-
Notifications
You must be signed in to change notification settings - Fork 81
/
transforms.test.js
38 lines (35 loc) · 1.13 KB
/
transforms.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import selectors from 'data/selectors';
import { GradeFormats } from 'data/constants/grades';
import transforms from './transforms';
jest.mock('data/selectors', () => {
const {
GradeFormats: { absolute, percent },
} = jest.requireActual('data/constants/grades');
return {
grades: {
subsectionGrade: {
[absolute]: jest.fn(v => ({ absolute: v })),
[percent]: jest.fn(v => ({ percent: v })),
},
roundGrade: jest.fn(),
},
};
});
describe('redux transforms', () => {
describe('grades transforms', () => {
test('subsectionGrade', () => {
const subsection = 'test-subsection';
expect(transforms.grades.subsectionGrade({
gradeFormat: GradeFormats.absolute,
subsection,
})()).toEqual(selectors.grades.subsectionGrade.absolute(subsection));
expect(transforms.grades.subsectionGrade({
gradeFormat: GradeFormats.percent,
subsection,
})()).toEqual(selectors.grades.subsectionGrade.percent(subsection));
});
test('roundGrade', () => {
expect(transforms.grades.roundGrade).toEqual(selectors.grades.roundGrade);
});
});
});