Skip to content

Commit 1c91106

Browse files
committed
ci: setup testes
1 parent 5239dd3 commit 1c91106

File tree

10 files changed

+1308
-6441
lines changed

10 files changed

+1308
-6441
lines changed

.storybook/main.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

.storybook/preview.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

jest.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default {
2+
clearMocks: true,
3+
preset: 'ts-jest',
4+
roots: ['<rootDir>/src'],
5+
testEnvironment: 'jsdom',
6+
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
7+
transform: {
8+
'^.+\\.tsx?$': 'ts-jest',
9+
},
10+
};

package.json

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,17 @@
2626
"scripts": {
2727
"dev": "tsdx watch",
2828
"build": "tsdx build",
29-
"test": "tsdx test --passWithNoTests",
29+
"test": "jest",
3030
"lint": "eslint --fix",
3131
"fmt": "prettier --write src/**/*.{ts,tsx}",
3232
"fmt:check": "prettier --check src/**/*.{ts,tsx}",
3333
"prepare": "tsdx build && husky install",
3434
"size": "size-limit",
35-
"analyze": "size-limit --why",
36-
"storybook": "start-storybook -p 6006",
37-
"build-storybook": "build-storybook"
35+
"analyze": "size-limit --why"
3836
},
3937
"peerDependencies": {
40-
"react": ">=16"
38+
"react": ">=16",
39+
"react-dom": ">=16"
4140
},
4241
"name": "react-mqtt-workflow-manager",
4342
"author": "wallace-sf",
@@ -55,11 +54,9 @@
5554
"devDependencies": {
5655
"@babel/core": "^7.21.0",
5756
"@size-limit/preset-small-lib": "^8.2.4",
58-
"@storybook/addon-essentials": "^6.5.16",
59-
"@storybook/addon-info": "^5.3.21",
60-
"@storybook/addon-links": "^6.5.16",
61-
"@storybook/addons": "^6.5.16",
62-
"@storybook/react": "^6.5.16",
57+
"@testing-library/jest-dom": "^5.16.5",
58+
"@testing-library/react": "^14.0.0",
59+
"@types/jest": "^29.4.0",
6360
"@types/react": "^18.0.28",
6461
"@types/react-dom": "^18.0.11",
6562
"@typescript-eslint/eslint-plugin": "^5.54.0",
@@ -73,12 +70,17 @@
7370
"eslint-plugin-prettier": "^4.2.1",
7471
"eslint-plugin-react": "^7.32.2",
7572
"eslint-plugin-react-hooks": "^4.6.0",
73+
"husky": "^8.0.3",
74+
"jest": "^29.4.3",
75+
"jest-environment-jsdom": "^29.4.3",
7676
"lint-staged": "^13.1.2",
7777
"prettier": "^2.8.4",
7878
"react": "^18.2.0",
7979
"react-dom": "^18.2.0",
8080
"react-is": "^18.2.0",
8181
"size-limit": "^8.2.4",
82+
"ts-jest": "^29.0.5",
83+
"ts-node": "^10.9.1",
8284
"tsdx": "^0.14.1",
8385
"tslib": "^2.5.0",
8486
"typescript": "^4.9.5"

src/WorkflowManager.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ export const WorkflowManager: FC<WorkflowManagerProps> = ({
2727
init();
2828
}, [init]);
2929

30-
return <div>{children ?? `Hello WorkflowManager`}</div>;
30+
return <>{children}</>;
3131
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react';
2+
3+
import { render } from '@testing-library/react';
4+
5+
import { WorkflowManager } from '../WorkflowManager';
6+
7+
describe('WorkflowManager component', () => {
8+
beforeEach(() => {
9+
const props = { brokerUrl: 'http://localhost:8080' };
10+
11+
render(<WorkflowManager {...props} />);
12+
});
13+
14+
it('should render', () => {
15+
expect(true).toBeTruthy();
16+
});
17+
});

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import { PropsWithChildren } from 'react';
33
import { IClientOptions } from 'mqtt';
44
export interface WorkflowManagerProps extends PropsWithChildren {
55
brokerUrl: string;
6-
options: IClientOptions;
6+
options?: IClientOptions;
77
}

stories/WorkflowManager.stories.tsx

Lines changed: 0 additions & 25 deletions
This file was deleted.

test/blah.test.tsx

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)