-
Notifications
You must be signed in to change notification settings - Fork 481
/
workshop_indexTest.js
72 lines (66 loc) · 1.75 KB
/
workshop_indexTest.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
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
import WorkshopIndex from '@cdo/apps/code-studio/pd/workshop_dashboard/workshop_index';
import React from 'react';
import {expect} from 'chai';
import {shallow} from 'enzyme';
import sinon from 'sinon';
import Permission from '@cdo/apps/code-studio/pd/permission';
describe("WorkshopIndex", () => {
const fakeRouter = {
createHref() {}
};
const context = {
router: fakeRouter
};
beforeEach(() => {
sinon.mock(fakeRouter);
});
describe("Button counts", () => {
// map each user permission that utilizes the Workshop Dashboard
// to the list of buttons to which it has access
let permissionButtonMap = new Map([
[
"facilitator",
[
"Facilitator Survey Results",
"Filter View"
]
],
[
"csf_facilitator",
[
"New Workshop",
"Facilitator Survey Results",
"Filter View"
]
],
[
"workshop_organizer",
[
"New Workshop",
"Attendance Reports",
"Filter View"
]
],
[
"workshop_admin",
[
"New Workshop",
"Attendance Reports",
"Filter View"
]
]
]);
permissionButtonMap.forEach(function (buttons, permission) {
it(permission + " has " + buttons.length + " buttons", () => {
new Permission().setPermission(permission);
let workshopIndex = shallow(
<WorkshopIndex/>, {context}
);
expect(workshopIndex.find('ButtonToolbar Button').length).to.equal(buttons.length);
expect(workshopIndex.find('ButtonToolbar Button').map((button) => {
return button.children().first().text();
})).to.deep.equal(buttons);
});
});
});
});