@@ -2,6 +2,7 @@ import { module, test } from 'qunit';
2
2
import { setupTest } from 'ember-qunit' ;
3
3
import { setupIntl } from 'ember-intl/test-support' ;
4
4
import { setupMirage } from 'frontend/tests/test-support/mirage' ;
5
+ import { DateTime } from 'luxon' ;
5
6
6
7
module ( 'Unit | Service | reporting' , function ( hooks ) {
7
8
setupTest ( hooks ) ;
@@ -226,6 +227,45 @@ module('Unit | Service | reporting', function (hooks) {
226
227
) ;
227
228
} ) ;
228
229
230
+ test ( 'buildReportDescription() - all terms for program year X in school Y' , async function ( assert ) {
231
+ const school = this . server . create ( 'school' , { title : 'School of Schools' } ) ;
232
+ const program = this . server . create ( 'program' , { school : school } ) ;
233
+ const programYear = this . server . create ( 'program-year' , {
234
+ program,
235
+ startYear : DateTime . now ( ) . year ,
236
+ } ) ;
237
+ const vocabulary = this . server . create ( 'vocabulary' , { school } ) ;
238
+ this . server . create ( 'term' , {
239
+ title : 'foo bar' ,
240
+ programYears : [ programYear ] ,
241
+ vocabulary,
242
+ } ) ;
243
+ const report = this . server . create ( 'report' , {
244
+ subject : 'term' ,
245
+ prepositionalObject : 'program year' ,
246
+ prepositionalObjectTableRowId : programYear . id ,
247
+ school,
248
+ } ) ;
249
+
250
+ const store = this . owner . lookup ( 'service:store' ) ;
251
+ const reportModel = await store . findRecord ( 'report' , report . id ) ;
252
+ const programYearModel = await store . findRecord ( 'program year' , programYear . id ) ;
253
+ const schoolModel = await store . findRecord ( 'school' , school . id ) ;
254
+ const title = await this . service . buildReportDescription (
255
+ reportModel . subject ,
256
+ reportModel . prepositionalObject ,
257
+ reportModel . prepositionalObjectTableRowId ,
258
+ school ,
259
+ ) ;
260
+ const classOfYear = await programYearModel . getClassOfYear ( ) ;
261
+ const programYearTitle = `${ classOfYear } ${ program . title } ` ;
262
+
263
+ assert . strictEqual (
264
+ title ,
265
+ `This report shows all Terms associated with Program Year "${ programYearTitle } " in ${ schoolModel . title } .` ,
266
+ ) ;
267
+ } ) ;
268
+
229
269
test ( 'buildReportDescription() - broken report' , async function ( assert ) {
230
270
const school = this . server . create ( 'school' , { title : 'School of Schools' } ) ;
231
271
const report = this . server . create ( 'report' , {
0 commit comments