add some basic tests
This commit is contained in:
parent
4cc0f28708
commit
9f6343a9f6
@ -72,6 +72,7 @@
|
|||||||
"@storybook/node-logger": "^6.3.8",
|
"@storybook/node-logger": "^6.3.8",
|
||||||
"@storybook/preset-create-react-app": "^3.2.0",
|
"@storybook/preset-create-react-app": "^3.2.0",
|
||||||
"@storybook/react": "^6.3.8",
|
"@storybook/react": "^6.3.8",
|
||||||
|
"babel-loader": "8.1.0",
|
||||||
"postcss": "8.3.6",
|
"postcss": "8.3.6",
|
||||||
"rollup": "^2.56.3",
|
"rollup": "^2.56.3",
|
||||||
"rollup-plugin-postcss": "^4.0.1",
|
"rollup-plugin-postcss": "^4.0.1",
|
||||||
|
28
src/components/callout/callout.test.tsx
Normal file
28
src/components/callout/callout.test.tsx
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { render, screen } from "@testing-library/react";
|
||||||
|
import * as React from "react";
|
||||||
|
import { Callout } from ".";
|
||||||
|
|
||||||
|
test("It renders content within callout", () => {
|
||||||
|
render(<Callout>Content</Callout>);
|
||||||
|
expect(screen.getByTestId("callout")).toHaveTextContent("Content");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("It renders title and icon", () => {
|
||||||
|
render(<Callout icon={<div data-testid="icon" />} title="title" />);
|
||||||
|
expect(screen.getByTestId("icon")).toBeInTheDocument();
|
||||||
|
expect(screen.getByText("title")).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
const intents = ["warn", "action", "error", "success"] as [
|
||||||
|
"warn",
|
||||||
|
"action",
|
||||||
|
"error",
|
||||||
|
"success"
|
||||||
|
];
|
||||||
|
|
||||||
|
intents.map((intent) =>
|
||||||
|
test("Applies class based on intent", () => {
|
||||||
|
render(<Callout intent={intent} />);
|
||||||
|
expect(screen.getByTestId("callout")).toHaveClass(`callout--${intent}`);
|
||||||
|
})
|
||||||
|
);
|
1
src/react-app-env.d.ts
vendored
Normal file
1
src/react-app-env.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/// <reference types="react-scripts" />
|
@ -1,7 +1,11 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ES2020",
|
"target": "ES2020",
|
||||||
"lib": ["dom", "dom.iterable", "ES2020"],
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"dom.iterable",
|
||||||
|
"ES2020"
|
||||||
|
],
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
@ -16,8 +20,14 @@
|
|||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": true,
|
||||||
"declarationDir": "dist/types"
|
"declarationDir": "dist/types",
|
||||||
|
"noEmit": true
|
||||||
},
|
},
|
||||||
"include": ["src"],
|
"include": [
|
||||||
"exclude": ["node_modules", "**/*.stories.tsx"]
|
"src"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"**/*.stories.tsx"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user