forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcreate-content.test.tsx
More file actions
38 lines (30 loc) · 1.14 KB
/
create-content.test.tsx
File metadata and controls
38 lines (30 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React from 'react';
import { createContent } from '../../src/create-content';
const MyComponent = () => {
return <div>MyComponent</div>
}
describe('createContent', () => {
test('should return the same content if it is a valid React element', () => {
const content = <div>Hello</div>;
const result = createContent(content);
expect(result).toEqual(content);
});
test('should clone the element with props if props are provided', () => {
const content = <div></div>;
const props = { className: 'my-class' };
const result = createContent(content, props);
expect(result.props).toEqual(props);
});
test('should create an element with props if the content is a React component', () => {
const content = MyComponent;
const props = { className: 'my-class' };
const result = createContent(content, props);
expect(result.type).toEqual(content);
expect(result.props).toEqual(props);
});
test('should return the content if it is not a React element or a React component', () => {
const content = 'Hello';
const result = createContent(content);
expect(result).toEqual(content);
});
});