Skip to content

Commit 24fdc1f

Browse files
🚨 Add test for TSX
1 parent e9911ca commit 24fdc1f

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

test/HTMLCodeBlockElement.test.tsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import * as React from 'react';
2+
import '../types/global';
3+
import renderer from 'react-test-renderer';
4+
5+
describe('React', () => {
6+
test('Simple', () => {
7+
const component = renderer.create(
8+
<code-block/>,
9+
);
10+
const tree = component.toJSON();
11+
12+
expect(tree).toMatchSnapshot();
13+
});
14+
15+
test('JSON', () => {
16+
const component = renderer.create(
17+
<code-block language="json">{
18+
`{
19+
"hoge": 100
20+
}`}
21+
</code-block>,
22+
);
23+
const tree = component.toJSON();
24+
25+
expect(tree).toMatchSnapshot();
26+
});
27+
28+
test('All', () => {
29+
const component = renderer.create(
30+
<code-block
31+
label="hoge"
32+
language="js"
33+
controls
34+
>
35+
<textarea><script>
36+
const hoge = 100;
37+
38+
console.log(100);
39+
</script></textarea>
40+
</code-block>,
41+
);
42+
const tree = component.toJSON();
43+
44+
expect(tree).toMatchSnapshot();
45+
});
46+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`React All 1`] = `
4+
<code-block
5+
controls={true}
6+
label="hoge"
7+
language="js"
8+
>
9+
<textarea>
10+
<script>
11+
const hoge = 100; console.log(100);
12+
</script>
13+
</textarea>
14+
</code-block>
15+
`;
16+
17+
exports[`React JSON 1`] = `
18+
<code-block
19+
language="json"
20+
>
21+
{
22+
"hoge": 100
23+
}
24+
</code-block>
25+
`;
26+
27+
exports[`React Simple 1`] = `<code-block />`;

0 commit comments

Comments
 (0)