Skip to content

Commit

Permalink
added test for Terms in ProgramYear report
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchadwick committed Oct 14, 2024
1 parent 2fda485 commit 56f1042
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions packages/frontend/tests/unit/services/reporting-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { setupIntl } from 'ember-intl/test-support';
import { setupMirage } from 'frontend/tests/test-support/mirage';
import { DateTime } from 'luxon';

module('Unit | Service | reporting', function (hooks) {
setupTest(hooks);
Expand Down Expand Up @@ -226,6 +227,45 @@ module('Unit | Service | reporting', function (hooks) {
);
});

test('buildReportDescription() - all terms for program year X in school Y', async function (assert) {
const school = this.server.create('school', { title: 'School of Schools' });
const program = this.server.create('program', { school: school });
const programYear = this.server.create('program-year', {
program,
startYear: DateTime.now().year,
});
const vocabulary = this.server.create('vocabulary', { school });
this.server.create('term', {
title: 'foo bar',
programYears: [programYear],
vocabulary,
});
const report = this.server.create('report', {
subject: 'term',
prepositionalObject: 'program year',
prepositionalObjectTableRowId: programYear.id,
school,
});

const store = this.owner.lookup('service:store');
const reportModel = await store.findRecord('report', report.id);
const programYearModel = await store.findRecord('program year', programYear.id);
const schoolModel = await store.findRecord('school', school.id);
const title = await this.service.buildReportDescription(
reportModel.subject,
reportModel.prepositionalObject,
reportModel.prepositionalObjectTableRowId,
school,
);
const classOfYear = await programYearModel.getClassOfYear();
const programYearTitle = `${classOfYear} ${program.title}`;

assert.strictEqual(
title,
`This report shows all Terms associated with Program Year "${programYearTitle}" (${classOfYear}) in ${schoolModel.title}.`,
);
});

test('buildReportDescription() - broken report', async function (assert) {
const school = this.server.create('school', { title: 'School of Schools' });
const report = this.server.create('report', {
Expand Down

0 comments on commit 56f1042

Please sign in to comment.