From 670735a4e9968275f1ca93142a8126ad9f59d3d5 Mon Sep 17 00:00:00 2001 From: VICTOR RAPHAEL BRAGA DE SALES MASCARENHAS Date: Wed, 6 Mar 2019 13:30:55 -0300 Subject: [PATCH] Typescript download manager unit test (#579) * adding enzyme * download manager unit test --- jest.unit.config.json | 3 + package.json | 3 + .../downloadManager.spec.ts.snap | 181 ++++++++++++++++++ spec/downloadManager.spec.ts | 123 ++++++++++++ spec/protocolHandler.spec.ts | 2 +- spec/setup/test-setup.js | 10 + src/renderer/components/download-manager.tsx | 2 +- 7 files changed, 322 insertions(+), 2 deletions(-) create mode 100644 spec/__snapshots__/downloadManager.spec.ts.snap create mode 100644 spec/downloadManager.spec.ts create mode 100644 spec/setup/test-setup.js diff --git a/jest.unit.config.json b/jest.unit.config.json index 95d4a069..73cb09e0 100644 --- a/jest.unit.config.json +++ b/jest.unit.config.json @@ -36,5 +36,8 @@ "sort": "status", "outputPath": "./out/Unit Tests Report.html" }] + ], + "setupFiles": [ + "./spec/setup/test-setup.js" ] } diff --git a/package.json b/package.json index 65645dda..8f704a0a 100644 --- a/package.json +++ b/package.json @@ -80,6 +80,7 @@ }, "devDependencies": { "@types/auto-launch": "^5.0.0", + "@types/enzyme": "^3.9.0", "@types/ffi": "0.2.1", "@types/jest": "23.3.12", "@types/lodash.omit": "^4.5.4", @@ -103,6 +104,8 @@ "electron-chromedriver": "4.0.0-beta.1", "electron-packager": "13.0.1", "electron-rebuild": "1.8.2", + "enzyme": "^3.9.0", + "enzyme-adapter-react-16": "^1.10.0", "eslint": "5.6.1", "eslint-config-airbnb": "17.1.0", "eslint-plugin-import": "2.14.0", diff --git a/spec/__snapshots__/downloadManager.spec.ts.snap b/spec/__snapshots__/downloadManager.spec.ts.snap new file mode 100644 index 00000000..bec11331 --- /dev/null +++ b/spec/__snapshots__/downloadManager.spec.ts.snap @@ -0,0 +1,181 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`download manager should render correctly 1`] = ` +ShallowWrapper { + Symbol(enzyme.__root__): [Circular], + Symbol(enzyme.__unrendered__): , + Symbol(enzyme.__renderer__): Object { + "batchedUpdates": [Function], + "checkPropTypes": [Function], + "getNode": [Function], + "render": [Function], + "simulateError": [Function], + "simulateEvent": [Function], + "unmount": [Function], + }, + Symbol(enzyme.__node__): Object { + "instance": null, + "key": undefined, + "nodeType": "host", + "props": Object { + "children": , + }, + "ref": null, + "rendered": Object { + "instance": null, + "key": undefined, + "nodeType": "host", + "props": Object { + "children": Array [ +