Skip to content

Commit

Permalink
Failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
samselikoff committed Jun 22, 2019
1 parent 10f8168 commit 802b35f
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions tests/integration/mixins/loadable-store/load-records-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { waitUntil } from '@ember/test-helpers';
import MirageServer from 'dummy/tests/integration/helpers/mirage-server';
import { Model, hasMany, belongsTo } from 'ember-cli-mirage';
import LoadableStore from 'ember-data-storefront/mixins/loadable-store';
import DSModel from 'ember-data/model';

module('Integration | Mixins | LoadableStore | loadRecords', function(hooks) {
setupTest(hooks);
Expand All @@ -14,11 +15,15 @@ module('Integration | Mixins | LoadableStore | loadRecords', function(hooks) {
post: Model.extend({
comments: hasMany(),
author: belongsTo(),
tags: hasMany()
tags: hasMany(),

owner: belongsTo('author', { inverse: null })
}),
comment: Model.extend({
post: belongsTo(),
author: belongsTo()
author: belongsTo(),

owner: belongsTo('post', { inverse: null })
}),
tag: Model.extend({
posts: hasMany()
Expand Down Expand Up @@ -146,6 +151,28 @@ module('Integration | Mixins | LoadableStore | loadRecords', function(hooks) {
assert.equal(posts.get('firstObject.comments.length'), 2);
});

test('it can load a polymorphic collection with model-specific includes', async function(assert) {
server.logging = true;
this.server.get('/items', schema => {
let posts = schema.posts.all();
let comments = schema.comments.all();

return posts.mergeCollection(comments);
});
let post = this.server.create('post', {
owner: this.server.create('author')
});
let comment = this.server.create('comment', {
owner: post
});
this.owner.register('model:item', DSModel.extend());

await this.store.loadRecords('item', { include: 'owner' });

assert.ok(this.store.peekRecord('post', post.id));
assert.ok(this.store.peekRecord('comment', comment.id));
});

module('Tracking includes', function() {
test('it will track an include', async function(assert) {
let serverPost = this.server.create('post', { title: 'My post' });
Expand Down

0 comments on commit 802b35f

Please sign in to comment.