-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathToolCardBoxes.test.js
More file actions
99 lines (93 loc) · 2.5 KB
/
ToolCardBoxes.test.js
File metadata and controls
99 lines (93 loc) · 2.5 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import React from 'react';
import renderer from 'react-test-renderer';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import ToolCardBoxes from '../js/components/home/toolsManagement/ToolCardBoxes';
import { TRANSLATION_WORDS, TRANSLATION_NOTES } from '../js/common/constants';
jest.mock('material-ui/Checkbox');
test('translationWords should have three boxes unchecked', () => {
const props = {
toolName: TRANSLATION_WORDS,
selectedCategories: [],
onChecked: jest.fn(() => {}),
availableCategories: {},
translate: jest.fn(() => {}),
selectedGL: 'en',
showPopover: jest.fn(() => {}),
};
const component = renderer.create(
<ToolCardBoxes {...props}></ToolCardBoxes>,
);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
test('translationNotes should have 4 boxes checked', () => {
const availableCategories = {
discourse: ['writing-background', 'writing-endofstory'],
numbers: ['translate-numbers', 'translate-fraction'],
figures: [
'figs-idiom',
'figs-irony',
'figs-metaphor',
'figs-rquestion',
'figs-simile',
'figs-apostrophe',
'figs-euphemism',
],
culture: ['figs-explicit'],
grammar: [
'figs-hypo',
'figs-activepassive',
'figs-gendernotations',
'figs-pronouns',
'figs-you',
'figs-123person',
'figs-abstractnouns',
'figs-distinguish',
],
};
const selectedCategories = [
'writing-background',
'translate-numbers',
'translate-fraction',
'figs-idiom',
'figs-irony',
'figs-metaphor',
'figs-rquestion',
'figs-simile',
'figs-apostrophe',
'figs-explicit',
'figs-hypo',
'figs-activepassive',
'figs-pronouns',
'figs-you',
'figs-123person',
'figs-abstractnouns',
];
const props = {
toolName: TRANSLATION_NOTES,
selectedCategories,
availableCategories,
checks: ['figs-gendernotations', 'figs-pronouns', 'figs-irony'],
onChecked: jest.fn(() => {}),
bookId: 'tit',
translate: jest.fn((txt) => 'translated: ' + txt),
selectedGL: 'en',
showPopover: jest.fn(() => {}),
onCategoryChecked: jest.fn(() => {}),
onSubcategoryChecked: jest.fn(() => {}),
};
const component = shallow(
<ToolCardBoxes {...props}></ToolCardBoxes>,
);
component.setState({
expanded: {
grammar: true,
figures: true,
discourse: true,
numbers: true,
},
});
const subCat = toJson(component);
expect(subCat).toMatchSnapshot();
});