2018-12-21 22:18:05 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { createRenderer } from 'react-test-renderer/shallow';
|
|
|
|
|
2022-01-10 18:41:53 +03:00
|
|
|
import { JSONTree } from '../src/index';
|
2018-12-21 22:18:05 +03:00
|
|
|
import JSONNode from '../src/JSONNode';
|
|
|
|
|
|
|
|
const BASIC_DATA = { a: 1, b: 'c' };
|
|
|
|
|
2020-08-22 03:13:24 +03:00
|
|
|
function render(component: React.ReactElement) {
|
2018-12-21 22:18:05 +03:00
|
|
|
const renderer = createRenderer();
|
|
|
|
renderer.render(component);
|
|
|
|
return renderer.getRenderOutput();
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('JSONTree', () => {
|
|
|
|
it('should render basic tree', () => {
|
|
|
|
const result = render(<JSONTree data={BASIC_DATA} />);
|
|
|
|
|
|
|
|
expect(result.type).toBe('ul');
|
|
|
|
expect(result.props.children.type.name).toBe(JSONNode.name);
|
|
|
|
});
|
|
|
|
});
|