@antv/dumi-theme-antv 0.2.2 → 0.3.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +32 -33
- package/dist/builtins/Playground/index.d.ts +21 -0
- package/dist/builtins/Playground/index.js +69 -0
- package/dist/builtins/Playground/index.module.less +15 -0
- package/dist/context.d.ts +6 -0
- package/dist/context.js +2 -0
- package/dist/layouts/DocLayout.d.ts +7 -0
- package/dist/layouts/DocLayout.js +48 -0
- package/dist/layouts/entry/API.d.ts +10 -0
- package/dist/layouts/entry/API.js +12 -0
- package/dist/layouts/entry/Index.d.ts +7 -0
- package/dist/layouts/entry/Index.js +79 -0
- package/dist/layouts/entry/Manual.d.ts +8 -0
- package/dist/layouts/entry/Manual.js +13 -0
- package/dist/locales/en.json +98 -0
- package/dist/locales/zh.json +98 -0
- package/dist/pages/404.d.ts +6 -0
- package/dist/pages/404.js +18 -0
- package/dist/pages/Example/index.d.ts +6 -0
- package/dist/pages/Example/index.js +115 -0
- package/dist/pages/Example/index.module.less +82 -0
- package/dist/pages/Example/utils.d.ts +1 -0
- package/dist/pages/Example/utils.js +9 -0
- package/dist/pages/Examples/components/Accouncement/index.d.ts +6 -0
- package/dist/pages/Examples/components/Accouncement/index.js +60 -0
- package/dist/pages/Examples/components/Accouncement/index.module.less +9 -0
- package/dist/pages/Examples/components/Article/index.d.ts +2 -0
- package/dist/pages/Examples/components/Article/index.js +8 -0
- package/dist/pages/Examples/components/Article/index.module.less +2 -0
- package/dist/pages/Examples/components/ExampleTopicMenu/components/LeftMenu/index.d.ts +10 -0
- package/dist/pages/Examples/components/ExampleTopicMenu/components/LeftMenu/index.js +74 -0
- package/dist/pages/Examples/components/ExampleTopicMenu/index.d.ts +9 -0
- package/{es/builtins/Example.js → dist/pages/Examples/components/ExampleTopicMenu/index.js} +47 -33
- package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.d.ts +10 -0
- package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.js +33 -0
- package/dist/pages/Examples/components/GalleryPageContent/index.d.ts +10 -0
- package/dist/pages/Examples/components/GalleryPageContent/index.js +81 -0
- package/dist/pages/Examples/index.d.ts +8 -0
- package/dist/pages/Examples/index.js +95 -0
- package/dist/pages/Examples/index.module.less +607 -0
- package/dist/pages/Examples/types.d.ts +34 -0
- package/dist/pages/Examples/types.js +1 -0
- package/dist/plugin/examples.d.ts +21 -0
- package/dist/plugin/examples.js +105 -0
- package/dist/plugin/index.d.ts +3 -0
- package/dist/plugin/index.js +113 -0
- package/dist/plugin/utils.d.ts +5 -0
- package/dist/plugin/utils.js +46 -0
- package/dist/slots/404.d.ts +2 -0
- package/{es/antv/404/index.js → dist/slots/404.js} +4 -9
- package/{es/antv/Cases/Cases.d.ts → dist/slots/Cases/index.d.ts} +5 -4
- package/{es/antv/Cases/Cases.js → dist/slots/Cases/index.js} +25 -25
- package/{src/antv/Cases/Cases.module.less → dist/slots/Cases/index.module.less} +36 -5
- package/dist/slots/CodeEditor/Toolbar.d.ts +67 -0
- package/dist/slots/CodeEditor/Toolbar.js +140 -0
- package/dist/slots/CodeEditor/Toolbar.module.less +81 -0
- package/dist/slots/CodeEditor/index.d.ts +58 -0
- package/dist/slots/CodeEditor/index.js +226 -0
- package/dist/slots/CodeEditor/index.module.less +11 -0
- package/dist/slots/CodeEditor/utils.d.ts +42 -0
- package/dist/slots/CodeEditor/utils.js +157 -0
- package/dist/slots/CodePreview/CodeHeader.d.ts +19 -0
- package/dist/slots/CodePreview/CodeHeader.js +32 -0
- package/dist/slots/CodePreview/CodeHeader.module.less +0 -0
- package/dist/slots/CodePreview/index.d.ts +17 -0
- package/dist/slots/CodePreview/index.js +29 -0
- package/dist/slots/CodePreview/index.module.less +43 -0
- package/dist/slots/CodeRunner/index.d.ts +15 -0
- package/dist/slots/CodeRunner/index.js +79 -0
- package/dist/slots/CodeRunner/index.module.less +0 -0
- package/dist/slots/CodeRunner/utils.d.ts +11 -0
- package/dist/slots/CodeRunner/utils.js +36 -0
- package/dist/slots/Companies/index.d.ts +13 -0
- package/dist/slots/Companies/index.js +49 -0
- package/dist/slots/Companies/index.module.less +82 -0
- package/dist/slots/Detail/News.d.ts +10 -0
- package/{es/antv/Banner/Notification.js → dist/slots/Detail/News.js} +8 -11
- package/{src/antv/Banner/Notification.module.less → dist/slots/Detail/News.module.less} +15 -3
- package/dist/slots/Detail/index.d.ts +27 -0
- package/dist/slots/Detail/index.js +124 -0
- package/{src/antv/Banner/Banner.module.less → dist/slots/Detail/index.module.less} +42 -74
- package/dist/slots/ExampleSider/index.d.ts +21 -0
- package/dist/slots/ExampleSider/index.js +196 -0
- package/dist/slots/ExampleSider/index.module.less +141 -0
- package/{es/antv → dist/slots}/Features/FeatureCard.d.ts +2 -1
- package/{es/antv → dist/slots}/Features/FeatureCard.js +6 -6
- package/{src/antv → dist/slots}/Features/FeatureCard.module.less +8 -1
- package/{es/antv → dist/slots}/Features/index.d.ts +2 -2
- package/{es/antv → dist/slots}/Features/index.js +19 -26
- package/{src/antv/Features/Features.module.less → dist/slots/Features/index.module.less} +34 -3
- package/dist/slots/Footer/index.d.ts +18 -0
- package/dist/slots/Footer/index.js +188 -0
- package/dist/slots/Footer/index.module.less +86 -0
- package/dist/slots/Header/Logo.d.ts +7 -0
- package/{es/antv → dist/slots}/Header/Logo.js +6 -2
- package/dist/slots/Header/LogoWhite.d.ts +7 -0
- package/dist/slots/Header/LogoWhite.js +19 -0
- package/dist/slots/Header/Navs.d.ts +26 -0
- package/dist/slots/Header/Navs.js +63 -0
- package/dist/slots/Header/Products/NavigatorBanner.d.ts +10 -0
- package/dist/slots/Header/Products/NavigatorBanner.js +34 -0
- package/dist/slots/Header/Products/NavigatorBanner.module.less +39 -0
- package/{es/antv → dist/slots/Header}/Products/Product.d.ts +3 -3
- package/{es/antv → dist/slots/Header}/Products/Product.js +11 -16
- package/{src/antv → dist/slots/Header}/Products/Product.module.less +10 -8
- package/{es/antv → dist/slots/Header}/Products/getProducts.d.ts +2 -7
- package/dist/slots/Header/Products/getProducts.js +67 -0
- package/dist/slots/Header/Products/index.d.ts +9 -0
- package/{es/antv → dist/slots/Header}/Products/index.js +15 -22
- package/dist/slots/Header/Search.d.ts +12 -0
- package/dist/slots/Header/Search.js +90 -0
- package/dist/slots/Header/Search.module.less +39 -0
- package/dist/slots/Header/index.d.ts +66 -0
- package/dist/slots/Header/index.js +380 -0
- package/dist/slots/Header/index.module.less +382 -0
- package/dist/slots/Header/utils.d.ts +1 -0
- package/dist/slots/Header/utils.js +26 -0
- package/dist/slots/Loading/index.d.ts +7 -0
- package/dist/slots/Loading/index.js +79 -0
- package/dist/slots/Loading/index.module.less +279 -0
- package/dist/slots/ManualContent/NavigatorBanner.d.ts +9 -0
- package/dist/slots/ManualContent/NavigatorBanner.js +36 -0
- package/dist/slots/ManualContent/NavigatorBanner.module.less +39 -0
- package/dist/slots/ManualContent/ReadingTime.d.ts +3 -0
- package/dist/slots/ManualContent/ReadingTime.js +10 -0
- package/dist/slots/ManualContent/index.d.ts +9 -0
- package/dist/slots/ManualContent/index.js +344 -0
- package/dist/slots/ManualContent/index.module.less +668 -0
- package/dist/slots/ManualContent/utils.d.ts +3 -0
- package/dist/slots/ManualContent/utils.js +35 -0
- package/dist/slots/SEO.d.ts +10 -0
- package/dist/slots/SEO.js +59 -0
- package/dist/slots/TOC.d.ts +5 -0
- package/dist/slots/TOC.js +6 -0
- package/dist/slots/_.less +83 -0
- package/dist/slots/global.d.ts +1 -0
- package/dist/slots/global.js +7 -0
- package/dist/slots/hooks.d.ts +16 -0
- package/{es/antv → dist/slots}/hooks.js +60 -37
- package/dist/slots/utils.d.ts +5 -0
- package/dist/slots/utils.js +112 -0
- package/dist/types.d.ts +86 -0
- package/dist/types.js +1 -0
- package/dist/typings.d.ts +24 -0
- package/package.json +110 -47
- package/es/antv/404/index.d.ts +0 -2
- package/es/antv/Banner/Banner.module.less +0 -412
- package/es/antv/Banner/Notification.d.ts +0 -10
- package/es/antv/Banner/Notification.module.less +0 -108
- package/es/antv/Banner/index.d.ts +0 -25
- package/es/antv/Banner/index.js +0 -104
- package/es/antv/Cases/Cases.module.less +0 -203
- package/es/antv/Features/FeatureCard.module.less +0 -51
- package/es/antv/Features/Features.module.less +0 -169
- package/es/antv/Footer/Footer.module.less +0 -36
- package/es/antv/Footer/index.d.ts +0 -12
- package/es/antv/Footer/index.js +0 -237
- package/es/antv/Header/Logo.d.ts +0 -4
- package/es/antv/Products/Product.module.less +0 -146
- package/es/antv/Products/getNewProducts.d.ts +0 -24
- package/es/antv/Products/getNewProducts.js +0 -35
- package/es/antv/Products/getProducts.js +0 -460
- package/es/antv/Products/index.d.ts +0 -9
- package/es/antv/hooks.d.ts +0 -14
- package/es/antv/mixins.less +0 -21
- package/es/antv/utils.d.ts +0 -5
- package/es/antv/utils.js +0 -49
- package/es/builtins/API.d.ts +0 -3
- package/es/builtins/API.js +0 -37
- package/es/builtins/Alert.d.ts +0 -3
- package/es/builtins/Alert.js +0 -7
- package/es/builtins/Alert.less +0 -62
- package/es/builtins/Badge.d.ts +0 -3
- package/es/builtins/Badge.js +0 -7
- package/es/builtins/Badge.less +0 -31
- package/es/builtins/Example.d.ts +0 -5
- package/es/builtins/Example.less +0 -47
- package/es/builtins/Previewer.d.ts +0 -39
- package/es/builtins/Previewer.js +0 -225
- package/es/builtins/Previewer.less +0 -406
- package/es/builtins/SourceCode.d.ts +0 -10
- package/es/builtins/SourceCode.js +0 -70
- package/es/builtins/SourceCode.less +0 -103
- package/es/builtins/Table.d.ts +0 -4
- package/es/builtins/Table.js +0 -56
- package/es/builtins/Table.less +0 -43
- package/es/builtins/Tree.d.ts +0 -4
- package/es/builtins/Tree.js +0 -213
- package/es/builtins/Tree.less +0 -159
- package/es/components/Dark.d.ts +0 -9
- package/es/components/Dark.js +0 -125
- package/es/components/Dark.less +0 -121
- package/es/components/LocaleSelect.d.ts +0 -6
- package/es/components/LocaleSelect.js +0 -53
- package/es/components/LocaleSelect.less +0 -59
- package/es/components/Navbar.d.ts +0 -10
- package/es/components/Navbar.js +0 -155
- package/es/components/Navbar.less +0 -180
- package/es/components/SearchBar.d.ts +0 -4
- package/es/components/SearchBar.js +0 -81
- package/es/components/SearchBar.less +0 -165
- package/es/components/SideMenu.d.ts +0 -10
- package/es/components/SideMenu.js +0 -99
- package/es/components/SideMenu.less +0 -379
- package/es/components/SlugList.d.ts +0 -7
- package/es/components/SlugList.js +0 -38
- package/es/components/SlugList.less +0 -18
- package/es/declaration.d.ts +0 -1
- package/es/layout.d.ts +0 -5
- package/es/layout.js +0 -276
- package/es/style/layout.less +0 -402
- package/es/style/markdown.less +0 -240
- package/es/style/variables.less +0 -37
- package/src/antv/404/index.tsx +0 -25
- package/src/antv/Banner/Notification.tsx +0 -45
- package/src/antv/Banner/index.tsx +0 -139
- package/src/antv/Cases/Cases.tsx +0 -116
- package/src/antv/Features/FeatureCard.tsx +0 -24
- package/src/antv/Features/index.tsx +0 -86
- package/src/antv/Footer/Footer.module.less +0 -36
- package/src/antv/Footer/index.tsx +0 -272
- package/src/antv/Header/Logo.tsx +0 -85
- package/src/antv/Products/Product.tsx +0 -80
- package/src/antv/Products/getNewProducts.tsx +0 -53
- package/src/antv/Products/getProducts.tsx +0 -626
- package/src/antv/Products/index.tsx +0 -70
- package/src/antv/hooks.ts +0 -87
- package/src/antv/mixins.less +0 -21
- package/src/antv/utils.ts +0 -44
- package/src/builtins/API.tsx +0 -57
- package/src/builtins/Alert.less +0 -62
- package/src/builtins/Alert.tsx +0 -4
- package/src/builtins/Badge.less +0 -31
- package/src/builtins/Badge.tsx +0 -4
- package/src/builtins/Example.less +0 -47
- package/src/builtins/Example.tsx +0 -34
- package/src/builtins/Previewer.less +0 -406
- package/src/builtins/Previewer.tsx +0 -264
- package/src/builtins/SourceCode.less +0 -103
- package/src/builtins/SourceCode.tsx +0 -55
- package/src/builtins/Table.less +0 -43
- package/src/builtins/Table.tsx +0 -42
- package/src/builtins/Tree.less +0 -159
- package/src/builtins/Tree.tsx +0 -130
- package/src/components/Dark.less +0 -121
- package/src/components/Dark.tsx +0 -78
- package/src/components/LocaleSelect.less +0 -59
- package/src/components/LocaleSelect.tsx +0 -53
- package/src/components/Navbar.less +0 -180
- package/src/components/Navbar.tsx +0 -152
- package/src/components/SearchBar.less +0 -165
- package/src/components/SearchBar.tsx +0 -68
- package/src/components/SideMenu.less +0 -379
- package/src/components/SideMenu.tsx +0 -148
- package/src/components/SlugList.less +0 -18
- package/src/components/SlugList.tsx +0 -20
- package/src/declaration.d.ts +0 -1
- package/src/layout.tsx +0 -225
- package/src/style/layout.less +0 -402
- package/src/style/markdown.less +0 -240
- package/src/style/variables.less +0 -37
- package/src/test/SearchBar.test.ts +0 -32
- package/src/test/Table.test.tsx +0 -41
- package/src/test/index.test.tsx +0 -377
package/src/test/index.test.tsx
DELETED
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
import '@testing-library/jest-dom';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { render, queryByAttribute, queryAllByAttribute, fireEvent } from '@testing-library/react';
|
|
4
|
-
import type { MemoryHistory} from '@umijs/runtime';
|
|
5
|
-
import { createMemoryHistory, Router } from '@umijs/runtime';
|
|
6
|
-
import { context as Context } from 'dumi/theme';
|
|
7
|
-
import SourceCode from '../builtins/SourceCode';
|
|
8
|
-
import Alert from '../builtins/Alert';
|
|
9
|
-
import Badge from '../builtins/Badge';
|
|
10
|
-
import Tree from '../builtins/Tree';
|
|
11
|
-
import Previewer from '../builtins/Previewer';
|
|
12
|
-
import API from '../builtins/API';
|
|
13
|
-
import Layout from '../layout';
|
|
14
|
-
|
|
15
|
-
let history: MemoryHistory;
|
|
16
|
-
|
|
17
|
-
// mock history location which import from 'dumi'
|
|
18
|
-
jest.mock('dumi', () => ({
|
|
19
|
-
history: { location: { pathname: '/' } },
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
describe('default theme', () => {
|
|
23
|
-
history = createMemoryHistory({ initialEntries: ['/', '/en-US'], initialIndex: 0 });
|
|
24
|
-
const baseCtx = {
|
|
25
|
-
title: 'test',
|
|
26
|
-
locale: 'zh-CN',
|
|
27
|
-
routes: [
|
|
28
|
-
{
|
|
29
|
-
path: '/',
|
|
30
|
-
title: '首页',
|
|
31
|
-
meta: {},
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
path: '/en-US',
|
|
35
|
-
title: 'Home',
|
|
36
|
-
meta: {},
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
config: {
|
|
40
|
-
locales: [
|
|
41
|
-
{ name: 'zh-CN', label: '中文' },
|
|
42
|
-
{ name: 'en-US', label: 'English' },
|
|
43
|
-
],
|
|
44
|
-
menus: {},
|
|
45
|
-
navs: {},
|
|
46
|
-
title: 'test',
|
|
47
|
-
logo: '/',
|
|
48
|
-
mode: 'site' as 'doc' | 'site',
|
|
49
|
-
repository: { branch: 'master' },
|
|
50
|
-
},
|
|
51
|
-
meta: {},
|
|
52
|
-
menu: [
|
|
53
|
-
{
|
|
54
|
-
title: '分组',
|
|
55
|
-
children: [
|
|
56
|
-
{
|
|
57
|
-
title: 'English',
|
|
58
|
-
path: '/en',
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
nav: [
|
|
64
|
-
{
|
|
65
|
-
path: '/',
|
|
66
|
-
title: '首页',
|
|
67
|
-
children: [],
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
title: '生态',
|
|
71
|
-
children: [
|
|
72
|
-
{
|
|
73
|
-
path: 'https://d.umijs.org',
|
|
74
|
-
title: 'GitHub',
|
|
75
|
-
children: [],
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
base: '/',
|
|
81
|
-
apis: {
|
|
82
|
-
MultipleExports: {
|
|
83
|
-
Other: [
|
|
84
|
-
{
|
|
85
|
-
identifier: 'other',
|
|
86
|
-
type: 'string',
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
},
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
const baseProps = {
|
|
93
|
-
history,
|
|
94
|
-
location: { ...history.location, query: {} },
|
|
95
|
-
match: { params: {}, isExact: true, path: '/', url: '/' },
|
|
96
|
-
route: { path: '/', routes: baseCtx.routes },
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
it('should render site home page', () => {
|
|
100
|
-
const attrName = 'data-prefers-color';
|
|
101
|
-
document.documentElement.setAttribute(attrName, 'light');
|
|
102
|
-
localStorage.setItem('dumi:prefers-color', 'light');
|
|
103
|
-
const wrapper = ({ children }) => (
|
|
104
|
-
<Context.Provider
|
|
105
|
-
value={{
|
|
106
|
-
...baseCtx,
|
|
107
|
-
meta: {
|
|
108
|
-
title: 'test',
|
|
109
|
-
hero: {
|
|
110
|
-
title: 'Hero',
|
|
111
|
-
desc: 'Hero Description',
|
|
112
|
-
actions: [{ text: '开始', link: '/' }],
|
|
113
|
-
},
|
|
114
|
-
features: [
|
|
115
|
-
{ title: 'Feat', desc: 'Feature' },
|
|
116
|
-
{ title: 'Feat2', link: '/' },
|
|
117
|
-
],
|
|
118
|
-
},
|
|
119
|
-
}}
|
|
120
|
-
>
|
|
121
|
-
{children}
|
|
122
|
-
</Context.Provider>
|
|
123
|
-
);
|
|
124
|
-
const { container, getAllByText, getByText } = render(
|
|
125
|
-
<Router history={history}>
|
|
126
|
-
<Layout {...baseProps}>
|
|
127
|
-
<h1>Home Page</h1>
|
|
128
|
-
</Layout>
|
|
129
|
-
</Router>,
|
|
130
|
-
{ wrapper },
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
// expect navbar be rendered
|
|
134
|
-
expect(getAllByText('首页')).not.toBeNull();
|
|
135
|
-
|
|
136
|
-
// expect content be rendered
|
|
137
|
-
expect(getByText('Home Page')).not.toBeNull();
|
|
138
|
-
|
|
139
|
-
// expect hero be rendered
|
|
140
|
-
expect(getByText('Hero')).not.toBeNull();
|
|
141
|
-
|
|
142
|
-
// expect features be rendered
|
|
143
|
-
expect(getByText('Feature')).not.toBeNull();
|
|
144
|
-
expect(getByText('Feat2')).not.toBeNull();
|
|
145
|
-
|
|
146
|
-
// trigger mobile menu display
|
|
147
|
-
queryByAttribute('class', container, '__dumi-default-navbar-toggle').click();
|
|
148
|
-
|
|
149
|
-
// expect sidemenu display for mobile
|
|
150
|
-
expect(queryByAttribute('data-mobile-show', container, 'true')).not.toBeNull();
|
|
151
|
-
|
|
152
|
-
// expect dark render and click success
|
|
153
|
-
const menu = queryByAttribute('class', container, '__dumi-default-menu');
|
|
154
|
-
const sunMenu = queryByAttribute('class', menu, '__dumi-default-dark-sun __dumi-default-dark-switch-active');
|
|
155
|
-
expect(sunMenu).not.toBeNull();
|
|
156
|
-
const moonMenu = queryByAttribute('class', container, '__dumi-default-dark-moon');
|
|
157
|
-
expect(moonMenu).not.toBeNull();
|
|
158
|
-
moonMenu.click();
|
|
159
|
-
expect(document.documentElement.getAttribute(attrName)).toEqual('dark');
|
|
160
|
-
expect(queryByAttribute('data-mobile-show', container, 'true')).toBeNull();
|
|
161
|
-
|
|
162
|
-
const navbar = queryByAttribute('class', container, '__dumi-default-navbar');
|
|
163
|
-
const moonNav = queryByAttribute('class', navbar, '__dumi-default-dark-moon __dumi-default-dark-switch-active');
|
|
164
|
-
moonNav.click();
|
|
165
|
-
expect(queryByAttribute('class', navbar, '__dumi-default-dark-switch __dumi-default-dark-switch-open')).not.toBeNull();
|
|
166
|
-
const switchList = queryByAttribute('class', navbar, '__dumi-default-dark-switch-list');
|
|
167
|
-
expect(switchList).not.toBeNull();
|
|
168
|
-
queryByAttribute('class', switchList, '__dumi-default-dark-sun').click();
|
|
169
|
-
expect(document.documentElement.getAttribute(attrName)).toEqual('light');
|
|
170
|
-
expect(queryByAttribute('class', navbar, '__dumi-default-dark-switch-list')).toBeNull();
|
|
171
|
-
expect(queryByAttribute('class', navbar, '__dumi-default-dark-switch __dumi-default-dark-switch-open')).toBeNull();
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it('should render documentation page', async () => {
|
|
175
|
-
const updatedTime = 1604026996000;
|
|
176
|
-
const wrapper = ({ children }) => (
|
|
177
|
-
<Context.Provider
|
|
178
|
-
value={{
|
|
179
|
-
...baseCtx,
|
|
180
|
-
meta: {
|
|
181
|
-
title: 'test',
|
|
182
|
-
slugs: [{ value: 'Slug A', heading: 'a', depth: 2 }],
|
|
183
|
-
updatedTime,
|
|
184
|
-
filePath: 'temp',
|
|
185
|
-
},
|
|
186
|
-
}}
|
|
187
|
-
>
|
|
188
|
-
{children}
|
|
189
|
-
</Context.Provider>
|
|
190
|
-
);
|
|
191
|
-
const { getByText, getAllByText } = render(
|
|
192
|
-
<Router history={history}>
|
|
193
|
-
<Layout {...baseProps}>
|
|
194
|
-
<h1>Doc</h1>
|
|
195
|
-
</Layout>
|
|
196
|
-
</Router>,
|
|
197
|
-
{ wrapper },
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
// expect slugs be rendered
|
|
201
|
-
expect(getByText('Slug A')).not.toBeNull();
|
|
202
|
-
|
|
203
|
-
// expect footer date show
|
|
204
|
-
expect(new Date(updatedTime).toLocaleString([], { hour12: false })).not.toBeNull();
|
|
205
|
-
|
|
206
|
-
// trigger locale change
|
|
207
|
-
getAllByText('English')[0].click();
|
|
208
|
-
|
|
209
|
-
// expect location change
|
|
210
|
-
expect(history.location.pathname).toEqual(baseCtx.routes[1].path);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('should render builtin components correctly', () => {
|
|
214
|
-
const code = "console.log('Hello World!')";
|
|
215
|
-
const wrapper = ({ children }) => (
|
|
216
|
-
<Context.Provider
|
|
217
|
-
value={{
|
|
218
|
-
...baseCtx,
|
|
219
|
-
meta: {
|
|
220
|
-
title: 'test',
|
|
221
|
-
slugs: [{ value: 'Slug A', heading: 'a', depth: 2 }],
|
|
222
|
-
},
|
|
223
|
-
}}
|
|
224
|
-
>
|
|
225
|
-
{children}
|
|
226
|
-
</Context.Provider>
|
|
227
|
-
);
|
|
228
|
-
|
|
229
|
-
const { getByText, getByTitle, getAllByTitle, container } = render(
|
|
230
|
-
<Router history={history}>
|
|
231
|
-
<Layout {...baseProps}>
|
|
232
|
-
<>
|
|
233
|
-
<a href="" id="btn">
|
|
234
|
-
click
|
|
235
|
-
</a>
|
|
236
|
-
<SourceCode code={code} lang="javascript" />
|
|
237
|
-
<Alert type="info">Alert</Alert>
|
|
238
|
-
<Badge type="info">Badge</Badge>
|
|
239
|
-
<Tree>
|
|
240
|
-
<ul>
|
|
241
|
-
<li>
|
|
242
|
-
1
|
|
243
|
-
<small>test1</small>
|
|
244
|
-
<ul>
|
|
245
|
-
<li>
|
|
246
|
-
1-1
|
|
247
|
-
<small>test1-1</small>
|
|
248
|
-
</li>
|
|
249
|
-
</ul>
|
|
250
|
-
</li>
|
|
251
|
-
</ul>
|
|
252
|
-
</Tree>
|
|
253
|
-
<Previewer
|
|
254
|
-
title="demo-1"
|
|
255
|
-
identifier="demo-1"
|
|
256
|
-
sources={{
|
|
257
|
-
_: {
|
|
258
|
-
jsx: "export default () => 'JavaScript'",
|
|
259
|
-
tsx: "export default () => 'TypeScript'",
|
|
260
|
-
},
|
|
261
|
-
}}
|
|
262
|
-
dependencies={{}}
|
|
263
|
-
>
|
|
264
|
-
<>demo-1 Content</>
|
|
265
|
-
</Previewer>
|
|
266
|
-
<Previewer
|
|
267
|
-
title="demo-2"
|
|
268
|
-
identifier="demo-2"
|
|
269
|
-
sources={{
|
|
270
|
-
_: {
|
|
271
|
-
jsx: "export default () => 'Main'",
|
|
272
|
-
},
|
|
273
|
-
'Other.jsx': {
|
|
274
|
-
import: './Other.jsx',
|
|
275
|
-
content: "export default () => 'Other'",
|
|
276
|
-
},
|
|
277
|
-
}}
|
|
278
|
-
dependencies={{}}
|
|
279
|
-
>
|
|
280
|
-
<>demo-2 Content</>
|
|
281
|
-
</Previewer>
|
|
282
|
-
<Previewer
|
|
283
|
-
title="demo-3"
|
|
284
|
-
identifier="demo-3"
|
|
285
|
-
sources={{
|
|
286
|
-
_: {
|
|
287
|
-
jsx: "export default () => 'Main'",
|
|
288
|
-
},
|
|
289
|
-
'Other.jsx': {
|
|
290
|
-
import: './Other.jsx',
|
|
291
|
-
content: "export default () => 'Other'",
|
|
292
|
-
},
|
|
293
|
-
}}
|
|
294
|
-
dependencies={{}}
|
|
295
|
-
iframe={100}
|
|
296
|
-
>
|
|
297
|
-
<>demo-3 Content</>
|
|
298
|
-
</Previewer>
|
|
299
|
-
<API identifier="MultipleExports" export="Other" />
|
|
300
|
-
</>
|
|
301
|
-
</Layout>
|
|
302
|
-
</Router>,
|
|
303
|
-
{ wrapper },
|
|
304
|
-
);
|
|
305
|
-
|
|
306
|
-
// toggle side menu display
|
|
307
|
-
fireEvent(
|
|
308
|
-
container.querySelector('.__dumi-default-navbar-toggle'),
|
|
309
|
-
new MouseEvent('click', {
|
|
310
|
-
bubbles: true,
|
|
311
|
-
cancelable: true,
|
|
312
|
-
}),
|
|
313
|
-
);
|
|
314
|
-
|
|
315
|
-
fireEvent(
|
|
316
|
-
container.querySelector('#btn'),
|
|
317
|
-
new MouseEvent('click', {
|
|
318
|
-
bubbles: true,
|
|
319
|
-
cancelable: true,
|
|
320
|
-
}),
|
|
321
|
-
);
|
|
322
|
-
|
|
323
|
-
// test tree render
|
|
324
|
-
expect(queryAllByAttribute('class', container, '__dumi-site-tree-icon icon-minus-square').length).toBe(2);
|
|
325
|
-
expect(queryAllByAttribute('class', container, '__dumi-site-tree-icon icon-folder-open').length).toBe(2);
|
|
326
|
-
expect(queryAllByAttribute('class', container, '__dumi-site-tree-icon icon-file').length).toBe(1);
|
|
327
|
-
|
|
328
|
-
expect(getByText('<root>')).toHaveClass('rc-tree-title');
|
|
329
|
-
expect(getByText('1')).toHaveClass('rc-tree-title');
|
|
330
|
-
expect(getByText('test1')).not.toBeNull();
|
|
331
|
-
|
|
332
|
-
getAllByTitle('<root>')[0].click();
|
|
333
|
-
expect(queryAllByAttribute('class', container, '__dumi-site-tree-icon icon-plus-square').length).toBe(1);
|
|
334
|
-
expect(queryAllByAttribute('class', container, '__dumi-site-tree-icon icon-folder').length).toBe(1);
|
|
335
|
-
|
|
336
|
-
// expect SourceCode highlight
|
|
337
|
-
expect(getByText('console')).toHaveClass('token');
|
|
338
|
-
|
|
339
|
-
// expect Alert be rendered
|
|
340
|
-
expect(getByText('Alert')).toHaveAttribute('type', 'info');
|
|
341
|
-
|
|
342
|
-
// expect Badge be rendered
|
|
343
|
-
expect(getByText('Badge')).toHaveClass('__dumi-default-badge');
|
|
344
|
-
|
|
345
|
-
// expect Previewer be rendered
|
|
346
|
-
expect(getByText('demo-1')).not.toBeNull();
|
|
347
|
-
|
|
348
|
-
// trigger source code display for demo-1
|
|
349
|
-
getAllByTitle('Toggle source code panel')[0].click();
|
|
350
|
-
|
|
351
|
-
// expect show TypeScript code default
|
|
352
|
-
expect(getByText("'TypeScript'")).not.toBeNull();
|
|
353
|
-
|
|
354
|
-
// trigger source code display for demo-2
|
|
355
|
-
getAllByTitle('Toggle source code panel')[1].click();
|
|
356
|
-
|
|
357
|
-
// expect show code of main file
|
|
358
|
-
expect(getByText("'Main'")).not.toBeNull();
|
|
359
|
-
|
|
360
|
-
// trigger file change
|
|
361
|
-
getByText('Other.jsx').click();
|
|
362
|
-
|
|
363
|
-
// expect show code of main file
|
|
364
|
-
expect(getByText("'Other'")).not.toBeNull();
|
|
365
|
-
|
|
366
|
-
// expect render iframe demo
|
|
367
|
-
(container.querySelector('[data-iframe] button[role=refresh]') as HTMLElement).click();
|
|
368
|
-
expect(container.querySelector('[data-iframe]').innerHTML).not.toContain('demo-3 Content');
|
|
369
|
-
expect(container.querySelector('[data-iframe] iframe')).not.toBeNull();
|
|
370
|
-
expect((container.querySelector('[data-iframe] iframe') as HTMLElement).style.height).toEqual(
|
|
371
|
-
'100px',
|
|
372
|
-
);
|
|
373
|
-
|
|
374
|
-
// expect render API property
|
|
375
|
-
expect(getByText('other', { selector: 'table td' })).not.toBeNull();
|
|
376
|
-
});
|
|
377
|
-
});
|