Browse Source

add empty card test

tumao 4 years ago
parent
commit
dbe920f2c8

+ 0 - 7
client/package.json

@@ -31,19 +31,12 @@
     "typescript": "^4.1.2",
     "web-vitals": "^1.0.1"
   },
-  "jest": {
-    "collectCoverage": true,
-    "coverageReporters": [
-      "json"
-    ]
-  },
   "scripts": {
     "start": "react-app-rewired start -FAST_REFRESH=true",
     "build": "react-app-rewired build",
     "test": "react-app-rewired test",
     "test:watch": "react-app-rewired test --watch",
     "test:cov": "react-app-rewired test --watchAll=false --coverage",
-    "test:report": "react-app-rewired test --watchAll=false --coverageReporters='text-summary'",
     "eject": "react-app-rewired eject"
   },
   "eslintConfig": {

+ 20 - 0
client/src/components/__test__/cards/EmptyCard.spec.tsx

@@ -0,0 +1,20 @@
+import { render, screen, RenderResult } from '@testing-library/react';
+import EmptyCard from '../../cards/EmptyCard';
+import provideTheme from '../utils/provideTheme';
+
+let body: RenderResult;
+
+describe('test empty card component', () => {
+  beforeEach(() => {
+    body = render(
+      provideTheme(
+        <EmptyCard icon={<span className="icon">icon</span>} text="empty" />
+      )
+    );
+  });
+
+  it('renders default state', () => {
+    expect(screen.getByText('icon')).toHaveClass('icon');
+    expect(screen.getByText('empty')).toBeInTheDocument();
+  });
+});

+ 2 - 1
client/src/components/__test__/copy/Copy.spec.tsx

@@ -1,3 +1,4 @@
+import { ReactNode } from 'react';
 import { render, unmountComponentAtNode } from 'react-dom';
 import { act } from 'react-dom/test-utils';
 import Copy from '../../copy/Copy';
@@ -10,7 +11,7 @@ jest.mock('react-i18next', () => ({
 }));
 
 jest.mock('@material-ui/core/Tooltip', () => {
-  return props => {
+  return (props: { children: ReactNode }) => {
     return <div id="tooltip">{props.children}</div>;
   };
 });

+ 6 - 0
client/src/components/__test__/utils/provideTheme.tsx

@@ -0,0 +1,6 @@
+import { ReactElement } from 'react';
+import { MuiThemeProvider } from '@material-ui/core/styles';
+import { theme } from '../../../styles/theme';
+export default (ui: ReactElement): ReactElement => {
+  return <MuiThemeProvider theme={theme}>{ui}</MuiThemeProvider>;
+};