From 922203e142bda71ebf8de6513bce29d76e1e2379 Mon Sep 17 00:00:00 2001 From: Myrotvorets Date: Mon, 25 Sep 2023 16:55:16 +0300 Subject: [PATCH] Linting --- .eslintrc.json | 3 +- Dockerfile | 2 +- nodemon.json | 5 +- package-lock.json | 71 ++++++++++++++----- package.json | 5 +- src/controllers/monitoring.mts | 3 +- .../controllers/monitoring.test.mts | 44 ++++++++---- test/functional/middleware/error.test.mts | 27 +++---- test/functional/middleware/upload.test.mts | 18 +++-- test/unit/lib/badrequesterror.test.mts | 5 +- test/unit/lib/environment.test.mts | 17 +++-- test/unit/lib/facexerror.test.mts | 5 +- test/unit/lib/uploaderror.test.mts | 5 +- test/unit/services/video.test.mts | 36 +++++----- 14 files changed, 159 insertions(+), 87 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 36c98a17..d3f0e815 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,7 +4,8 @@ "sourceType": "module" }, "extends": [ - "@myrotvorets/myrotvorets-ts" + "@myrotvorets/myrotvorets-ts", + "plugin:mocha/recommended" ], "env": { "es2022": true, diff --git a/Dockerfile b/Dockerfile index 658b216b..37d17838 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ USER nobody:nobody COPY --chown=nobody:nobody ./package.json ./package-lock.json ./tsconfig.json .npmrc* ./ RUN \ npm r --package-lock-only \ - @myrotvorets/eslint-config-myrotvorets-ts eslint-formatter-gha \ + @myrotvorets/eslint-config-myrotvorets-ts eslint-formatter-gha eslint-plugin-mocha \ mocha @types/mocha chai @types/chai chai-as-promised @types/chai-as-promised supertest @types/supertest testdouble c8 mocha-multi mocha-reporter-gha mocha-reporter-sonarqube \ ts-node nodemon && \ npm ci --ignore-scripts --userconfig .npmrc.local && \ diff --git a/nodemon.json b/nodemon.json index db1b2ec8..17dd1b87 100644 --- a/nodemon.json +++ b/nodemon.json @@ -1,5 +1,6 @@ { "watch": ["src"], - "ext": "mts", - "exec": "rm -rf dist && ts-node-script --transpile-only ./src/index.mts" + "ext": "mts,yaml", + "exec": "rm -rf dist && ts-node-script --transpile-only ./src/index.mts", + "signal": "SIGTERM" } diff --git a/package-lock.json b/package-lock.json index b5881947..622bb3a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,12 +11,12 @@ "dependencies": { "@cloudnative/health-connect": "^2.1.0", "@myrotvorets/clean-up-after-multer": "^1.1.6", - "@myrotvorets/create-server": "^2.1.1", + "@myrotvorets/create-server": "^2.2.0", "@myrotvorets/envalidators": "^2.1.0", "@myrotvorets/express-async-middleware-wrapper": "^2.1.0", "@myrotvorets/express-microservice-middlewares": "^1.5.7", "@myrotvorets/facex": "^2.6.0", - "@myrotvorets/oav-installer": "^4.0.0", + "@myrotvorets/oav-installer": "^4.0.1", "@myrotvorets/opentelemetry-configurator": "^4.0.1", "@opentelemetry/instrumentation-express": "^0.33.0", "envalid": "^8.0.0", @@ -38,6 +38,7 @@ "chai": "^4.3.8", "chai-as-promised": "^7.1.1", "eslint-formatter-gha": "^1.2.0", + "eslint-plugin-mocha": "^10.2.0", "mocha": "^10.2.0", "mocha-multi": "^1.1.7", "mocha-reporter-gha": "^1.0.2", @@ -562,17 +563,6 @@ "@opentelemetry/api": "^1.3.0" } }, - "node_modules/@opentelemetry/instrumentation-express/node_modules/@types/express": { - "version": "4.17.17", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.17.tgz", - "integrity": "sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==", - "dependencies": { - "@types/body-parser": "*", - "@types/express-serve-static-core": "^4.17.33", - "@types/qs": "*", - "@types/serve-static": "*" - } - }, "node_modules/@opentelemetry/instrumentation-http": { "version": "0.43.0", "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-http/-/instrumentation-http-0.43.0.tgz", @@ -760,9 +750,9 @@ "dev": true }, "node_modules/@types/express": { - "version": "4.17.18", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.18.tgz", - "integrity": "sha512-Sxv8BSLLgsBYmcnGdGjjEjqET2U+AKAdCRODmMiq02FgjwuV75Ut85DRpvFjyw/Mk0vgUOliGRU0UUmuuZHByQ==", + "version": "4.17.17", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.17.tgz", + "integrity": "sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==", "dependencies": { "@types/body-parser": "*", "@types/express-serve-static-core": "^4.17.33", @@ -2632,6 +2622,22 @@ "semver": "bin/semver.js" } }, + "node_modules/eslint-plugin-mocha": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-mocha/-/eslint-plugin-mocha-10.2.0.tgz", + "integrity": "sha512-ZhdxzSZnd1P9LqDPF0DBcFLpRIGdh1zkF2JHnQklKQOvrQtT73kdP5K9V2mzvbLR+cCAO9OI48NXK/Ax9/ciCQ==", + "dev": true, + "dependencies": { + "eslint-utils": "^3.0.0", + "rambda": "^7.4.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, "node_modules/eslint-plugin-prettier": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.0.0.tgz", @@ -2705,6 +2711,33 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^2.0.0" + }, + "engines": { + "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + }, + "peerDependencies": { + "eslint": ">=5" + } + }, + "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/eslint-visitor-keys": { "version": "3.4.3", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", @@ -5335,6 +5368,12 @@ "node": ">= 0.14.0" } }, + "node_modules/rambda": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/rambda/-/rambda-7.5.0.tgz", + "integrity": "sha512-y/M9weqWAH4iopRd7EHDEQQvpFPHj1AA3oHozE9tfITHUtTR7Z9PSlIRRG2l1GuW7sefC1cXFfIcF+cgnShdBA==", + "dev": true + }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", diff --git a/package.json b/package.json index 1bb9b640..d4cba1ad 100644 --- a/package.json +++ b/package.json @@ -18,12 +18,12 @@ "dependencies": { "@cloudnative/health-connect": "^2.1.0", "@myrotvorets/clean-up-after-multer": "^1.1.6", - "@myrotvorets/create-server": "^2.1.1", + "@myrotvorets/create-server": "^2.2.0", "@myrotvorets/envalidators": "^2.1.0", "@myrotvorets/express-async-middleware-wrapper": "^2.1.0", "@myrotvorets/express-microservice-middlewares": "^1.5.7", "@myrotvorets/facex": "^2.6.0", - "@myrotvorets/oav-installer": "^4.0.0", + "@myrotvorets/oav-installer": "^4.0.1", "@myrotvorets/opentelemetry-configurator": "^4.0.1", "@opentelemetry/instrumentation-express": "^0.33.0", "envalid": "^8.0.0", @@ -45,6 +45,7 @@ "chai": "^4.3.8", "chai-as-promised": "^7.1.1", "eslint-formatter-gha": "^1.2.0", + "eslint-plugin-mocha": "^10.2.0", "mocha": "^10.2.0", "mocha-multi": "^1.1.7", "mocha-reporter-gha": "^1.0.2", diff --git a/src/controllers/monitoring.mts b/src/controllers/monitoring.mts index 534ecca4..995e621f 100644 --- a/src/controllers/monitoring.mts +++ b/src/controllers/monitoring.mts @@ -8,13 +8,14 @@ import { import { Router } from 'express'; import { addJsonContentTypeMiddleware } from '@myrotvorets/express-microservice-middlewares'; -export const healthChecker = new HealthChecker(); +export let healthChecker: HealthChecker | undefined; export function monitoringController(): Router { const router = Router(); const shutdownCheck = new ShutdownCheck('SIGTERM', (): Promise => Promise.resolve()); + healthChecker = new HealthChecker(); healthChecker.registerShutdownCheck(shutdownCheck); router.use(addJsonContentTypeMiddleware); diff --git a/test/functional/controllers/monitoring.test.mts b/test/functional/controllers/monitoring.test.mts index 750704c0..39550b4d 100644 --- a/test/functional/controllers/monitoring.test.mts +++ b/test/functional/controllers/monitoring.test.mts @@ -1,22 +1,23 @@ -import { afterEach, before, beforeEach } from 'mocha'; import express, { type Express } from 'express'; import request from 'supertest'; import { healthChecker, monitoringController } from '../../../src/controllers/monitoring.mjs'; -describe('MonitoringController', () => { +describe('MonitoringController', function () { let app: Express; - before(() => { + before(function () { app = express(); app.disable('x-powered-by'); app.use('/monitoring', monitoringController()); }); - beforeEach(() => { + beforeEach(function () { healthChecker.shutdownRequested = false; }); - afterEach(() => process.removeAllListeners('SIGTERM')); + afterEach(function () { + process.removeAllListeners('SIGTERM'); + }); const checker200 = (endpoint: string): Promise => request(app).get(`/monitoring/${endpoint}`).expect('Content-Type', /json/u).expect(200); @@ -26,18 +27,33 @@ describe('MonitoringController', () => { return request(app).get(`/monitoring/${endpoint}`).expect('Content-Type', /json/u).expect(503); }; - describe('Liveness Check', () => { - it('should succeed', () => checker200('live')); - it('should fail when shutdown requested', () => checker503('live')); + describe('Liveness Check', function () { + it('should succeed', function () { + return checker200('live'); + }); + + it('should fail when shutdown requested', function () { + return checker503('live'); + }); }); - describe('Readiness Check', () => { - it('should succeed', () => checker200('ready')); - it('should fail when shutdown requested', () => checker503('ready')); + describe('Readiness Check', function () { + it('should succeed', function () { + return checker200('ready'); + }); + + it('should fail when shutdown requested', function () { + return checker503('ready'); + }); }); - describe('Health Check', () => { - it('should succeed', () => checker200('health')); - it('should fail when shutdown requested', () => checker503('health')); + describe('Health Check', function () { + it('should succeed', function () { + return checker200('health'); + }); + + it('should fail when shutdown requested', function () { + return checker503('health'); + }); }); }); diff --git a/test/functional/middleware/error.test.mts b/test/functional/middleware/error.test.mts index b3de541f..f89f6fed 100644 --- a/test/functional/middleware/error.test.mts +++ b/test/functional/middleware/error.test.mts @@ -1,4 +1,3 @@ -import { afterEach, beforeEach, describe, it } from 'mocha'; import { expect } from 'chai'; import express, { type Express, type NextFunction } from 'express'; import request from 'supertest'; @@ -9,11 +8,15 @@ import { environment } from '../../../src/lib/environment.mjs'; import { UploadError } from '../../../src/lib/uploaderror.mjs'; import { faceXErrorHandlerMiddleware } from '../../../src/middleware/error.mjs'; -describe('faceXErrorHandlerMiddleware', () => { +describe('faceXErrorHandlerMiddleware', function () { let app: Express; - const env = { ...process.env }; + let env: typeof process.env; - beforeEach(() => { + before(function () { + env = { ...process.env }; + }); + + beforeEach(function () { process.env = { NODE_ENV: 'test', PORT: '3030', @@ -26,7 +29,7 @@ describe('faceXErrorHandlerMiddleware', () => { app.disable('x-powered-by'); }); - afterEach(() => { + afterEach(function () { process.env = { ...env }; }); @@ -39,7 +42,7 @@ describe('faceXErrorHandlerMiddleware', () => { const expectBadGateway = (res: request.Response): unknown => expectError(res, 'BAD_GATEWAY', 502); - it('should ignore non-errors', () => { + it('should ignore non-errors', function () { app.use('/', (_req, _res, next: NextFunction) => next(123)); app.use(faceXErrorHandlerMiddleware); app.use(errorMiddleware); @@ -49,7 +52,7 @@ describe('faceXErrorHandlerMiddleware', () => { .expect((res) => expect(res.body).to.deep.equal({})); }); - it('should catch UploadError', () => { + it('should catch UploadError', function () { app.use('/', (_req, _res, next: NextFunction) => next(new UploadError('message', 'file'))); app.use(faceXErrorHandlerMiddleware); app.use(errorMiddleware); @@ -60,7 +63,7 @@ describe('faceXErrorHandlerMiddleware', () => { .expect((res) => expectError(res, 'UPLOAD_FAILED', 400)); }); - it('should catch FaceX HttpError', () => { + it('should catch FaceX HttpError', function () { app.use('/', (_req, _res, next: NextFunction) => next(new HttpError({ status: 418, statusText: "I'm a teapot" })), ); @@ -69,21 +72,21 @@ describe('faceXErrorHandlerMiddleware', () => { return request(app).get('/').expect(502).expect('Content-Type', /json/u).expect(expectBadGateway); }); - it('should catch FaceX NetworkError', () => { + it('should catch FaceX NetworkError', function () { app.use('/', (_req, _res, next: NextFunction) => next(new NetworkError('Boom-boom bye-bye'))); app.use(faceXErrorHandlerMiddleware); app.use(errorMiddleware); return request(app).get('/').expect(502).expect('Content-Type', /json/u).expect(expectBadGateway); }); - it('should catch FaceX BadResponseError', () => { + it('should catch FaceX BadResponseError', function () { app.use('/', (_req, _res, next: NextFunction) => next(new BadResponseError('Boom-boom bye-bye'))); app.use(faceXErrorHandlerMiddleware); app.use(errorMiddleware); return request(app).get('/').expect(502).expect('Content-Type', /json/u).expect(expectBadGateway); }); - it('should catch BadRequestError', () => { + it('should catch BadRequestError', function () { app.use('/', (_req, _res, next: NextFunction) => next(new BadRequestError('Boom-boom bye-bye'))); app.use(faceXErrorHandlerMiddleware); app.use(errorMiddleware); @@ -94,7 +97,7 @@ describe('faceXErrorHandlerMiddleware', () => { .expect((res) => expectError(res, 'BAD_REQUEST', 400)); }); - it('should catch FaceXError', () => { + it('should catch FaceXError', function () { app.use('/', (_req, _res, next: NextFunction) => next(new FaceXError('Boom-boom bye-bye'))); app.use(faceXErrorHandlerMiddleware); app.use(errorMiddleware); diff --git a/test/functional/middleware/upload.test.mts b/test/functional/middleware/upload.test.mts index 5e627d14..496c6f28 100644 --- a/test/functional/middleware/upload.test.mts +++ b/test/functional/middleware/upload.test.mts @@ -1,4 +1,3 @@ -import { afterEach, beforeEach, describe, it } from 'mocha'; import { expect } from 'chai'; import express, { type Express, type NextFunction } from 'express'; import request from 'supertest'; @@ -7,11 +6,15 @@ import { type ErrorCode, MulterError } from 'multer'; import { uploadErrorHandlerMiddleware } from '../../../src/middleware/upload.mjs'; import { environment } from '../../../src/lib/environment.mjs'; -describe('uploadErrorHandlerMiddleware', () => { - const env = { ...process.env }; +describe('uploadErrorHandlerMiddleware', function () { let app: Express; + let env: typeof process.env; - beforeEach(() => { + before(function () { + env = { ...process.env }; + }); + + beforeEach(function () { process.env = { NODE_ENV: 'test', PORT: '3030', @@ -24,11 +27,11 @@ describe('uploadErrorHandlerMiddleware', () => { app.disable('x-powered-by'); }); - afterEach(() => { + afterEach(function () { process.env = { ...env }; }); - it('should not modify non-multer errors', () => { + it('should not modify non-multer errors', function () { app.use('/', (_req, _res, next: NextFunction) => next(new Error())); app.use(uploadErrorHandlerMiddleware); app.use(errorMiddleware); @@ -50,8 +53,9 @@ describe('uploadErrorHandlerMiddleware', () => { ['OTHER_ERROR' as ErrorCode, 'BAD_REQUEST'], ]; + // eslint-disable-next-line mocha/no-setup-in-describe table.forEach(([error, expectedCode]) => { - it(`should properly handle Multer errors (${error} => ${expectedCode})`, () => { + it(`should properly handle Multer errors (${error} => ${expectedCode})`, function () { app.use('/', (_req, _res, next: NextFunction) => next(new MulterError(error))); app.use(uploadErrorHandlerMiddleware); app.use(errorMiddleware); diff --git a/test/unit/lib/badrequesterror.test.mts b/test/unit/lib/badrequesterror.test.mts index 7edc2926..9ae09934 100644 --- a/test/unit/lib/badrequesterror.test.mts +++ b/test/unit/lib/badrequesterror.test.mts @@ -1,9 +1,8 @@ -import { describe, it } from 'mocha'; import { expect } from 'chai'; import { BadRequestError } from '../../../src/lib/badrequesterror.mjs'; -describe('BadRequestError', () => { - it('should be correct', () => { +describe('BadRequestError', function () { + it('should be correct', function () { const expectedMessage = 'message'; const error = new BadRequestError(expectedMessage); expect(error).to.be.instanceOf(BadRequestError).and.include({ diff --git a/test/unit/lib/environment.test.mts b/test/unit/lib/environment.test.mts index c97baa13..c8e7f861 100644 --- a/test/unit/lib/environment.test.mts +++ b/test/unit/lib/environment.test.mts @@ -1,13 +1,18 @@ -import { afterEach, describe, it } from 'mocha'; import { expect } from 'chai'; import { Environment, environment } from '../../../src/lib/environment.mjs'; -describe('environment', () => { - const env = { ...process.env }; +describe('environment', function () { + let env: typeof process.env; - afterEach(() => (process.env = { ...env })); + before(function () { + env = { ...process.env }; + }); + + afterEach(function () { + process.env = { ...env }; + }); - it('should ignore extra variables', () => { + it('should ignore extra variables', function () { const expected: Environment = { NODE_ENV: 'development', PORT: 3000, @@ -27,7 +32,7 @@ describe('environment', () => { expect(actual).to.deep.equal(expected); }); - it('should cache the result', () => { + it('should cache the result', function () { const expected: Environment = { NODE_ENV: 'staging', PORT: 3030, diff --git a/test/unit/lib/facexerror.test.mts b/test/unit/lib/facexerror.test.mts index 147d2cec..7caf7cbd 100644 --- a/test/unit/lib/facexerror.test.mts +++ b/test/unit/lib/facexerror.test.mts @@ -1,10 +1,9 @@ -import { describe, it } from 'mocha'; import { expect } from 'chai'; import { FaceXError } from '@myrotvorets/facex'; import { errorResponseFromFaceXError } from '../../../src/lib/facexerror.mjs'; -describe('errorResponseFromFaceXError', () => { - it('should produce correct results', () => { +describe('errorResponseFromFaceXError', function () { + it('should produce correct results', function () { const error = new FaceXError('message'); const result = errorResponseFromFaceXError(error); expect(result).to.deep.equal({ diff --git a/test/unit/lib/uploaderror.test.mts b/test/unit/lib/uploaderror.test.mts index 5a3370b4..464ac55a 100644 --- a/test/unit/lib/uploaderror.test.mts +++ b/test/unit/lib/uploaderror.test.mts @@ -1,9 +1,8 @@ -import { describe, it } from 'mocha'; import { expect } from 'chai'; import { UploadError } from '../../../src/lib/uploaderror.mjs'; -describe('UploadError', () => { - it('should be correct', () => { +describe('UploadError', function () { + it('should be correct', function () { const expectedMessage = 'message'; const expectedFile = 'file'; const error = new UploadError(expectedMessage, expectedFile); diff --git a/test/unit/services/video.test.mts b/test/unit/services/video.test.mts index 51c9129e..f31d9457 100644 --- a/test/unit/services/video.test.mts +++ b/test/unit/services/video.test.mts @@ -1,4 +1,3 @@ -import { describe, it } from 'mocha'; import { expect } from 'chai'; import { matchers, when } from 'testdouble'; import { @@ -27,20 +26,25 @@ import { successfulVideoUploadResponse, } from './fixtures.mjs'; -describe('VideoService', () => { - const service = new VideoService(new FakeFaceXVideoClient('https://example.com', 'client_id')); +describe('VideoService', function () { + let service: VideoService; - describe('#upload()', () => { - it('should fail on error', () => { + before(function () { + service = new VideoService(new FakeFaceXVideoClient('https://example.com', 'client_id')); + }); + + describe('#upload()', function () { + it('should fail on error', function () { const response = responseFactory(failedVideoUploadResponse) as VideoUploadAck; when(uploadVideo(matchers.anything() as VideoType, matchers.anything() as VideoUploadPriority)).thenResolve( response, ); + return expect(service.upload(fakeFile)).to.be.rejectedWith(UploadError); }); - it('should return GUID on success', () => { + it('should return GUID on success', function () { const expectedGUID = '00000000-0000-0000-0000-000000000001'; const response = responseFactory(successfulVideoUploadResponse(expectedGUID)) as VideoUploadAck; @@ -52,22 +56,22 @@ describe('VideoService', () => { }); }); - describe('#getVideoStatus()', () => { - it('should fail on error', () => { + describe('#getVideoStatus()', function () { + it('should fail on error', function () { const response = responseFactory(failedStatusResponse) as VideoStatus; when(getVideoStatus(clientGUID)).thenResolve(response); return expect(service.status(clientGUID)).to.be.rejectedWith(FaceXError); }); - it('should return false if the result is not ready', () => { + it('should return false if the result is not ready', function () { const response = responseFactory(inProgressStatusResponse) as VideoStatus; when(getVideoStatus(clientGUID)).thenResolve(response); return expect(service.status(clientGUID)).to.eventually.be.false; }); - it('should return proper data on success', () => { + it('should return proper data on success', function () { const expectedResult: ProcessingStats = { detections: 12, matches: 375, @@ -89,22 +93,22 @@ describe('VideoService', () => { }); }); - describe('#getVideoResult()', () => { - it('should fail on not finished requests', () => { + describe('#getVideoResult()', function () { + it('should fail on not finished requests', function () { const response = responseFactory(inProgressStatusResponse) as VideoStatus; when(getVideoStatus(clientGUID)).thenResolve(response); return expect(service.result(clientGUID, 'detect', 1)).to.be.rejectedWith(BadRequestError); }); - it('should fail on bad archive numbers', () => { + it('should fail on bad archive numbers', function () { const response = responseFactory(successfulStatusResponse(0, 0, 0, 0)) as VideoStatus; when(getVideoStatus(clientGUID)).thenResolve(response); return expect(service.result(clientGUID, 'detect', 1)).to.be.rejectedWith(BadRequestError); }); - it('should fail on errors', () => { + it('should fail on errors', function () { when(getVideoStatus(clientGUID)).thenResolve( responseFactory(successfulStatusResponse(1, 1, 1, 1)) as VideoStatus, ); @@ -116,7 +120,7 @@ describe('VideoService', () => { return expect(service.result(clientGUID, 'detect', 1)).to.be.rejectedWith(FaceXError); }); - it('should return empty buffer if there is no archive', () => { + it('should return empty buffer if there is no archive', function () { when(getVideoStatus(clientGUID)).thenResolve( responseFactory(successfulStatusResponse(1, 1, 1, 1)) as VideoStatus, ); @@ -129,7 +133,7 @@ describe('VideoService', () => { }); }); - it('should return non-empty buffer if there is an archive', async () => { + it('should return non-empty buffer if there is an archive', async function () { const expectedString = 'Test'; when(getVideoStatus(clientGUID)).thenResolve(