Skip to content

Commit 4c557ff

Browse files
committed
Fix: test code location
1 parent 55d217a commit 4c557ff

File tree

11 files changed

+261
-6
lines changed

11 files changed

+261
-6
lines changed

__tests__/WeEditor.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ describe('component: WeEditor', () => {
88
expect(result).toMatchSnapshot();
99
});
1010

11-
test('called getHTMLString has string value', () => {
11+
test('called getHTML is string value', () => {
1212
const ref = React.createRef<WeEditorRef>();
1313
render(<WeEditor ref={ref} />);
14-
expect(ref.current?.getHTMLState()).toBe('');
14+
expect(typeof ref.current?.getHTML()).toBe('string');
15+
});
16+
17+
test('called getMarkdown is string value', () => {
18+
const ref = React.createRef<WeEditorRef>();
19+
render(<WeEditor ref={ref} />);
20+
expect(typeof ref.current?.getMarkdown()).toBe('string');
1521
});
1622
});

__tests__/WeToolbar.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as React from 'react';
2+
import { render } from '@testing-library/react';
3+
import { WeToolbar } from '../src';
4+
5+
describe('component: WeToolbar', () => {
6+
test('WeToolbar render', () => {
7+
const ref = React.createRef<HTMLDivElement>();
8+
const result = render(<WeToolbar editorRef={ref} />);
9+
expect(result).toMatchSnapshot();
10+
});
11+
});

__tests__/__snapshots__/WeEditor.tsx.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ Object {
1010
id="we_editor_id"
1111
/>
1212
<div
13-
class="css-8i3df"
13+
class="css-17b6vo2"
1414
>
1515
<div
16-
class="css-o4ynn6"
16+
class="css-1ptt82a"
1717
>
1818
<button
1919
class="css-11mb858"
@@ -96,10 +96,10 @@ Object {
9696
id="we_editor_id"
9797
/>
9898
<div
99-
class="css-8i3df"
99+
class="css-17b6vo2"
100100
>
101101
<div
102-
class="css-o4ynn6"
102+
class="css-1ptt82a"
103103
>
104104
<button
105105
class="css-11mb858"
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`component: WeToolbar WeToolbar render 1`] = `
4+
Object {
5+
"asFragment": [Function],
6+
"baseElement": <body>
7+
<div>
8+
<div
9+
class="css-17b6vo2"
10+
>
11+
<div
12+
class="css-1ptt82a"
13+
>
14+
<button
15+
class="css-11mb858"
16+
>
17+
<svg
18+
fill="currentColor"
19+
height="20"
20+
stroke="currentColor"
21+
stroke-width="0"
22+
viewBox="0 0 24 24"
23+
width="20"
24+
xmlns="http://www.w3.org/2000/svg"
25+
>
26+
<path
27+
d="M17.061 11.22A4.46 4.46 0 0 0 18 8.5C18 6.019 15.981 4 13.5 4H6v15h8c2.481 0 4.5-2.019 4.5-4.5a4.48 4.48 0 0 0-1.439-3.28zM13.5 7c.827 0 1.5.673 1.5 1.5s-.673 1.5-1.5 1.5H9V7h4.5zm.5 9H9v-3h5c.827 0 1.5.673 1.5 1.5S14.827 16 14 16z"
28+
/>
29+
</svg>
30+
</button>
31+
<button
32+
class="css-11mb858"
33+
>
34+
<svg
35+
fill="currentColor"
36+
height="20"
37+
stroke="currentColor"
38+
stroke-width="0"
39+
viewBox="0 0 24 24"
40+
width="20"
41+
xmlns="http://www.w3.org/2000/svg"
42+
>
43+
<path
44+
d="M5 18h14v2H5zM6 4v6c0 3.309 2.691 6 6 6s6-2.691 6-6V4h-2v6c0 2.206-1.794 4-4 4s-4-1.794-4-4V4H6z"
45+
/>
46+
</svg>
47+
</button>
48+
<button
49+
class="css-11mb858"
50+
>
51+
<svg
52+
fill="currentColor"
53+
height="20"
54+
stroke="currentColor"
55+
stroke-width="0"
56+
viewBox="0 0 24 24"
57+
width="20"
58+
xmlns="http://www.w3.org/2000/svg"
59+
>
60+
<path
61+
d="M19 7V4H9v3h2.868L9.012 17H5v3h10v-3h-2.868l2.856-10z"
62+
/>
63+
</svg>
64+
</button>
65+
<button
66+
class="css-11mb858"
67+
>
68+
<svg
69+
fill="currentColor"
70+
height="20"
71+
stroke="currentColor"
72+
stroke-width="0"
73+
viewBox="0 0 24 24"
74+
width="20"
75+
xmlns="http://www.w3.org/2000/svg"
76+
>
77+
<path
78+
d="M8.465 11.293c1.133-1.133 3.109-1.133 4.242 0l.707.707 1.414-1.414-.707-.707c-.943-.944-2.199-1.465-3.535-1.465s-2.592.521-3.535 1.465L4.929 12a5.008 5.008 0 0 0 0 7.071 4.983 4.983 0 0 0 3.535 1.462A4.982 4.982 0 0 0 12 19.071l.707-.707-1.414-1.414-.707.707a3.007 3.007 0 0 1-4.243 0 3.005 3.005 0 0 1 0-4.243l2.122-2.121z"
79+
/>
80+
<path
81+
d="m12 4.929-.707.707 1.414 1.414.707-.707a3.007 3.007 0 0 1 4.243 0 3.005 3.005 0 0 1 0 4.243l-2.122 2.121c-1.133 1.133-3.109 1.133-4.242 0L10.586 12l-1.414 1.414.707.707c.943.944 2.199 1.465 3.535 1.465s2.592-.521 3.535-1.465L19.071 12a5.008 5.008 0 0 0 0-7.071 5.006 5.006 0 0 0-7.071 0z"
82+
/>
83+
</svg>
84+
</button>
85+
</div>
86+
</div>
87+
</div>
88+
</body>,
89+
"container": <div>
90+
<div
91+
class="css-17b6vo2"
92+
>
93+
<div
94+
class="css-1ptt82a"
95+
>
96+
<button
97+
class="css-11mb858"
98+
>
99+
<svg
100+
fill="currentColor"
101+
height="20"
102+
stroke="currentColor"
103+
stroke-width="0"
104+
viewBox="0 0 24 24"
105+
width="20"
106+
xmlns="http://www.w3.org/2000/svg"
107+
>
108+
<path
109+
d="M17.061 11.22A4.46 4.46 0 0 0 18 8.5C18 6.019 15.981 4 13.5 4H6v15h8c2.481 0 4.5-2.019 4.5-4.5a4.48 4.48 0 0 0-1.439-3.28zM13.5 7c.827 0 1.5.673 1.5 1.5s-.673 1.5-1.5 1.5H9V7h4.5zm.5 9H9v-3h5c.827 0 1.5.673 1.5 1.5S14.827 16 14 16z"
110+
/>
111+
</svg>
112+
</button>
113+
<button
114+
class="css-11mb858"
115+
>
116+
<svg
117+
fill="currentColor"
118+
height="20"
119+
stroke="currentColor"
120+
stroke-width="0"
121+
viewBox="0 0 24 24"
122+
width="20"
123+
xmlns="http://www.w3.org/2000/svg"
124+
>
125+
<path
126+
d="M5 18h14v2H5zM6 4v6c0 3.309 2.691 6 6 6s6-2.691 6-6V4h-2v6c0 2.206-1.794 4-4 4s-4-1.794-4-4V4H6z"
127+
/>
128+
</svg>
129+
</button>
130+
<button
131+
class="css-11mb858"
132+
>
133+
<svg
134+
fill="currentColor"
135+
height="20"
136+
stroke="currentColor"
137+
stroke-width="0"
138+
viewBox="0 0 24 24"
139+
width="20"
140+
xmlns="http://www.w3.org/2000/svg"
141+
>
142+
<path
143+
d="M19 7V4H9v3h2.868L9.012 17H5v3h10v-3h-2.868l2.856-10z"
144+
/>
145+
</svg>
146+
</button>
147+
<button
148+
class="css-11mb858"
149+
>
150+
<svg
151+
fill="currentColor"
152+
height="20"
153+
stroke="currentColor"
154+
stroke-width="0"
155+
viewBox="0 0 24 24"
156+
width="20"
157+
xmlns="http://www.w3.org/2000/svg"
158+
>
159+
<path
160+
d="M8.465 11.293c1.133-1.133 3.109-1.133 4.242 0l.707.707 1.414-1.414-.707-.707c-.943-.944-2.199-1.465-3.535-1.465s-2.592.521-3.535 1.465L4.929 12a5.008 5.008 0 0 0 0 7.071 4.983 4.983 0 0 0 3.535 1.462A4.982 4.982 0 0 0 12 19.071l.707-.707-1.414-1.414-.707.707a3.007 3.007 0 0 1-4.243 0 3.005 3.005 0 0 1 0-4.243l2.122-2.121z"
161+
/>
162+
<path
163+
d="m12 4.929-.707.707 1.414 1.414.707-.707a3.007 3.007 0 0 1 4.243 0 3.005 3.005 0 0 1 0 4.243l-2.122 2.121c-1.133 1.133-3.109 1.133-4.242 0L10.586 12l-1.414 1.414.707.707c.943.944 2.199 1.465 3.535 1.465s2.592-.521 3.535-1.465L19.071 12a5.008 5.008 0 0 0 0-7.071 5.006 5.006 0 0 0-7.071 0z"
164+
/>
165+
</svg>
166+
</button>
167+
</div>
168+
</div>
169+
</div>,
170+
"debug": [Function],
171+
"findAllByAltText": [Function],
172+
"findAllByDisplayValue": [Function],
173+
"findAllByLabelText": [Function],
174+
"findAllByPlaceholderText": [Function],
175+
"findAllByRole": [Function],
176+
"findAllByTestId": [Function],
177+
"findAllByText": [Function],
178+
"findAllByTitle": [Function],
179+
"findByAltText": [Function],
180+
"findByDisplayValue": [Function],
181+
"findByLabelText": [Function],
182+
"findByPlaceholderText": [Function],
183+
"findByRole": [Function],
184+
"findByTestId": [Function],
185+
"findByText": [Function],
186+
"findByTitle": [Function],
187+
"getAllByAltText": [Function],
188+
"getAllByDisplayValue": [Function],
189+
"getAllByLabelText": [Function],
190+
"getAllByPlaceholderText": [Function],
191+
"getAllByRole": [Function],
192+
"getAllByTestId": [Function],
193+
"getAllByText": [Function],
194+
"getAllByTitle": [Function],
195+
"getByAltText": [Function],
196+
"getByDisplayValue": [Function],
197+
"getByLabelText": [Function],
198+
"getByPlaceholderText": [Function],
199+
"getByRole": [Function],
200+
"getByTestId": [Function],
201+
"getByText": [Function],
202+
"getByTitle": [Function],
203+
"queryAllByAltText": [Function],
204+
"queryAllByDisplayValue": [Function],
205+
"queryAllByLabelText": [Function],
206+
"queryAllByPlaceholderText": [Function],
207+
"queryAllByRole": [Function],
208+
"queryAllByTestId": [Function],
209+
"queryAllByText": [Function],
210+
"queryAllByTitle": [Function],
211+
"queryByAltText": [Function],
212+
"queryByDisplayValue": [Function],
213+
"queryByLabelText": [Function],
214+
"queryByPlaceholderText": [Function],
215+
"queryByRole": [Function],
216+
"queryByTestId": [Function],
217+
"queryByText": [Function],
218+
"queryByTitle": [Function],
219+
"rerender": [Function],
220+
"unmount": [Function],
221+
}
222+
`;
File renamed without changes.

__tests__/library/marked.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { marked } from 'marked';
2+
3+
describe('library: markded', () => {
4+
test('called marked.parse is html string', () => {
5+
const head1 = marked.parse('# abc');
6+
expect(head1).toBe('<h1 id="abc">abc</h1>\n');
7+
});
8+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { NodeHtmlMarkdown } from 'node-html-markdown';
2+
3+
describe('library: node-html-markdown', () => {
4+
test('called NodeHtmlMarkdown.translate is html string', () => {
5+
const head1 = NodeHtmlMarkdown.translate('<h1 id="abc">abc</h1>\n');
6+
expect(head1).toBe('# abc');
7+
});
8+
});
File renamed without changes.

0 commit comments

Comments
 (0)