Skip to content

Commit

Permalink
Update model API docs to use the new packages import syntax (#6137) (#…
Browse files Browse the repository at this point in the history
…6189)

* Update model API docs to use the new packages import syntax (#6137)

* Using codemod to convert integration tests to new qunit syntax

* [CHORE tests] Converting unit tests to new qunit syntax (#6100)

* [CHORE] Converting unit tests to new qunit syntax
* Fixing prettier issues

* [CHORE tests] fix issue with test assertions expecting DS. (#6157)

* Use the @ember-data packages in the store API docs (#6144)
  • Loading branch information
runspired authored Jun 25, 2019
1 parent 12a2131 commit 78f8e83
Show file tree
Hide file tree
Showing 102 changed files with 30,311 additions and 30,058 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { module, test } from 'qunit';
import DS from 'ember-data';
import { settled } from '@ember/test-helpers';

module('integration/adapter/store-adapter - client-side delete', {
beforeEach() {
module('integration/adapter/store-adapter - client-side delete', function(hooks) {
hooks.beforeEach(function() {
this.Bookstore = DS.Model.extend({
books: DS.hasMany('book', { async: false, inverse: 'bookstore' }),
});
Expand All @@ -22,84 +22,84 @@ module('integration/adapter/store-adapter - client-side delete', {
});
this.store = this.env.store;
this.adapter = this.env.adapter;
},
});

afterEach() {
hooks.afterEach(function() {
run(this.env.container, 'destroy');
},
});
});

test('client-side deleted records can be added back from an inverse', async function(assert) {
this.adapter.deleteRecord = function(store, modelClass, snapshot) {
if (snapshot.adapterOptions.clientSideDelete) {
return resolve();
}

assert.ok(false, 'unreachable');
};

let bookstore = this.store.push({
data: {
id: '1',
type: 'bookstore',
relationships: {
books: {
data: [
{
id: '1',
type: 'book',
},
{
id: '2',
type: 'book',
},
],
},
},
},
included: [
{
test('client-side deleted records can be added back from an inverse', async function(assert) {
this.adapter.deleteRecord = function(store, modelClass, snapshot) {
if (snapshot.adapterOptions.clientSideDelete) {
return resolve();
}

assert.ok(false, 'unreachable');
};

let bookstore = this.store.push({
data: {
id: '1',
type: 'book',
},
{
id: '2',
type: 'book',
type: 'bookstore',
relationships: {
books: {
data: [
{
id: '1',
type: 'book',
},
{
id: '2',
type: 'book',
},
],
},
},
},
],
});
included: [
{
id: '1',
type: 'book',
},
{
id: '2',
type: 'book',
},
],
});

assert.deepEqual(bookstore.get('books').mapBy('id'), ['1', '2'], 'initial hasmany loaded');
assert.deepEqual(bookstore.get('books').mapBy('id'), ['1', '2'], 'initial hasmany loaded');

let book2 = this.store.peekRecord('book', '2');
let book2 = this.store.peekRecord('book', '2');

await book2.destroyRecord({ adapterOptions: { clientSideDelete: true } });
await book2.destroyRecord({ adapterOptions: { clientSideDelete: true } });

run(() => book2.unloadRecord());
run(() => book2.unloadRecord());

await settled();
await settled();

assert.equal(this.store.hasRecordForId('book', '2'), false, 'book 2 unloaded');
assert.deepEqual(bookstore.get('books').mapBy('id'), ['1'], 'one book client-side deleted');
assert.equal(this.store.hasRecordForId('book', '2'), false, 'book 2 unloaded');
assert.deepEqual(bookstore.get('books').mapBy('id'), ['1'], 'one book client-side deleted');

this.store.push({
data: {
id: '2',
type: 'book',
relationships: {
bookstore: {
data: {
id: '1',
type: 'bookstore',
this.store.push({
data: {
id: '2',
type: 'book',
relationships: {
bookstore: {
data: {
id: '1',
type: 'bookstore',
},
},
},
},
},
});
});

assert.deepEqual(
bookstore.get('books').mapBy('id'),
['1', '2'],
'the deleted book (with same id) is pushed back into the store'
);
assert.deepEqual(
bookstore.get('books').mapBy('id'),
['1', '2'],
'the deleted book (with same id) is pushed back into the store'
);
});
});
Loading

0 comments on commit 78f8e83

Please sign in to comment.