Skip to content

Commit

Permalink
Merge pull request #7415 from stopfstedt/test-coverage-improvements
Browse files Browse the repository at this point in the history
improves test coverage for user/cohort assignment component.
  • Loading branch information
dartajax committed Sep 18, 2023
2 parents 923020f + 2c9572c commit 8c95230
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/integration/components/user-profile-cohorts-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ module('Integration | Component | user profile cohorts', function (hooks) {
const programYear2 = this.server.create('program-year', { program: program2 });
const programYear3 = this.server.create('program-year', { program: program1 });
const programYear4 = this.server.create('program-year', { program: program2 });
const programYear5 = this.server.create('program-year', { program: program1 });

this.cohort1 = this.server.create('cohort', { programYear: programYear1 });
this.cohort2 = this.server.create('cohort', { programYear: programYear2 });
this.cohort3 = this.server.create('cohort', { programYear: programYear3 });
this.cohort4 = this.server.create('cohort', { programYear: programYear4 });
this.cohort5 = this.server.create('cohort', { programYear: programYear5 });

const user = this.server.create('user', {
primaryCohort: this.cohort1,
Expand Down Expand Up @@ -64,7 +66,7 @@ module('Integration | Component | user profile cohorts', function (hooks) {
});

test('can edit user cohorts', async function (assert) {
assert.expect(13);
assert.expect(24);
this.set('user', this.user);
this.server.patch('api/users/:id', (schema, request) => {
const { data } = JSON.parse(request.requestBody);
Expand All @@ -89,8 +91,21 @@ module('Integration | Component | user profile cohorts', function (hooks) {
assert.strictEqual(component.manager.secondaryCohorts[0].title, 'school 1 program 1 cohort 1');
assert.strictEqual(component.manager.schools.filter.value, '1');
assert.strictEqual(component.manager.schools.filter.options.length, 2);
assert.strictEqual(component.manager.assignableCohorts.length, 2);
assert.strictEqual(component.manager.assignableCohorts[0].title, 'program 0 cohort 2');
assert.strictEqual(component.manager.assignableCohorts[1].title, 'program 0 cohort 4');
await component.manager.assignableCohorts[1].add();
assert.strictEqual(component.manager.assignableCohorts.length, 1);
assert.strictEqual(component.manager.assignableCohorts[0].title, 'program 0 cohort 2');
assert.strictEqual(component.manager.secondaryCohorts.length, 2);
assert.strictEqual(component.manager.secondaryCohorts[0].title, 'school 0 program 0 cohort 4');
assert.strictEqual(component.manager.secondaryCohorts[1].title, 'school 1 program 1 cohort 1');
await component.manager.secondaryCohorts[0].remove();
assert.strictEqual(component.manager.assignableCohorts.length, 2);
assert.strictEqual(component.manager.assignableCohorts[0].title, 'program 0 cohort 2');
assert.strictEqual(component.manager.assignableCohorts[1].title, 'program 0 cohort 4');
assert.strictEqual(component.manager.secondaryCohorts.length, 1);
assert.strictEqual(component.manager.secondaryCohorts[0].title, 'school 1 program 1 cohort 1');
await component.manager.schools.filter.select('2');
assert.strictEqual(component.manager.assignableCohorts.length, 1);
assert.strictEqual(component.manager.assignableCohorts[0].title, 'program 1 cohort 3');
Expand Down

0 comments on commit 8c95230

Please sign in to comment.