Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

Commit

Permalink
Fixup objective terms list
Browse files Browse the repository at this point in the history
Turns out we didn't use this backing class at all, so I removed it.
Ensures we're getting the array and not a proxy by awaiting the terms.
And finally, sent in clean test data instead of munging the existing
model as that was causing issues with this test.
  • Loading branch information
jrjohnson committed Oct 2, 2022
1 parent 3caae7b commit 784a0e6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 46 deletions.
2 changes: 1 addition & 1 deletion addon/components/objective-list-item-terms.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{{#if vocab.termCount}}
<DetailTermsList
@vocabulary={{vocab}}
@terms={{@subject.terms}}
@terms={{await @subject.terms}}
@canEdit={{false}}
@manage={{if @editable @manage (noop)}}
/>
Expand Down
35 changes: 0 additions & 35 deletions addon/components/objective-list-item-terms.js

This file was deleted.

22 changes: 12 additions & 10 deletions tests/integration/components/objective-list-item-terms-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module('Integration | Component | objective-list-item-terms', function (hooks) {
setupMirage(hooks);

hooks.beforeEach(async function () {
const course = this.server.create('course');
this.course = this.server.create('course');
const school1 = this.server.create('school');
const school2 = this.server.create('school');
const vocabulary1 = this.server.create('vocabulary', { school: school1 });
Expand All @@ -22,15 +22,12 @@ module('Integration | Component | objective-list-item-terms', function (hooks) {
const term2 = this.server.create('term', { vocabulary: vocabulary1 });
const term3 = this.server.create('term', { vocabulary: vocabulary2 });
const courseObjective = this.server.create('courseObjective', {
course,
course: this.course,
terms: [term1, term2, term3],
});
this.subject = await this.owner
.lookup('service:store')
.findRecord('course-objective', courseObjective.id);
this.vocabularyModel1 = await this.owner
.lookup('service:store')
.findRecord('vocabulary', vocabulary1.id);
const store = this.owner.lookup('service:store');
this.subject = await store.findRecord('course-objective', courseObjective.id);
this.vocabularyModel1 = await store.findRecord('vocabulary', vocabulary1.id);
});

test('it renders and is accessible when managing', async function (assert) {
Expand Down Expand Up @@ -92,8 +89,13 @@ module('Integration | Component | objective-list-item-terms', function (hooks) {

test('manage new', async function (assert) {
assert.expect(1);
this.subject.set('terms', []);
this.set('subject', this.subject);
const courseObjective = this.server.create('courseObjective', {
course: this.course,
});
const subject = await this.owner
.lookup('service:store')
.findRecord('course-objective', courseObjective.id);
this.set('subject', subject);
this.set('manage', (vocabulary) => {
assert.strictEqual(vocabulary, null);
});
Expand Down

0 comments on commit 784a0e6

Please sign in to comment.