Add test for workers
authorShinigami92 <chrissi92@hotmail.de>
Sun, 14 Feb 2021 14:02:42 +0000 (15:02 +0100)
committerShinigami92 <chrissi92@hotmail.de>
Sun, 14 Feb 2021 14:02:42 +0000 (15:02 +0100)
package-lock.json
package.json
tests/worker/cluster-worker.test.js [new file with mode: 0644]
tests/worker/thread-worker.test.js [new file with mode: 0644]

index efed1e62096d6efa27caa84ce398f8199a3c0c69..fe7d419b434cc8a7e0d2c7c6361ae3bb4fc4469f 100644 (file)
       "dev": true
     },
     "uglify-js": {
-      "version": "3.12.7",
-      "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.7.tgz",
-      "integrity": "sha512-SIZhkoh+U/wjW+BHGhVwE9nt8tWJspncloBcFapkpGRwNPqcH8pzX36BXe3TPBjzHWPMUZotpCigak/udWNr1Q==",
+      "version": "3.12.8",
+      "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.8.tgz",
+      "integrity": "sha512-fvBeuXOsvqjecUtF/l1dwsrrf5y2BCUk9AOJGzGcm6tE7vegku5u/YvqjyDaAGr422PLoLnrxg3EnRvTqsdC1w==",
       "dev": true,
       "optional": true
     },
index ff1376dfcf89e311c1bc547d57fabaac2c83ad3c..fdba3a8b9ab5df262d49dd37d4b90e480423d72b 100644 (file)
@@ -9,9 +9,9 @@
     "benchmark": "npm run build && node benchmarks/bench.js",
     "benchmark:debug": "npm run build:dev && node -r source-map-support/register --inspect-brk benchmarks/bench.js",
     "benchmark:debug:vscode": "node -r source-map-support/register benchmarks/bench.js",
-    "test": "npm run build && nyc mocha --exit --timeout 20000 tests/**/*.test.js",
-    "test:debug": "npm run build:dev && mocha -r source-map-support/register --inspect-brk --exit tests/**/*.test.js",
-    "test:debug:vscode": "mocha -r source-map-support/register --exit tests/**/*.test.js",
+    "test": "npm run build && nyc mocha --exit --timeout 20000 'tests/**/*.test.js'",
+    "test:debug": "npm run build:dev && mocha -r source-map-support/register --inspect-brk --exit 'tests/**/*.test.js'",
+    "test:debug:vscode": "mocha -r source-map-support/register --exit 'tests/**/*.test.js'",
     "sonar": "sonar-scanner",
     "coverage": "nyc report --reporter=lcov --check-coverage --lines 80",
     "coverage:html": "nyc report --reporter=html --check-coverage --lines 80",
diff --git a/tests/worker/cluster-worker.test.js b/tests/worker/cluster-worker.test.js
new file mode 100644 (file)
index 0000000..fc2d344
--- /dev/null
@@ -0,0 +1,10 @@
+const expect = require('expect')
+const { ClusterWorker } = require('../../lib')
+
+describe('Cluster worker test suite', () => {
+  // Skipped because ClusterWorker would be in main instead of non-main worker
+  it.skip('Verify worker has default maxInactiveTime', () => {
+    const worker = new ClusterWorker(() => {})
+    expect(worker.maxInactiveTime).toEqual(60_000)
+  })
+})
diff --git a/tests/worker/thread-worker.test.js b/tests/worker/thread-worker.test.js
new file mode 100644 (file)
index 0000000..240534a
--- /dev/null
@@ -0,0 +1,9 @@
+const expect = require('expect')
+const { ThreadWorker } = require('../../lib')
+
+describe('Thread worker test suite', () => {
+  it('Verify worker has default maxInactiveTime', () => {
+    const worker = new ThreadWorker(() => {})
+    expect(worker.maxInactiveTime).toEqual(60_000)
+  })
+})