Skip to content

Commit afd0f60

Browse files
committed
test: add test case.
1 parent f65c089 commit afd0f60

File tree

7 files changed

+125
-5
lines changed

7 files changed

+125
-5
lines changed

core/src/comps/ellipsis.test.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import renderer from 'react-test-renderer';
2+
import { Ellipsis } from './ellipsis';
3+
4+
it('renders <Ellipsis /> test case', () => {
5+
const component = renderer.create(
6+
<Ellipsis />,
7+
);
8+
let tree = component.toJSON();
9+
expect(tree).toHaveProperty('type');
10+
expect(tree).toHaveProperty('props');
11+
expect(tree).toHaveProperty('children', [ '...' ]);
12+
expect(tree).toHaveProperty('type', 'span');
13+
expect(tree).toHaveProperty('props', {
14+
className: 'w-rjv-ellipsis ',
15+
style: {
16+
cursor: 'pointer',
17+
}
18+
});
19+
});
20+
21+
22+
it('renders <Ellipsis /> render props test case', () => {
23+
const component = renderer.create(
24+
<Ellipsis render={(props) => <del {...props}>xxx</del>} />,
25+
);
26+
let tree = component.toJSON();
27+
expect(tree).toHaveProperty('type');
28+
expect(tree).toHaveProperty('props');
29+
expect(tree).toHaveProperty('children', [ 'xxx' ]);
30+
expect(tree).toHaveProperty('type', 'del');
31+
expect(tree).toHaveProperty('props', {
32+
className: 'w-rjv-ellipsis ',
33+
style: {
34+
cursor: 'pointer',
35+
}
36+
});
37+
});

core/src/comps/meta.test.tsx

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import renderer from 'react-test-renderer';
2+
import { Meta } from './meta';
3+
4+
it('renders <Meta /> test case', () => {
5+
const component = renderer.create(
6+
<Meta />,
7+
);
8+
let tree = component.toJSON();
9+
expect(tree).toHaveProperty('type');
10+
expect(tree).toHaveProperty('props');
11+
expect(tree).toHaveProperty('children', [ '}' ]);
12+
expect(tree).toHaveProperty('type', 'span');
13+
expect(tree).toHaveProperty('props', {
14+
style: {
15+
color: 'var(--w-rjv-curlybraces-color, #236a7c)',
16+
fontSize: undefined,
17+
opacity: undefined,
18+
paddingRight: undefined
19+
},
20+
className: 'w-rjv-curlybraces-end '
21+
});
22+
});
23+
24+
25+
it('renders <Meta /> render props test case', () => {
26+
const component = renderer.create(
27+
<Meta start render={(props) => <del {...props} />} />,
28+
);
29+
const tree = component.toJSON();
30+
expect(tree).toHaveProperty('type');
31+
expect(tree).toHaveProperty('props');
32+
expect(tree).toHaveProperty('children', [ '{' ]);
33+
expect(tree).toHaveProperty('type', 'del');
34+
expect(tree).toHaveProperty('props', {
35+
isArray: false,
36+
className: 'w-rjv-curlybraces-start ',
37+
style: { color: 'var(--w-rjv-curlybraces-color, #236a7c)' }
38+
});
39+
});
40+
41+
it('renders <Meta /> isArray props test case', () => {
42+
const component = renderer.create(
43+
<Meta isArray render={(props) => <del {...props} />} />,
44+
);
45+
const tree = component.toJSON();
46+
expect(tree).toHaveProperty('type');
47+
expect(tree).toHaveProperty('props');
48+
expect(tree).toHaveProperty('children', [ ']' ]);
49+
expect(tree).toHaveProperty('type', 'del');
50+
expect(tree).toHaveProperty('props', {
51+
isArray: true,
52+
className: 'w-rjv-brackets-end ',
53+
style: { color: 'var(--w-rjv-brackets-color, #236a7c)' }
54+
});
55+
});

core/src/copied.test.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ it('renders <Copied /> `show` test case', () => {
2222
expect(tree).toHaveProperty('props');
2323
expect(tree).toHaveProperty('children');
2424
expect(tree).toHaveProperty('type', 'svg');
25-
expect(tree).toHaveProperty('props.viewBox', '0 0 38 38');
25+
expect(tree).toHaveProperty('props.viewBox', '0 0 32 36');
2626
expect(tree).toHaveProperty('props.height', '1em');
2727
expect(tree).toHaveProperty('props.width', '1em');
2828
expect(tree).toHaveProperty('props.fill', 'var(--w-rjv-copied-color, currentColor)');
29-
expect(tree).toHaveProperty('props.style', { cursor: 'pointer', marginLeft: 5 });
29+
expect(tree).toHaveProperty('props.style', { cursor: 'pointer', marginLeft: 5, verticalAlign: 'middle' });
3030
expect(tree).toHaveProperty('props.className', 'w-rjv-copied');
3131
expect(tree).toHaveProperty('props.onClick');
3232
});
@@ -38,6 +38,7 @@ it('renders <Copied /> `show` test case', () => {
3838
cursor: 'pointer',
3939
height: '1em',
4040
width: '1em',
41+
verticalAlign: 'middle',
4142
...style,
4243
};
4344
return (
@@ -59,7 +60,7 @@ it('renders <Copied /> `show` test case', () => {
5960
expect(tree).toHaveProperty('props.height', '1em');
6061
expect(tree).toHaveProperty('props.width', '1em');
6162
expect(tree).toHaveProperty('props.fill', 'var(--w-rjv-copied-color, currentColor)');
62-
expect(tree).toHaveProperty('props.style', { cursor: 'pointer', marginLeft: 5, height: '1em', width: '1em' });
63+
expect(tree).toHaveProperty('props.style', { cursor: 'pointer', marginLeft: 5, height: '1em', width: '1em', verticalAlign: 'middle' });
6364
expect(tree).toHaveProperty('props.className', 'w-rjv-copied');
6465
expect(tree).toHaveProperty('props.onClick');
6566
});

core/src/editor/icon/edit.test.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import renderer from 'react-test-renderer';
2+
import { EditIcon } from './edit';
3+
4+
5+
it('renders <EditIcon /> test case', () => {
6+
const component = renderer.create(
7+
<EditIcon />,
8+
);
9+
let tree = component.toJSON();
10+
expect(tree).toHaveProperty('type');
11+
expect(tree).toHaveProperty('props');
12+
expect(tree).toHaveProperty('children');
13+
expect(tree).toHaveProperty('type', 'svg');
14+
expect(tree).toHaveProperty('props', {
15+
viewBox: '0 0 26 26',
16+
fill: 'var(--w-rjv-edit-color, currentColor)',
17+
style: {
18+
verticalAlign: 'middle',
19+
display: 'inline-block',
20+
cursor: 'pointer',
21+
marginLeft: 5,
22+
height: '1em',
23+
width: '1em',
24+
}
25+
});
26+
});

core/src/editor/icon/edit.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export const EditIcon = (props: EditIconProps) => {
66
const defaultStyle: CSSProperties = {
77
verticalAlign: 'middle',
88
display: 'inline-block',
9-
color: 'var(--w-rjv-edit-color, currentColor)',
109
cursor: 'pointer',
1110
marginLeft: 5,
1211
height: '1em',
@@ -15,7 +14,7 @@ export const EditIcon = (props: EditIconProps) => {
1514
return (
1615
<svg
1716
viewBox="0 0 26 26"
18-
fill="currentColor"
17+
fill="var(--w-rjv-edit-color, currentColor)"
1918
{...props}
2019
style={{ ...style, ...defaultStyle}}
2120
>

core/src/theme/dark.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ it('darkTheme test case', () => {
1919
'--w-rjv-type-bigint-color',
2020
'--w-rjv-type-boolean-color',
2121
'--w-rjv-type-date-color',
22+
'--w-rjv-type-url-color',
2223
'--w-rjv-type-null-color',
2324
'--w-rjv-type-nan-color',
2425
'--w-rjv-type-undefined-color',

core/src/theme/light.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ it('lightTheme test case', () => {
1919
'--w-rjv-type-bigint-color',
2020
'--w-rjv-type-boolean-color',
2121
'--w-rjv-type-date-color',
22+
'--w-rjv-type-url-color',
2223
'--w-rjv-type-null-color',
2324
'--w-rjv-type-nan-color',
2425
'--w-rjv-type-undefined-color',

0 commit comments

Comments
 (0)