Changeset View
Changeset View
Standalone View
Standalone View
web/xec-web-components/util/templates/component.test.js
- This file was added.
module.exports = componentName => ({ | |||||
content: `// Generated with util/create-component.js | |||||
import React from "react"; | |||||
import { render } from "@testing-library/react"; | |||||
import ${componentName} from "./${componentName}"; | |||||
import { ${componentName}Props } from "./${componentName}.types"; | |||||
describe("Test Component", () => { | |||||
let props: ${componentName}Props; | |||||
beforeEach(() => { | |||||
props = { | |||||
foo: "bar" | |||||
}; | |||||
}); | |||||
const renderComponent = () => render(<${componentName} {...props} />); | |||||
it("should render foo text correctly", () => { | |||||
props.foo = "harvey was here"; | |||||
const { getByTestId } = renderComponent(); | |||||
const component = getByTestId("${componentName}"); | |||||
expect(component).toHaveTextContent("harvey was here"); | |||||
}); | |||||
}); | |||||
`, | |||||
extension: `.test.tsx`, | |||||
}); |