mercredi 30 juin 2021

How could I set the class property passed as an array to an inner rendered component for ember test as at the moment by using set doesnt pass array?

the users are defined on the component class

// recipients-component.js
export default class RecipientsComponent extends Component {

get users () {
return [{name:'jerry'},{name:'ana'},{name:'erik'}]
}

get selectedUsers () {
return [{name:'jerry'}]
}

}

This users are passed to a powerSlectMultiple component


// recipients-component.hbs
  <div class="card-row">
 <h3>Recipients</>
        <div class="card-row">
          <PowerSelectMultiple
        @placeholder="Select recipient(s)"
        @searchEnabled=true
        @selected=
        @options=
        @onChange=
        @onKeydown=
        @searchField="name"
        as |user|
      >
        
      </PowerSelectMultiple>
  </div>

Not rendering the users array when I create those with this.set()

  • Is there a way to pass or create the users array to pass into this component?

// recipients-component-test.js
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Component | recipients-component', function (hooks) {
  setupRenderingTest(hooks);

  test('it renders users', function (assert) {

   this.set('users', [{name:'jerry'},{name:'ana'},{name:'erik'}]); // not working
   await render(hbs`<Recipients-component  />`);

    assert.equal(this.$('h3').text().trim(), 'Recipients');
  });
});



Aucun commentaire:

Enregistrer un commentaire