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 983870e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
3 changes: 3 additions & 0 deletions tests/dummy/app/mixins/itemizable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Mixin from '@ember/object/mixin';

export default Mixin.create({});
7 changes: 7 additions & 0 deletions tests/dummy/app/models/homepage-item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import DS from 'ember-data';

export default DS.Model.extend({

itemizable: DS.belongsTo({ polymorphic: true }),

});
34 changes: 15 additions & 19 deletions tests/integration/mixins/loadable-store/load-records-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,14 @@ import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
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';

module('Integration | Mixins | LoadableStore | loadRecords', function(hooks) {
setupTest(hooks);

hooks.beforeEach(function() {
this.server = new MirageServer({
models: {
post: Model.extend({
comments: hasMany(),
author: belongsTo(),
tags: hasMany()
}),
comment: Model.extend({
post: belongsTo(),
author: belongsTo()
}),
tag: Model.extend({
posts: hasMany()
}),
author: Model.extend({
comments: hasMany(),
posts: hasMany()
})
},
discoverEmberDataModels: true,
baseConfig() {
this.resource('posts');
}
Expand Down Expand Up @@ -146,6 +128,20 @@ 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('/homepage-items');
let post = this.server.create('post');
let comment = this.server.create('comment');
this.server.create('homepage-item', { itemizable: post });
this.server.create('homepage-item', { itemizable: comment });

await this.store.loadRecords('homepage-item', { include: 'itemizable.tags' });

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 983870e

Please sign in to comment.