mercredi 18 novembre 2015

Ember Integration test with ember-data models

How can I can I test my components that get an ember-data model passed into it as props?

For example:

{{#queue/review/moderatable-text model=activity property="info_name" handleModeration="handleModeration"}}
    {{pro-form-textfield value=activity.info_name}}
{{/queue/review/moderatable-text}}

where activity is a model instance.

How do I setup my integration test to pass in activity and to test it where component can save the model?

I tried to stub out as if it's pure ember objects:

test('it sets approved', function(assert) {

  // Set any properties with this.set('myProperty', 'value');
  // Handle any actions with this.on('myAction', function(val) { ... });" + EOL + EOL +
  this.set('property', 'info_title');
  this.set('model', Ember.Object.create({counterpart: Ember.Object.create()}))

  // Template block usage:" + EOL +
  this.render(hbs`
    {{#queue/review/moderatable-text property=property}}
      {{pro-form-textfield value=value}}
    {{/queue/review/moderatable-text}}
  `);

  this.$('.approve-button').click();

  assert.ok(this.get('approved'));
});

but then I'd have to create my own save() methods and others.

Thoughts?

Aucun commentaire:

Enregistrer un commentaire