mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-05 05:18:34 +08:00
46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
|
import {
|
||
|
registerRenderer,
|
||
|
unRegisterRenderer,
|
||
|
RendererProps,
|
||
|
render as amisRender
|
||
|
} from '../src/factory';
|
||
|
import React = require('react');
|
||
|
import {render, fireEvent, cleanup} from 'react-testing-library';
|
||
|
|
||
|
test('factory unregistered Renderer', () => {
|
||
|
const {
|
||
|
container,
|
||
|
} = render(amisRender({
|
||
|
type: 'my-renderer',
|
||
|
a: 23
|
||
|
}));
|
||
|
|
||
|
expect(container).toMatchSnapshot(); // not found
|
||
|
});
|
||
|
|
||
|
test('factory:registerRenderer', () => {
|
||
|
interface MyProps extends RendererProps {
|
||
|
a: number;
|
||
|
};
|
||
|
|
||
|
class MyComponent extends React.Component<MyProps> {
|
||
|
render() {
|
||
|
return (<div>This is Custom Renderer, a is {this.props.a}</div>);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const renderer = registerRenderer({
|
||
|
component: MyComponent,
|
||
|
test: /\bmy-renderer$/
|
||
|
});
|
||
|
|
||
|
const {
|
||
|
container
|
||
|
} = render(amisRender({
|
||
|
type: 'my-renderer',
|
||
|
a: 23
|
||
|
}))
|
||
|
|
||
|
expect(container).toMatchSnapshot();
|
||
|
unRegisterRenderer(renderer);
|
||
|
});
|