Skip to content

Commit dedc968

Browse files
committed
test: add test case.
1 parent 02e1d3f commit dedc968

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/__test__/index.test.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,33 @@ it('Should output a RunWeb', async () => {
1414
expect(tree.props.srcDoc).toEqual('<!DOCTYPE html><html><head></head><body></body></html>');
1515
}
1616
});
17+
18+
it('RunWeb Props js="..."', async () => {
19+
const component = TestRenderer.create(<RunWeb js="console.log('hello world!')" />);
20+
let tree = component.toJSON();
21+
if (tree && !Array.isArray(tree)) {
22+
expect(tree.type).toEqual('iframe');
23+
expect(tree.props.title).toEqual('Demo Title');
24+
expect(tree.props.width).toEqual('100%');
25+
expect(tree.props.height).toEqual('100%');
26+
expect(tree.props.style).toEqual({ border: 0 });
27+
expect(tree.props.srcDoc).toEqual(
28+
`<!DOCTYPE html><html><head></head><body><script type="text/javascript">console.log('hello world!')</script></body></html>`,
29+
);
30+
}
31+
});
32+
33+
it('RunWeb Props css="..."', async () => {
34+
const component = TestRenderer.create(<RunWeb css="body { color:red; }" />);
35+
let tree = component.toJSON();
36+
if (tree && !Array.isArray(tree)) {
37+
expect(tree.type).toEqual('iframe');
38+
expect(tree.props.title).toEqual('Demo Title');
39+
expect(tree.props.width).toEqual('100%');
40+
expect(tree.props.height).toEqual('100%');
41+
expect(tree.props.style).toEqual({ border: 0 });
42+
expect(tree.props.srcDoc).toEqual(
43+
`<!DOCTYPE html><html><head><style>body { color:red; }</style></head><body></body></html>`,
44+
);
45+
}
46+
});

0 commit comments

Comments
 (0)