Rename and move existing sample test

This commit is contained in:
2019-07-19 18:45:39 +05:30
parent 92444eacb8
commit 6638f33d1b
4 changed files with 43 additions and 21 deletions
+25
View File
@@ -0,0 +1,25 @@
import { mount, ReactWrapper } from "enzyme";
import * as React from "react";
import C from "./sample-components/basic";
describe("Component", () => {
let container: HTMLDivElement;
let wrapper: ReactWrapper;
beforeEach(() => {
container = document.body.appendChild(document.createElement("div"));
});
afterEach(() => {
document.body.removeChild(container);
});
it("should render correctly", () => {
const rootRef = React.createRef<C>();
rootRef.current && rootRef.current
wrapper = mount(<C text="text" ref={rootRef} />, { attachTo: container });
expect(wrapper.html()).toMatchSnapshot();
});
});
-21
View File
@@ -1,21 +0,0 @@
import { mount, ReactWrapper } from 'enzyme'
import * as React from 'react'
import C from '../src'
describe('Component', () => {
let container: HTMLDivElement
let wrapper: ReactWrapper
beforeEach(() => {
container = document.body.appendChild(document.createElement('div'))
})
afterEach(() => {
document.body.removeChild(container)
})
it('should render correctly', () => {
wrapper = mount(<C text="text" />, { attachTo: container })
expect(wrapper.html()).toMatchSnapshot()
})
})
+18
View File
@@ -0,0 +1,18 @@
// import * as PropTypes from "prop-types";
import * as React from "react";
interface Props {
text: string;
}
class C extends React.Component<Props> {
render() {
return <p>{this.props.text}</p>;
}
}
// C.propTypes = {
// text: PropTypes.string.isRequired
// };
export default C;