How to get property from component when testing?

Keo

How can I check component's property value when component doesn't have template? In application the component is extended and template is provided that way.

//my-component.js
export default Ember.Component.extend({
    foo: 'bar'
});

//my-component-test.hbs
integration: true;
test('it renders', function(assert) {
  this.set('foo2', 'foo2');
  this.render(hbs`{{my-component foo=foo2}}`);
  assert.equal(/* ??? */, 'foo2');
});

I am not able to use this.render(hbs'{{#my-component foo=foo2}}{{foo}}{{/my-component}}'); because foo is not yielded. Accessing component directly is not possible either.

Keo

And the solution is to use unit test instead.

import { moduleForComponent, test } from 'ember-qunit';

moduleForComponent('forms/base-form', 'Unit | Component | forms/base-form field', {
  unit: true
});

test('it renders', function(assert) {
  const foo2 = 'foo2';
  const component = this.subject({foo: foo2});
  assert.equal(component.get('foo'), 'foo2');
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to get value from field of superior record when it is setting property of subordinate record

From Java

Angular Parent Component property does not get updated when changing value from Child Component

From Java

How to get data from function component?

From Dev

How to get component value from ActionEvent object?

From Dev

How to avoid "Unable to get property 'X' of undefined or null reference" when creating $scope properties from JSON data

From Dev

How to get a property from a plist

From Dev

How to get component properties from main component in Angular2?

From Dev

How to get property from ofono

From Dev

How to get translate property from a group?

From Dev

How to get the component's viewmodel from component's node in KnockoutJS

From Dev

How to access the "key" property from a reactjs component

From Dev

Get CSS property values from a component's "style" prop

From Dev

How to get component from component name in codenameone?

From Dev

How to set a Component's property value from inside a FileReader event

From Dev

How can I access a globally defined property that is accessed through a property file using Spock when unit testing

From Dev

How to get updated property in singleton from a component in Blazor?

From Dev

How to get an object property value when property name is in a variable?

From Dev

How to get component version from Joomla?

From Dev

How to get a property from another property in JS?

From Dev

How to get a property from a plist

From Dev

How to change controller property from component?

From Dev

How to get component properties from main component in Angular2?

From Dev

How to get property value from JavaScript object when key is 0_1

From Dev

How to get string of x:Name property of component in Xamarin form?

From Dev

Emberjs How to update property on a component from route?

From Dev

React: How to get results from one component to another component

From Dev

ReactJS: How to get property in a component container?

From Dev

Override pipe when testing component

From Dev

How get data from JFrame Component Java?

Related Related

  1. 1

    How to get value from field of superior record when it is setting property of subordinate record

  2. 2

    Angular Parent Component property does not get updated when changing value from Child Component

  3. 3

    How to get data from function component?

  4. 4

    How to get component value from ActionEvent object?

  5. 5

    How to avoid "Unable to get property 'X' of undefined or null reference" when creating $scope properties from JSON data

  6. 6

    How to get a property from a plist

  7. 7

    How to get component properties from main component in Angular2?

  8. 8

    How to get property from ofono

  9. 9

    How to get translate property from a group?

  10. 10

    How to get the component's viewmodel from component's node in KnockoutJS

  11. 11

    How to access the "key" property from a reactjs component

  12. 12

    Get CSS property values from a component's "style" prop

  13. 13

    How to get component from component name in codenameone?

  14. 14

    How to set a Component's property value from inside a FileReader event

  15. 15

    How can I access a globally defined property that is accessed through a property file using Spock when unit testing

  16. 16

    How to get updated property in singleton from a component in Blazor?

  17. 17

    How to get an object property value when property name is in a variable?

  18. 18

    How to get component version from Joomla?

  19. 19

    How to get a property from another property in JS?

  20. 20

    How to get a property from a plist

  21. 21

    How to change controller property from component?

  22. 22

    How to get component properties from main component in Angular2?

  23. 23

    How to get property value from JavaScript object when key is 0_1

  24. 24

    How to get string of x:Name property of component in Xamarin form?

  25. 25

    Emberjs How to update property on a component from route?

  26. 26

    React: How to get results from one component to another component

  27. 27

    ReactJS: How to get property in a component container?

  28. 28

    Override pipe when testing component

  29. 29

    How get data from JFrame Component Java?

HotTag

Archive