-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathCustomNodeFactory.test.js
More file actions
28 lines (26 loc) · 1021 Bytes
/
CustomNodeFactory.test.js
File metadata and controls
28 lines (26 loc) · 1021 Bytes
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
import React from 'react'
import { render } from '@testing-library/react'
import CustomNodeFactory from '../../../src/components/CustomNode/CustomNodeFactory';
import CustomNodeModel from '../../../src/components/CustomNode/CustomNodeModel';
import CustomNodeWidget from '../../../src/components/CustomNode/CustomNodeWidget';
describe('Validate CustomNodeFactory', () => {
it('CustomNodeFactory generates CustomNodeWidget', () => {
const customNodeFactory = new CustomNodeFactory();
const node = new CustomNodeModel({id: "myId"});
const model = {
node: node,
};
const event = {
model: model,
initialConfig: {
options: { id: "modelId"},
config: {}
}
};
const widget = customNodeFactory.generateReactWidget(event);
expect(React.isValidElement(widget)).toBe(true);
const nodeModel = customNodeFactory.generateModel(event);
expect(nodeModel instanceof CustomNodeModel).toBe(true);
expect(nodeModel.getNodeId()).toBe("modelId");
});
})