-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
/
findActivePage.test.js
97 lines (91 loc) · 3.56 KB
/
findActivePage.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
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
import { expect } from 'chai';
import findActivePage from './findActivePage';
describe('findActivePage', () => {
describe('old structure', () => {
const pages = [
{
pathname: '/getting-started',
icon: 'DescriptionIcon',
children: [{ pathname: '/getting-started/installation' }],
},
{
pathname: '/react-',
icon: 'ToggleOnIcon',
children: [
{
pathname: '/components',
subheader: '/components/inputs',
children: [
{ pathname: '/components/autocomplete' },
{ pathname: '/components/buttons', title: 'Button' },
{ pathname: '/components/button-group' },
{ pathname: '/components/checkboxes', title: 'Checkbox' },
{ pathname: '/components/floating-action-button' },
{ pathname: '/components/radio-buttons', title: 'Radio button' },
{ pathname: '/components/rating' },
{ pathname: '/components/selects', title: 'Select' },
{ pathname: '/components/slider' },
{ pathname: '/components/switches', title: 'Switch' },
{ pathname: '/components/text-fields', title: 'Text field' },
{ pathname: '/components/transfer-list' },
{ pathname: '/components/toggle-button' },
],
},
],
},
];
it('return first level page', () => {
expect(findActivePage(pages, '/getting-started').activePage).to.deep.equal({
pathname: '/getting-started',
icon: 'DescriptionIcon',
children: [{ pathname: '/getting-started/installation' }],
});
});
it('return nested page', () => {
expect(findActivePage(pages, '/getting-started/installation').activePage).to.deep.equal({
pathname: '/getting-started/installation',
});
});
it('return deep nested page', () => {
expect(findActivePage(pages, '/components/radio-buttons').activePage).to.deep.equal({
pathname: '/components/radio-buttons',
title: 'Radio button',
});
});
});
describe('new structure', () => {
const pages = [
{
pathname: '/material-ui/react-',
icon: 'ToggleOnIcon',
children: [
{
pathname: '/material-ui/components',
subheader: '/components/inputs',
children: [
{ pathname: '/material-ui/react-autocomplete' },
{ pathname: '/material-ui/react-buttons', title: 'Button' },
{ pathname: '/material-ui/react-button-group' },
{ pathname: '/material-ui/react-checkboxes', title: 'Checkbox' },
{ pathname: '/material-ui/react-floating-action-button' },
{ pathname: '/material-ui/react-radio-buttons', title: 'Radio button' },
{ pathname: '/material-ui/react-rating' },
{ pathname: '/material-ui/react-selects', title: 'Select' },
{ pathname: '/material-ui/react-slider' },
{ pathname: '/material-ui/react-switches', title: 'Switch' },
{ pathname: '/material-ui/react-text-fields', title: 'Text field' },
{ pathname: '/material-ui/react-transfer-list' },
{ pathname: '/material-ui/react-toggle-button' },
],
},
],
},
];
it('return deep nested page', () => {
expect(findActivePage(pages, '/material-ui/react-radio-buttons').activePage).to.deep.equal({
pathname: '/material-ui/react-radio-buttons',
title: 'Radio button',
});
});
});
});