mardi 3 mai 2016

Error saving record in ember component test

When trying to save a ember-data model in a component integration test, I get the following test error in qunit:

Promise rejected after demo ..: Assertion Failed: You can only unload a record which is not inFlight. `<(subclass of DS.Model):ember272:null>`@ 118 ms
Source:     
Error: Assertion Failed: You can only unload a record which is not inFlight. `<(subclass of DS.Model):ember272:null>`
    at new Error (native)

The test looks like:

moduleForComponent('some-component', 'Integration | Component | some-component', {
  integration: true
});

test('demo ..', function(assert) {
  let store = this.container.lookup('service:store');
  let foo = null;

  stubRequest('post', `/foos/`, (request) => {
    return request.ok({ foo: { id: 100, name: 'bar' }});
  });

  Ember.run(() => {
    foo = store.createRecord('foo', { name: 'foo' });
    foo.save();
  });

  assert.equal(foo.get('displayName'), 'bar', 'should update display name');
});

Not sure what I'm missing.

Versions: Ember: 2.4.3, Ember data: 2.4.0




Aucun commentaire:

Enregistrer un commentaire