Skip to content

Commit

Permalink
test: add case for multiple saves
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobq committed Nov 11, 2019
1 parent 52b80c3 commit a966968
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/integration/adapters/pouch-basics-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,27 @@ test('create a new record', function (assert) {
}).finally(done);
});

test('update a newly created record before it has finished saving', function (assert) {
assert.expect(2);

const done = assert.async();
Promise.resolve().then(() => {
var newSoup = this.store().createRecord('taco-soup', { id: 'E', flavor: 'oops-wrong-flavor' });
newSoup.save();
newSoup.set('flavor', 'balsamic');
return newSoup.save();
}).then(() => {
return this.db().get('tacoSoup_2_E');
}).then((newDoc) => {
assert.equal(newDoc.data.flavor, 'balsamic', 'should have saved the attribute');

var recordInStore = this.store().peekRecord('tacoSoup', 'E');
assert.equal(newDoc._rev, recordInStore.get('rev'),
'should have associated the ember-data record with the rev for the new record');

}).finally(done);
});

test('creating an associated record stores a reference to it in the parent', function (assert) {
assert.expect(1);

Expand Down

0 comments on commit a966968

Please sign in to comment.