-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2924 from WISE-Community/issue-2896-combine-miles…
…tone-reports Combine milestone reports
- Loading branch information
Showing
7 changed files
with
376 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 103 additions & 12 deletions
115
...e/src/app/teacher/milestone/milestone-report-data/milestone-report-data.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,112 @@ | ||
import { MilestoneReportDataComponent } from './milestone-report-data.component'; | ||
|
||
let comp: any = null; | ||
const nodeId1: string = 'node1'; | ||
const nodeId2: string = 'node2'; | ||
const componentId1: string = 'component1'; | ||
const componentId2: string = 'component2'; | ||
const counts1: any = { 1: 0, 2: 0, 3: 1, 4: 1, 5: 0 }; | ||
const counts2: any = { 1: 0, 2: 0, 3: 0, 4: 2, 5: 0 }; | ||
const average1: number = 3.5; | ||
const average2: number = 4; | ||
const scoreCount1: number = 2; | ||
const scoreCount2: number = 2; | ||
const scoreSum1: number = 7; | ||
const scoreSum2: number = 8; | ||
const stepTitle1: string = '1.1: Milestone Step 1'; | ||
const stepTitle2: string = '1.2: Milestone Step 2'; | ||
const componentData1: any = createComponentData( | ||
nodeId1, | ||
componentId1, | ||
counts1, | ||
average1, | ||
scoreCount1, | ||
scoreSum1, | ||
stepTitle1 | ||
); | ||
const componentData2: any = createComponentData( | ||
nodeId2, | ||
componentId2, | ||
counts2, | ||
average2, | ||
scoreCount2, | ||
scoreSum2, | ||
stepTitle2 | ||
); | ||
|
||
describe('MilestoneReportDataComponent', () => { | ||
it('#getPercent() should return percentage', () => { | ||
const comp = new MilestoneReportDataComponent(); | ||
comp.data = { scoreCount: 5 }; | ||
beforeEach(() => { | ||
comp = new MilestoneReportDataComponent(); | ||
comp.data = [componentData1, componentData2]; | ||
}); | ||
|
||
getPercent(); | ||
getCount(); | ||
getAverage(); | ||
getScoreValuesCount(); | ||
getComponentData(); | ||
}); | ||
|
||
function getPercent(): void { | ||
it('getPercent() should return percentage', () => { | ||
expect(comp.getPercent()).toEqual('100%'); | ||
}); | ||
} | ||
|
||
it('#getScoreValuesCount() should count for current score value', () => { | ||
const comp = new MilestoneReportDataComponent(); | ||
function getCount(): void { | ||
it('getCount() should get the count when scoreValues is not specified', () => { | ||
expect(comp.getCount()).toEqual(2); | ||
}); | ||
|
||
it('getCount() should get the count when scoreValues is specified', () => { | ||
comp.scoreValues = [5]; | ||
comp.data = { | ||
average: 4.3333333333333, | ||
counts: { 1: 0, 2: 0, 3: 1, 4: 0, 5: 2 }, | ||
scoreCount: 3, | ||
scoreSum: 13 | ||
}; | ||
expect(comp.getCount()).toEqual(0); | ||
}); | ||
} | ||
|
||
function getAverage(): void { | ||
it('getAverage() should get the average', () => { | ||
expect(comp.getAverage()).toEqual(4); | ||
}); | ||
} | ||
|
||
function getScoreValuesCount(): void { | ||
it('getScoreValuesCount() should get the count for the specified score value', () => { | ||
comp.scoreValues = [4]; | ||
expect(comp.getScoreValuesCount()).toEqual(2); | ||
}); | ||
}); | ||
} | ||
|
||
function getComponentData(): void { | ||
it(`getComponentData() should get the last component data if nodeId and componentId are not | ||
specified`, () => { | ||
expect(comp.getComponentData()).toEqual(componentData2); | ||
}); | ||
|
||
it(`getComponentData() should get the component data if nodeId and componentId are | ||
specified`, () => { | ||
comp.nodeId = nodeId1; | ||
comp.componentId = componentId1; | ||
expect(comp.getComponentData()).toEqual(componentData1); | ||
}); | ||
} | ||
|
||
function createComponentData( | ||
nodeId: string, | ||
componentId: string, | ||
counts: any, | ||
average: number, | ||
scoreCount: number, | ||
scoreSum: number, | ||
stepTitle: string | ||
): any { | ||
return { | ||
nodeId: nodeId, | ||
componentId: componentId, | ||
average: average, | ||
counts: counts, | ||
scoreCount: scoreCount, | ||
scoreSum: scoreSum, | ||
stepTitle: stepTitle | ||
}; | ||
} |
Oops, something went wrong.