From ab8a92d744f6bcb0072aa74000061b8cdc4bd9c8 Mon Sep 17 00:00:00 2001 From: Navdeep Date: Wed, 6 Nov 2024 11:05:36 -0500 Subject: [PATCH] migrate all test files to use async await instead of done callback --- packages/api/package-lock.json | 6945 +++++++---------- packages/api/package.json | 2 +- packages/api/tests/animal.test.js | 3 +- packages/api/tests/animal_batch.test.js | 3 +- packages/api/tests/animal_group.test.js | 41 +- .../api/tests/animal_identifier_color.test.js | 17 +- .../api/tests/animal_identifier_type.test.js | 6 +- packages/api/tests/animal_origin.test.js | 17 +- .../api/tests/animal_removal_reason.test.js | 6 +- packages/api/tests/animal_sex.test.js | 17 +- packages/api/tests/animal_union_batch.test.js | 6 +- packages/api/tests/animal_use.test.js | 6 +- packages/api/tests/authorization.test.js | 486 +- packages/api/tests/crop.test.js | 444 +- packages/api/tests/crop_variety.test.js | 634 +- .../api/tests/custom_animal_breed.test.js | 50 +- packages/api/tests/custom_animal_type.test.js | 24 +- .../api/tests/default_animal_breed.test.js | 22 +- .../api/tests/default_animal_type.test.js | 6 +- packages/api/tests/disease.test.js | 318 +- packages/api/tests/documents.test.js | 258 +- packages/api/tests/expense.test.js | 498 +- packages/api/tests/expense_type.test.js | 108 +- packages/api/tests/farm.test.js | 207 +- packages/api/tests/fertilizer.test.js | 286 +- packages/api/tests/harvestUseType.test.js | 158 +- packages/api/tests/insightsAPI.test.js | 266 +- packages/api/tests/invite.user.test.js | 34 +- packages/api/tests/jwt.test.js | 530 +- packages/api/tests/location.test.js | 506 +- packages/api/tests/login.test.js | 158 +- packages/api/tests/managementPlan.test.js | 671 +- packages/api/tests/mock.factories.test.js | 6 +- packages/api/tests/notificationUser.test.js | 112 +- .../api/tests/organicCertifierSurvey.test.js | 623 +- packages/api/tests/organicHistory.test.js | 34 +- packages/api/tests/pesticides.test.js | 302 +- packages/api/tests/price.test.js | 288 +- packages/api/tests/product.test.js | 160 +- packages/api/tests/revenue_type.test.js | 90 +- packages/api/tests/sale.test.js | 573 +- .../soil_amendment_fertiliser_types.test.js | 6 +- .../api/tests/soil_amendment_methods.test.js | 6 +- .../api/tests/soil_amendment_purposes.test.js | 6 +- packages/api/tests/supportTicket.test.js | 30 +- packages/api/tests/task.test.js | 1639 ++-- packages/api/tests/taskNotification.test.js | 274 +- packages/api/tests/tasktype.test.js | 379 +- packages/api/tests/timeNotification.test.js | 342 +- packages/api/tests/user.test.js | 262 +- packages/api/tests/userFarm.test.js | 1007 ++- packages/api/tests/userFarmData.test.js | 167 +- packages/api/tests/yield.test.js | 298 +- 53 files changed, 8189 insertions(+), 11148 deletions(-) diff --git a/packages/api/package-lock.json b/packages/api/package-lock.json index 32346bd130..4ad2a17256 100644 --- a/packages/api/package-lock.json +++ b/packages/api/package-lock.json @@ -73,7 +73,7 @@ "eslint-config-prettier": "^7.0.0", "eslint-plugin-json": "^3.1.0", "i18next-parser": "^5.3.0", - "jest": "^26.4.2", + "jest": "^29.7.0", "lint-staged": "^10.5.3", "nodemon": "^2.0.22", "prettier": "2.2.1", @@ -1575,48 +1575,52 @@ "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" }, "node_modules/@babel/code-frame": { - "version": "7.22.13", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", - "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.2.tgz", + "integrity": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/highlight": "^7.22.13", - "chalk": "^2.4.2" + "@babel/helper-validator-identifier": "^7.25.9", + "js-tokens": "^4.0.0", + "picocolors": "^1.0.0" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/compat-data": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.5.tgz", - "integrity": "sha512-4Jc/YuIaYqKnDDz892kPIledykKg12Aw1PYX5i/TY28anJtacvM1Rrr8wbieB9GfEJwlzqT0hUEao0CxEebiDA==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.26.2.tgz", + "integrity": "sha512-Z0WgzSEa+aUcdiJuCIqgujCshpMWgUpgOxXotrYPSA53hA3qopNaqcJpyr0hVb1FeWdnqFA35/fUtXgBK8srQg==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.5.tgz", - "integrity": "sha512-SBuTAjg91A3eKOvD+bPEz3LlhHZRNu1nFOVts9lzDJTXshHTjII0BAtDS3Y2DAkdZdDKWVZGVwkDfc4Clxn1dg==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.26.0.tgz", + "integrity": "sha512-i1SLeK+DzNnQ3LL/CswPCa/E5u4lh1k6IAEphON8F+cXt0t9euTshDru0q7/IqMa1PMPz5RnHuHscF8/ZJsStg==", "dev": true, + "license": "MIT", "dependencies": { "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.22.5", - "@babel/generator": "^7.22.5", - "@babel/helper-compilation-targets": "^7.22.5", - "@babel/helper-module-transforms": "^7.22.5", - "@babel/helpers": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/template": "^7.22.5", - "@babel/traverse": "^7.22.5", - "@babel/types": "^7.22.5", - "convert-source-map": "^1.7.0", + "@babel/code-frame": "^7.26.0", + "@babel/generator": "^7.26.0", + "@babel/helper-compilation-targets": "^7.25.9", + "@babel/helper-module-transforms": "^7.26.0", + "@babel/helpers": "^7.26.0", + "@babel/parser": "^7.26.0", + "@babel/template": "^7.25.9", + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.26.0", + "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", - "json5": "^2.2.2", - "semver": "^6.3.0" + "json5": "^2.2.3", + "semver": "^6.3.1" }, "engines": { "node": ">=6.9.0" @@ -1626,6 +1630,13 @@ "url": "https://opencollective.com/babel" } }, + "node_modules/@babel/core/node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, "node_modules/@babel/eslint-parser": { "version": "7.22.5", "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.22.5.tgz", @@ -1645,15 +1656,17 @@ } }, "node_modules/@babel/generator": { - "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", - "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.2.tgz", + "integrity": "sha512-zevQbhbau95nkoxSq3f/DC/SC+EEOUZd3DYqfSkMhY2/wfSeaHV1Ew4vk8e+x8lja31IbyuUa2uQ3JONqKbysw==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/types": "^7.23.0", - "@jridgewell/gen-mapping": "^0.3.2", - "@jridgewell/trace-mapping": "^0.3.17", - "jsesc": "^2.5.1" + "@babel/parser": "^7.26.2", + "@babel/types": "^7.26.0", + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25", + "jsesc": "^3.0.2" }, "engines": { "node": ">=6.9.0" @@ -1684,22 +1697,20 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.5.tgz", - "integrity": "sha512-Ji+ywpHeuqxB8WDxraCiqR0xfhYjiDE/e6k7FuIaANnoOFxAHskHChz4vA1mJC9Lbm01s1PVAGhQY4FUKSkGZw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.9.tgz", + "integrity": "sha512-j9Db8Suy6yV/VHa4qzrj9yZfZxhLWQdVnRlXxmKLYlhWUVB1sB2G5sxuWYXk/whHD9iW76PmNzxZ4UCnTQTVEQ==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/compat-data": "^7.22.5", - "@babel/helper-validator-option": "^7.22.5", - "browserslist": "^4.21.3", + "@babel/compat-data": "^7.25.9", + "@babel/helper-validator-option": "^7.25.9", + "browserslist": "^4.24.0", "lru-cache": "^5.1.1", - "semver": "^6.3.0" + "semver": "^6.3.1" }, "engines": { "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" } }, "node_modules/@babel/helper-create-class-features-plugin": { @@ -1806,34 +1817,35 @@ } }, "node_modules/@babel/helper-module-imports": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.22.5.tgz", - "integrity": "sha512-8Dl6+HD/cKifutF5qGd/8ZJi84QeAKh+CEe1sBzz8UayBBGg1dAIJrdHOcOM5b2MpzWL2yuotJTtGjETq0qjXg==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.25.9.tgz", + "integrity": "sha512-tnUA4RsrmflIM6W6RFTLFSXITtl0wKjgpnLgXyowocVPrbYrLUXSBXDgTs8BlbmIzIdlBySRQjINYs2BAkiLtw==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/types": "^7.22.5" + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.25.9" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.5.tgz", - "integrity": "sha512-+hGKDt/Ze8GFExiVHno/2dvG5IdstpzCq0y4Qc9OJ25D4q3pKfiIP/4Vp3/JvhDkLKsDK2api3q3fpIgiIF5bw==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.26.0.tgz", + "integrity": "sha512-xO+xu6B5K2czEnQye6BHA7DolFFmS3LB7stHZFaOLb1pAwO1HWLS8fXA+eh0A2yIvltPVmx3eNNDBJA2SLHXFw==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-environment-visitor": "^7.22.5", - "@babel/helper-module-imports": "^7.22.5", - "@babel/helper-simple-access": "^7.22.5", - "@babel/helper-split-export-declaration": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.5", - "@babel/template": "^7.22.5", - "@babel/traverse": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/helper-module-imports": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9", + "@babel/traverse": "^7.25.9" }, "engines": { "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" } }, "node_modules/@babel/helper-optimise-call-expression": { @@ -1849,10 +1861,11 @@ } }, "node_modules/@babel/helper-plugin-utils": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz", - "integrity": "sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.9.tgz", + "integrity": "sha512-kSMlyUVdWe25rEsRGviIgOWnoT/nfABVWlqt9N19/dIPWViAOW2s9wznP5tURbs/IDuNk4gPy3YdYRgH3uxhBw==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -1929,26 +1942,29 @@ } }, "node_modules/@babel/helper-string-parser": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", - "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", + "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.20", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", - "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", + "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-option": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.22.5.tgz", - "integrity": "sha512-R3oB6xlIVKUnxNUxbmgq7pKjxpru24zlimpE8WK47fACIlM0II/Hm1RS8IaOI7NgCr6LNS+jl5l75m20npAziw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.25.9.tgz", + "integrity": "sha512-e/zv1co8pp55dNdEcCynfj9X7nyUKUXoUEwfXqaZt0omVOmDe9oOTdKStH4GmAw6zxMFs50ZayuMfHDKlO7Tfw==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -1969,14 +1985,14 @@ } }, "node_modules/@babel/helpers": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.22.5.tgz", - "integrity": "sha512-pSXRmfE1vzcUIDFQcSGA5Mr+GxBV9oiRKDuDxXvWQQBCh8HoIjs/2DlDB7H8smac1IVrB9/xdXj2N3Wol9Cr+Q==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.0.tgz", + "integrity": "sha512-tbhNuIxNcVb21pInl3ZSjksLCvgdZy9KwJ8brv993QtIVKJBBkYXz4q4ZbAv31GdnC+R90np23L5FbEBlthAEw==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/template": "^7.22.5", - "@babel/traverse": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/template": "^7.25.9", + "@babel/types": "^7.26.0" }, "engines": { "node": ">=6.9.0" @@ -1997,9 +2013,13 @@ } }, "node_modules/@babel/parser": { - "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", - "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.2.tgz", + "integrity": "sha512-DWMCZH9WA4Maitz2q21SRKHo9QXZxkDsbNZoVD62gusNtNBBqDg9i7uOhASfTfIGNzW+O+r7+jAlM8dwphcJKQ==", + "license": "MIT", + "dependencies": { + "@babel/types": "^7.26.0" + }, "bin": { "parser": "bin/babel-parser.js" }, @@ -2213,6 +2233,22 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.25.9.tgz", + "integrity": "sha512-ld6oezHQMZsZfp6pWtbjaNDF2tiiCYYDqQszHt5VV437lewP9aSi2Of99CK0D0XB21k7FLgnLcmQKyKzynfeAA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-syntax-logical-assignment-operators": { "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", @@ -2315,6 +2351,22 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-syntax-typescript": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.25.9.tgz", + "integrity": "sha512-hjMgRy5hb8uJJjUcdWunWVcoi9bGpJp8p5Ol1229PoN6aytsLwNMgmdftO23wnCLMfVmTwZDWMPNq/D1SY60JQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-syntax-unicode-sets-regex": { "version": "7.18.6", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-unicode-sets-regex/-/plugin-syntax-unicode-sets-regex-7.18.6.tgz", @@ -3236,34 +3288,33 @@ "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" }, "node_modules/@babel/template": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", - "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.9.tgz", + "integrity": "sha512-9DGttpmPvIxBb/2uwpVo3dqJ+O6RooAFOS+lB+xDqoE2PVCE8nfoHMdZLpfCQRLwvohzXISPZcgxt80xLfsuwg==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.22.13", - "@babel/parser": "^7.22.15", - "@babel/types": "^7.22.15" + "@babel/code-frame": "^7.25.9", + "@babel/parser": "^7.25.9", + "@babel/types": "^7.25.9" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.23.2", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", - "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.9.tgz", + "integrity": "sha512-ZCuvfwOwlz/bawvAuvcj8rrithP2/N55Tzz342AkTvq4qaWbGfmCk/tKhNaV2cthijKrPAA8SRJV5WWe7IBMJw==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.22.13", - "@babel/generator": "^7.23.0", - "@babel/helper-environment-visitor": "^7.22.20", - "@babel/helper-function-name": "^7.23.0", - "@babel/helper-hoist-variables": "^7.22.5", - "@babel/helper-split-export-declaration": "^7.22.6", - "@babel/parser": "^7.23.0", - "@babel/types": "^7.23.0", - "debug": "^4.1.0", + "@babel/code-frame": "^7.25.9", + "@babel/generator": "^7.25.9", + "@babel/parser": "^7.25.9", + "@babel/template": "^7.25.9", + "@babel/types": "^7.25.9", + "debug": "^4.3.1", "globals": "^11.1.0" }, "engines": { @@ -3271,13 +3322,13 @@ } }, "node_modules/@babel/types": { - "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", - "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.0.tgz", + "integrity": "sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA==", + "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.20", - "to-fast-properties": "^2.0.0" + "@babel/helper-string-parser": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -3287,23 +3338,8 @@ "version": "0.2.3", "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", - "dev": true - }, - "node_modules/@cnakazawa/watch": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@cnakazawa/watch/-/watch-1.0.4.tgz", - "integrity": "sha512-v9kIhKwjeZThiWrLmj0y17CWoyddASLj9O2yvbZkbvw/N3rWOYy9zkV66ursAoVr0mV15bL8g0c4QZUE6cdDoQ==", "dev": true, - "dependencies": { - "exec-sh": "^0.3.2", - "minimist": "^1.2.0" - }, - "bin": { - "watch": "cli.js" - }, - "engines": { - "node": ">=0.1.95" - } + "license": "MIT" }, "node_modules/@colors/colors": { "version": "1.5.0", @@ -3541,52 +3577,67 @@ } }, "node_modules/@jest/console": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/console/-/console-26.6.2.tgz", - "integrity": "sha512-IY1R2i2aLsLr7Id3S6p2BA82GNWryt4oSvEXLAKc+L2zdi89dSkE8xC1C+0kpATG4JhBJREnQOH7/zmccM2B0g==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.7.0.tgz", + "integrity": "sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", - "jest-message-util": "^26.6.2", - "jest-util": "^26.6.2", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", "slash": "^3.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/console/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/console/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/@jest/console/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/@jest/console/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/@jest/console/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -3602,6 +3653,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -3618,6 +3670,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -3629,32 +3682,35 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@jest/console/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/@jest/console/node_modules/jest-util": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", - "integrity": "sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", - "is-ci": "^2.0.0", - "micromatch": "^4.0.2" + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/console/node_modules/supports-color": { @@ -3662,6 +3718,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -3670,100 +3727,124 @@ } }, "node_modules/@jest/core": { - "version": "26.6.3", - "resolved": "https://registry.npmjs.org/@jest/core/-/core-26.6.3.tgz", - "integrity": "sha512-xvV1kKbhfUqFVuZ8Cyo+JPpipAHHAV3kcDBftiduK8EICXmTFddryy3P7NfZt8Pv37rA9nEJBKCCkglCPt/Xjw==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.7.0.tgz", + "integrity": "sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/console": "^26.6.2", - "@jest/reporters": "^26.6.2", - "@jest/test-result": "^26.6.2", - "@jest/transform": "^26.6.2", - "@jest/types": "^26.6.2", + "@jest/console": "^29.7.0", + "@jest/reporters": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", "@types/node": "*", "ansi-escapes": "^4.2.1", "chalk": "^4.0.0", + "ci-info": "^3.2.0", "exit": "^0.1.2", - "graceful-fs": "^4.2.4", - "jest-changed-files": "^26.6.2", - "jest-config": "^26.6.3", - "jest-haste-map": "^26.6.2", - "jest-message-util": "^26.6.2", - "jest-regex-util": "^26.0.0", - "jest-resolve": "^26.6.2", - "jest-resolve-dependencies": "^26.6.3", - "jest-runner": "^26.6.3", - "jest-runtime": "^26.6.3", - "jest-snapshot": "^26.6.2", - "jest-util": "^26.6.2", - "jest-validate": "^26.6.2", - "jest-watcher": "^26.6.2", - "micromatch": "^4.0.2", - "p-each-series": "^2.1.0", - "rimraf": "^3.0.0", + "graceful-fs": "^4.2.9", + "jest-changed-files": "^29.7.0", + "jest-config": "^29.7.0", + "jest-haste-map": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-resolve-dependencies": "^29.7.0", + "jest-runner": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "jest-watcher": "^29.7.0", + "micromatch": "^4.0.4", + "pretty-format": "^29.7.0", "slash": "^3.0.0", "strip-ansi": "^6.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/core/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/core/node_modules/@jest/transform": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-26.6.2.tgz", - "integrity": "sha512-E9JjhUgNzvuQ+vVAL21vlyfy12gP0GhazGgJC4h6qUt1jSdUXGWJ1wfu/X7Sd8etSgxV4ovT1pb9v5D6QW4XgA==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.7.0.tgz", + "integrity": "sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/core": "^7.1.0", - "@jest/types": "^26.6.2", - "babel-plugin-istanbul": "^6.0.0", + "@babel/core": "^7.11.6", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "babel-plugin-istanbul": "^6.1.1", "chalk": "^4.0.0", - "convert-source-map": "^1.4.0", - "fast-json-stable-stringify": "^2.0.0", - "graceful-fs": "^4.2.4", - "jest-haste-map": "^26.6.2", - "jest-regex-util": "^26.0.0", - "jest-util": "^26.6.2", - "micromatch": "^4.0.2", - "pirates": "^4.0.1", + "convert-source-map": "^2.0.0", + "fast-json-stable-stringify": "^2.1.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "micromatch": "^4.0.4", + "pirates": "^4.0.4", "slash": "^3.0.0", - "source-map": "^0.6.1", - "write-file-atomic": "^3.0.0" + "write-file-atomic": "^4.0.2" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/core/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/@jest/core/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/@jest/core/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/@jest/core/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -3779,6 +3860,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -3795,6 +3877,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -3806,68 +3889,78 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" + }, + "node_modules/@jest/core/node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" }, "node_modules/@jest/core/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/@jest/core/node_modules/jest-haste-map": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-26.6.2.tgz", - "integrity": "sha512-easWIJXIw71B2RdR8kgqpjQrbMRWQBgiBwXYEhtGUTaX+doCjBheluShdDMeR8IMfJiTqH4+zfhtg29apJf/8w==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.7.0.tgz", + "integrity": "sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", - "@types/graceful-fs": "^4.1.2", + "@jest/types": "^29.6.3", + "@types/graceful-fs": "^4.1.3", "@types/node": "*", "anymatch": "^3.0.3", "fb-watchman": "^2.0.0", - "graceful-fs": "^4.2.4", - "jest-regex-util": "^26.0.0", - "jest-serializer": "^26.6.2", - "jest-util": "^26.6.2", - "jest-worker": "^26.6.2", - "micromatch": "^4.0.2", - "sane": "^4.0.3", - "walker": "^1.0.7" + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "micromatch": "^4.0.4", + "walker": "^1.0.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" }, "optionalDependencies": { - "fsevents": "^2.1.2" + "fsevents": "^2.3.2" } }, "node_modules/@jest/core/node_modules/jest-regex-util": { - "version": "26.0.0", - "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-26.0.0.tgz", - "integrity": "sha512-Gv3ZIs/nA48/Zvjrl34bf+oD76JHiGDUxNOVgUjh3j890sblXryjY4rss71fPtD/njchl6PSE2hIhvyWa1eT0A==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", "dev": true, + "license": "MIT", "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/core/node_modules/jest-util": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", - "integrity": "sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", - "is-ci": "^2.0.0", - "micromatch": "^4.0.2" + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/core/node_modules/supports-color": { @@ -3875,6 +3968,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -3882,63 +3976,66 @@ "node": ">=8" } }, - "node_modules/@jest/core/node_modules/write-file-atomic": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", - "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", + "node_modules/@jest/environment": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.7.0.tgz", + "integrity": "sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw==", "dev": true, + "license": "MIT", "dependencies": { - "imurmurhash": "^0.1.4", - "is-typedarray": "^1.0.0", - "signal-exit": "^3.0.2", - "typedarray-to-buffer": "^3.1.5" + "@jest/fake-timers": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-mock": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/@jest/environment": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-26.6.2.tgz", - "integrity": "sha512-nFy+fHl28zUrRsCeMB61VDThV1pVTtlEokBRgqPrcT1JNq4yRNIyTHfyht6PqtUvY9IsuLGTrbG8kPXjSZIZwA==", + "node_modules/@jest/environment/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/fake-timers": "^26.6.2", - "@jest/types": "^26.6.2", - "@types/node": "*", - "jest-mock": "^26.6.2" + "@sinclair/typebox": "^0.27.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/environment/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/@jest/environment/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/@jest/environment/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/@jest/environment/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -3954,6 +4051,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -3970,6 +4068,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -3981,13 +4080,15 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@jest/environment/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -3997,6 +4098,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -4004,46 +4106,107 @@ "node": ">=8" } }, + "node_modules/@jest/expect": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.7.0.tgz", + "integrity": "sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "expect": "^29.7.0", + "jest-snapshot": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect-utils": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.7.0.tgz", + "integrity": "sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==", + "dev": true, + "license": "MIT", + "dependencies": { + "jest-get-type": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, "node_modules/@jest/fake-timers": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-26.6.2.tgz", - "integrity": "sha512-14Uleatt7jdzefLPYM3KLcnUl1ZNikaKq34enpb5XG9i81JpppDb5muZvonvKyrl7ftEHkKS5L5/eB/kxJ+bvA==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.7.0.tgz", + "integrity": "sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", - "@sinonjs/fake-timers": "^6.0.1", + "@jest/types": "^29.6.3", + "@sinonjs/fake-timers": "^10.0.2", "@types/node": "*", - "jest-message-util": "^26.6.2", - "jest-mock": "^26.6.2", - "jest-util": "^26.6.2" + "jest-message-util": "^29.7.0", + "jest-mock": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/fake-timers/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/fake-timers/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/@jest/fake-timers/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/@jest/fake-timers/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jest/fake-timers/node_modules/@sinonjs/commons": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.1.tgz", + "integrity": "sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { - "@types/yargs-parser": "*" + "type-detect": "4.0.8" + } + }, + "node_modules/@jest/fake-timers/node_modules/@sinonjs/fake-timers": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", + "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@sinonjs/commons": "^3.0.0" } }, "node_modules/@jest/fake-timers/node_modules/ansi-styles": { @@ -4051,6 +4214,7 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -4066,6 +4230,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -4082,6 +4247,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -4093,32 +4259,35 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@jest/fake-timers/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/@jest/fake-timers/node_modules/jest-util": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", - "integrity": "sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", - "is-ci": "^2.0.0", - "micromatch": "^4.0.2" + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/fake-timers/node_modules/supports-color": { @@ -4126,6 +4295,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -4134,49 +4304,65 @@ } }, "node_modules/@jest/globals": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-26.6.2.tgz", - "integrity": "sha512-85Ltnm7HlB/KesBUuALwQ68YTU72w9H2xW9FjZ1eL1U3lhtefjjl5c2MiUbpXt/i6LaPRvoOFJ22yCBSfQ0JIA==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.7.0.tgz", + "integrity": "sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/expect": "^29.7.0", + "@jest/types": "^29.6.3", + "jest-mock": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/globals/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/environment": "^26.6.2", - "@jest/types": "^26.6.2", - "expect": "^26.6.2" + "@sinclair/typebox": "^0.27.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/globals/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/@jest/globals/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/@jest/globals/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/@jest/globals/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -4192,6 +4378,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -4208,6 +4395,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -4219,13 +4407,15 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@jest/globals/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -4235,6 +4425,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -4243,99 +4434,120 @@ } }, "node_modules/@jest/reporters": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-26.6.2.tgz", - "integrity": "sha512-h2bW53APG4HvkOnVMo8q3QXa6pcaNt1HkwVsOPMBV6LD/q9oSpxNSYZQYkAnjdMjrJ86UuYeLo+aEZClV6opnw==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.7.0.tgz", + "integrity": "sha512-DApq0KJbJOEzAFYjHADNNxAE3KbhxQB1y5Kplb5Waqw6zVbuWatSnMjE5gs8FUgEPmNsnZA3NCWl9NG0ia04Pg==", "dev": true, + "license": "MIT", "dependencies": { "@bcoe/v8-coverage": "^0.2.3", - "@jest/console": "^26.6.2", - "@jest/test-result": "^26.6.2", - "@jest/transform": "^26.6.2", - "@jest/types": "^26.6.2", + "@jest/console": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "@types/node": "*", "chalk": "^4.0.0", "collect-v8-coverage": "^1.0.0", "exit": "^0.1.2", - "glob": "^7.1.2", - "graceful-fs": "^4.2.4", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", "istanbul-lib-coverage": "^3.0.0", - "istanbul-lib-instrument": "^4.0.3", + "istanbul-lib-instrument": "^6.0.0", "istanbul-lib-report": "^3.0.0", "istanbul-lib-source-maps": "^4.0.0", - "istanbul-reports": "^3.0.2", - "jest-haste-map": "^26.6.2", - "jest-resolve": "^26.6.2", - "jest-util": "^26.6.2", - "jest-worker": "^26.6.2", + "istanbul-reports": "^3.1.3", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", "slash": "^3.0.0", - "source-map": "^0.6.0", "string-length": "^4.0.1", - "terminal-link": "^2.0.0", - "v8-to-istanbul": "^7.0.0" + "strip-ansi": "^6.0.0", + "v8-to-istanbul": "^9.0.1" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" }, - "optionalDependencies": { - "node-notifier": "^8.0.0" + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/reporters/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/reporters/node_modules/@jest/transform": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-26.6.2.tgz", - "integrity": "sha512-E9JjhUgNzvuQ+vVAL21vlyfy12gP0GhazGgJC4h6qUt1jSdUXGWJ1wfu/X7Sd8etSgxV4ovT1pb9v5D6QW4XgA==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.7.0.tgz", + "integrity": "sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/core": "^7.1.0", - "@jest/types": "^26.6.2", - "babel-plugin-istanbul": "^6.0.0", + "@babel/core": "^7.11.6", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "babel-plugin-istanbul": "^6.1.1", "chalk": "^4.0.0", - "convert-source-map": "^1.4.0", - "fast-json-stable-stringify": "^2.0.0", - "graceful-fs": "^4.2.4", - "jest-haste-map": "^26.6.2", - "jest-regex-util": "^26.0.0", - "jest-util": "^26.6.2", - "micromatch": "^4.0.2", - "pirates": "^4.0.1", + "convert-source-map": "^2.0.0", + "fast-json-stable-stringify": "^2.1.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "micromatch": "^4.0.4", + "pirates": "^4.0.4", "slash": "^3.0.0", - "source-map": "^0.6.1", - "write-file-atomic": "^3.0.0" + "write-file-atomic": "^4.0.2" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/reporters/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/@jest/reporters/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/@jest/reporters/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/@jest/reporters/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -4351,6 +4563,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -4367,6 +4580,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -4378,83 +4592,108 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" + }, + "node_modules/@jest/reporters/node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" }, "node_modules/@jest/reporters/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/@jest/reporters/node_modules/istanbul-lib-instrument": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz", - "integrity": "sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz", + "integrity": "sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { - "@babel/core": "^7.7.5", - "@istanbuljs/schema": "^0.1.2", - "istanbul-lib-coverage": "^3.0.0", - "semver": "^6.3.0" + "@babel/core": "^7.23.9", + "@babel/parser": "^7.23.9", + "@istanbuljs/schema": "^0.1.3", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^7.5.4" }, "engines": { - "node": ">=8" + "node": ">=10" } }, "node_modules/@jest/reporters/node_modules/jest-haste-map": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-26.6.2.tgz", - "integrity": "sha512-easWIJXIw71B2RdR8kgqpjQrbMRWQBgiBwXYEhtGUTaX+doCjBheluShdDMeR8IMfJiTqH4+zfhtg29apJf/8w==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.7.0.tgz", + "integrity": "sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", - "@types/graceful-fs": "^4.1.2", + "@jest/types": "^29.6.3", + "@types/graceful-fs": "^4.1.3", "@types/node": "*", "anymatch": "^3.0.3", "fb-watchman": "^2.0.0", - "graceful-fs": "^4.2.4", - "jest-regex-util": "^26.0.0", - "jest-serializer": "^26.6.2", - "jest-util": "^26.6.2", - "jest-worker": "^26.6.2", - "micromatch": "^4.0.2", - "sane": "^4.0.3", - "walker": "^1.0.7" + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "micromatch": "^4.0.4", + "walker": "^1.0.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" }, "optionalDependencies": { - "fsevents": "^2.1.2" + "fsevents": "^2.3.2" } }, "node_modules/@jest/reporters/node_modules/jest-regex-util": { - "version": "26.0.0", - "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-26.0.0.tgz", - "integrity": "sha512-Gv3ZIs/nA48/Zvjrl34bf+oD76JHiGDUxNOVgUjh3j890sblXryjY4rss71fPtD/njchl6PSE2hIhvyWa1eT0A==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", "dev": true, + "license": "MIT", "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/reporters/node_modules/jest-util": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", - "integrity": "sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", - "is-ci": "^2.0.0", - "micromatch": "^4.0.2" + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/reporters/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" }, "engines": { - "node": ">= 10.14.2" + "node": ">=10" } }, "node_modules/@jest/reporters/node_modules/supports-color": { @@ -4462,6 +4701,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -4469,18 +4709,6 @@ "node": ">=8" } }, - "node_modules/@jest/reporters/node_modules/write-file-atomic": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", - "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", - "dev": true, - "dependencies": { - "imurmurhash": "^0.1.4", - "is-typedarray": "^1.0.0", - "signal-exit": "^3.0.2", - "typedarray-to-buffer": "^3.1.5" - } - }, "node_modules/@jest/schemas": { "version": "28.1.3", "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-28.1.3.tgz", @@ -4494,64 +4722,80 @@ } }, "node_modules/@jest/source-map": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-26.6.2.tgz", - "integrity": "sha512-YwYcCwAnNmOVsZ8mr3GfnzdXDAl4LaenZP5z+G0c8bzC9/dugL8zRmxZzdoTl4IaS3CryS1uWnROLPFmb6lVvA==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-29.6.3.tgz", + "integrity": "sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw==", "dev": true, + "license": "MIT", "dependencies": { + "@jridgewell/trace-mapping": "^0.3.18", "callsites": "^3.0.0", - "graceful-fs": "^4.2.4", - "source-map": "^0.6.0" + "graceful-fs": "^4.2.9" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/test-result": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-26.6.2.tgz", - "integrity": "sha512-5O7H5c/7YlojphYNrK02LlDIV2GNPYisKwHm2QTKjNZeEzezCbwYs9swJySv2UfPMyZ0VdsmMv7jIlD/IKYQpQ==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.7.0.tgz", + "integrity": "sha512-Fdx+tv6x1zlkJPcWXmMDAG2HBnaR9XPSd5aDWQVsfrZmLVT3lU1cwyxLgRmXR9yrq4NBoEm9BMsfgFzTQAbJYA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/console": "^26.6.2", - "@jest/types": "^26.6.2", + "@jest/console": "^29.7.0", + "@jest/types": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "collect-v8-coverage": "^1.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-result/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/test-result/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/@jest/test-result/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/@jest/test-result/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/@jest/test-result/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -4567,6 +4811,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -4583,6 +4828,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -4594,13 +4840,15 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@jest/test-result/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -4610,6 +4858,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -4618,51 +4867,65 @@ } }, "node_modules/@jest/test-sequencer": { - "version": "26.6.3", - "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-26.6.3.tgz", - "integrity": "sha512-YHlVIjP5nfEyjlrSr8t/YdNfU/1XEt7c5b4OxcXCjyRhjzLYu/rO69/WHPuYcbCWkz8kAeZVZp2N2+IOLLEPGw==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.7.0.tgz", + "integrity": "sha512-GQwJ5WZVrKnOJuiYiAF52UNUJXgTZx1NHjFSEB0qEMmSZKAkdMoIzw/Cj6x6NF4AvV23AUqDpFzQkN/eYCYTxw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/test-result": "^29.7.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-sequencer/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/test-result": "^26.6.2", - "graceful-fs": "^4.2.4", - "jest-haste-map": "^26.6.2", - "jest-runner": "^26.6.3", - "jest-runtime": "^26.6.3" + "@sinclair/typebox": "^0.27.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/test-sequencer/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/@jest/test-sequencer/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/@jest/test-sequencer/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/@jest/test-sequencer/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -4678,6 +4941,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -4694,6 +4958,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -4705,68 +4970,71 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@jest/test-sequencer/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/@jest/test-sequencer/node_modules/jest-haste-map": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-26.6.2.tgz", - "integrity": "sha512-easWIJXIw71B2RdR8kgqpjQrbMRWQBgiBwXYEhtGUTaX+doCjBheluShdDMeR8IMfJiTqH4+zfhtg29apJf/8w==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.7.0.tgz", + "integrity": "sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", - "@types/graceful-fs": "^4.1.2", + "@jest/types": "^29.6.3", + "@types/graceful-fs": "^4.1.3", "@types/node": "*", "anymatch": "^3.0.3", "fb-watchman": "^2.0.0", - "graceful-fs": "^4.2.4", - "jest-regex-util": "^26.0.0", - "jest-serializer": "^26.6.2", - "jest-util": "^26.6.2", - "jest-worker": "^26.6.2", - "micromatch": "^4.0.2", - "sane": "^4.0.3", - "walker": "^1.0.7" + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "micromatch": "^4.0.4", + "walker": "^1.0.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" }, "optionalDependencies": { - "fsevents": "^2.1.2" + "fsevents": "^2.3.2" } }, "node_modules/@jest/test-sequencer/node_modules/jest-regex-util": { - "version": "26.0.0", - "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-26.0.0.tgz", - "integrity": "sha512-Gv3ZIs/nA48/Zvjrl34bf+oD76JHiGDUxNOVgUjh3j890sblXryjY4rss71fPtD/njchl6PSE2hIhvyWa1eT0A==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", "dev": true, + "license": "MIT", "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/test-sequencer/node_modules/jest-util": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", - "integrity": "sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", - "is-ci": "^2.0.0", - "micromatch": "^4.0.2" + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/test-sequencer/node_modules/supports-color": { @@ -4774,6 +5042,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -4965,14 +5234,15 @@ } }, "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", - "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", + "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", "dev": true, + "license": "MIT", "dependencies": { - "@jridgewell/set-array": "^1.0.1", + "@jridgewell/set-array": "^1.2.1", "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.9" + "@jridgewell/trace-mapping": "^0.3.24" }, "engines": { "node": ">=6.0.0" @@ -4988,10 +5258,11 @@ } }, "node_modules/@jridgewell/set-array": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", - "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.0.0" } @@ -5003,21 +5274,16 @@ "dev": true }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.18", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz", - "integrity": "sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==", + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", "dev": true, + "license": "MIT", "dependencies": { - "@jridgewell/resolve-uri": "3.1.0", - "@jridgewell/sourcemap-codec": "1.4.14" + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", - "dev": true - }, "node_modules/@ladjs/country-language": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/@ladjs/country-language/-/country-language-0.2.1.tgz", @@ -6467,24 +6733,12 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.3.2.tgz", "integrity": "sha512-vOBLVQeCQfIcF/2Y7eKFTqrMnizK5lRNQ7ykML/5RuwVXVWxYkgwS7xbt4B6fKCUPgbSL5FSsjHQpaGQP/dQmw==" }, - "node_modules/@types/normalize-package-data": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz", - "integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==", - "dev": true - }, "node_modules/@types/parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", "dev": true }, - "node_modules/@types/prettier": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", - "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==", - "dev": true - }, "node_modules/@types/qs": { "version": "6.9.7", "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", @@ -6515,10 +6769,11 @@ } }, "node_modules/@types/stack-utils": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", - "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", - "dev": true + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", + "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==", + "dev": true, + "license": "MIT" }, "node_modules/@types/superagent": { "version": "4.1.13", @@ -6919,33 +7174,6 @@ "sprintf-js": "~1.0.2" } }, - "node_modules/arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/arr-flatten": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/arr-union": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/array-buffer-byte-length": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz", @@ -6979,15 +7207,6 @@ "node": ">=8" } }, - "node_modules/array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha512-SleRWjh9JUud2wH1hPs9rZBZ33H6T9HOiL0uwGnGx9FpE6wKGyfWugmbkEOIs6qWrZhg0LWeLziLrEwQJhs5mQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/array.prototype.reduce": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/array.prototype.reduce/-/array.prototype.reduce-1.0.5.tgz", @@ -7048,15 +7267,6 @@ "node": "*" } }, - "node_modules/assign-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", - "integrity": "sha512-Q+JC7Whu8HhmTdBph/Tq59IoRtoy6KAm5zzPv00WdujX82lbAL8K7WVjne7vdCsAmbF4AYaDOPyO3k0kl8qIrw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/astral-regex": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", @@ -7095,18 +7305,6 @@ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, - "node_modules/atob": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", - "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", - "dev": true, - "bin": { - "atob": "bin/atob.js" - }, - "engines": { - "node": ">= 4.5.0" - } - }, "node_modules/available-typed-arrays": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", @@ -7581,36 +7779,6 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, - "node_modules/base": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", - "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", - "dev": true, - "dependencies": { - "cache-base": "^1.0.1", - "class-utils": "^0.3.5", - "component-emitter": "^1.2.1", - "define-property": "^1.0.0", - "isobject": "^3.0.1", - "mixin-deep": "^1.2.0", - "pascalcase": "^0.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/base/node_modules/define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==", - "dev": true, - "dependencies": { - "is-descriptor": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -7852,9 +8020,9 @@ "integrity": "sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==" }, "node_modules/browserslist": { - "version": "4.21.9", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.9.tgz", - "integrity": "sha512-M0MFoZzbUrRU4KNfCrDLnvyE7gub+peetoTid3TBIqtunaDJyXlwhakT+/VkvSXcfIzFfK/nkCs4nmyTmxdNSg==", + "version": "4.24.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.2.tgz", + "integrity": "sha512-ZIc+Q62revdMcqC6aChtW4jz3My3klmCO1fEmINZY/8J3EpBg5/A/D0AKmBveUh6pgoeycoMkVMko84tuYS+Gg==", "dev": true, "funding": [ { @@ -7870,11 +8038,12 @@ "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "dependencies": { - "caniuse-lite": "^1.0.30001503", - "electron-to-chromium": "^1.4.431", - "node-releases": "^2.0.12", - "update-browserslist-db": "^1.0.11" + "caniuse-lite": "^1.0.30001669", + "electron-to-chromium": "^1.5.41", + "node-releases": "^2.0.18", + "update-browserslist-db": "^1.1.1" }, "bin": { "browserslist": "cli.js" @@ -8072,26 +8241,6 @@ "node": ">= 0.8" } }, - "node_modules/cache-base": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", - "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", - "dev": true, - "dependencies": { - "collection-visit": "^1.0.0", - "component-emitter": "^1.2.1", - "get-value": "^2.0.6", - "has-value": "^1.0.0", - "isobject": "^3.0.1", - "set-value": "^2.0.0", - "to-object-path": "^0.3.0", - "union-value": "^1.0.0", - "unset-value": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/call-bind": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", @@ -8134,9 +8283,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001508", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001508.tgz", - "integrity": "sha512-sdQZOJdmt3GJs1UMNpCCCyeuS2IEGLXnHyAo9yIO5JJDjbjoVRij4M1qep6P6gFpptD1PqIYgzM+gwJbOi92mw==", + "version": "1.0.30001677", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001677.tgz", + "integrity": "sha512-fmfjsOlJUpMWu+mAAtZZZHz7UEwsUxIIvu1TJfO1HqFQvB/B+ii0xr9B5HpbZY/mC4XZ8SvjHJqtAY6pDPQEog==", "dev": true, "funding": [ { @@ -8151,19 +8300,8 @@ "type": "github", "url": "https://github.com/sponsors/ai" } - ] - }, - "node_modules/capture-exit": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/capture-exit/-/capture-exit-2.0.0.tgz", - "integrity": "sha512-PiT/hQmTonHhl/HFGN+Lx3JJUznrVYJ3+AQsnthneZbvW7x+f08Tk7yLJTLEOUvBTbduLeeBkxEaYXUOUrRq6g==", - "dev": true, - "dependencies": { - "rsvp": "^4.8.4" - }, - "engines": { - "node": "6.* || 8.* || >= 10.*" - } + ], + "license": "CC-BY-4.0" }, "node_modules/caseless": { "version": "0.12.0", @@ -8247,6 +8385,7 @@ "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" } @@ -8473,114 +8612,26 @@ "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" }, "node_modules/ci-info": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", - "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==", - "dev": true - }, - "node_modules/cjs-module-lexer": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-0.6.0.tgz", - "integrity": "sha512-uc2Vix1frTfnuzxxu1Hp4ktSvM3QaI4oXl4ZUqL1wjTu/BGki9TrCWoqLTg/drR1KwAEarXuRFCG2Svr1GxPFw==", - "dev": true - }, - "node_modules/class-utils": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", - "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", - "dev": true, - "dependencies": { - "arr-union": "^3.1.0", - "define-property": "^0.2.5", - "isobject": "^3.0.0", - "static-extend": "^0.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/class-utils/node_modules/define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", - "dev": true, - "dependencies": { - "is-descriptor": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/class-utils/node_modules/is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==", - "dev": true, - "dependencies": { - "kind-of": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/class-utils/node_modules/is-accessor-descriptor/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", - "dev": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/class-utils/node_modules/is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==", - "dev": true, - "dependencies": { - "kind-of": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/class-utils/node_modules/is-data-descriptor/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", - "dev": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/class-utils/node_modules/is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "dependencies": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - }, + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "license": "MIT", "engines": { - "node": ">=0.10.0" + "node": ">=8" } }, - "node_modules/class-utils/node_modules/kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "node_modules/cjs-module-lexer": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.4.1.tgz", + "integrity": "sha512-cuSVIHi9/9E/+821Qjdvngor+xpnlwnuwIyZOaLmHBVdXL+gP+I6QQB9VkO7RI77YIcTV+S1W9AreJ5eN63JBA==", "dev": true, - "engines": { - "node": ">=0.10.0" - } + "license": "MIT" }, "node_modules/clean-stack": { "version": "2.2.0", @@ -8620,61 +8671,17 @@ } }, "node_modules/cliui": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", - "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", - "dev": true, + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "license": "ISC", "dependencies": { "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^6.2.0" - } - }, - "node_modules/cliui/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/cliui/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/cliui/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/cliui/node_modules/wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" }, "engines": { - "node": ">=8" + "node": ">=12" } }, "node_modules/clone": { @@ -8755,29 +8762,18 @@ "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", "dev": true, + "license": "MIT", "engines": { "iojs": ">= 1.0.0", "node": ">= 0.12.0" } }, "node_modules/collect-v8-coverage": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz", - "integrity": "sha512-iBPtljfCNcTKNAto0KEtDfZ3qzjJvqE3aTGZsbhjSBlorqpXJlaWWtPO35D+ZImoC3KWejX64o+yPGxhWSTzfg==", - "dev": true - }, - "node_modules/collection-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", - "integrity": "sha512-lNkKvzEeMBBjUGHZ+q6z9pSJla0KWAQPvtzhEV9+iGyQYG+pBpl7xKDhxoNSOZH2hhv0v5k0y2yAM4o4SjoSkw==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz", + "integrity": "sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==", "dev": true, - "dependencies": { - "map-visit": "^1.0.0", - "object-visit": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } + "license": "MIT" }, "node_modules/color": { "version": "3.2.1", @@ -8952,15 +8948,6 @@ "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==" }, - "node_modules/copy-descriptor": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", - "integrity": "sha512-XgZ0pFcakEUlbwQEVNg3+QAis1FyTL3Qel9FYy8pSkQqoG3PNoT0bOCQtOXcOkur21r2Eq2kI+IE+gsmAEVlYw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/core-js": { "version": "3.31.0", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.31.0.tgz", @@ -9040,6 +9027,160 @@ "node": ">= 10" } }, + "node_modules/create-jest": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz", + "integrity": "sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-config": "^29.7.0", + "jest-util": "^29.7.0", + "prompts": "^2.0.1" + }, + "bin": { + "create-jest": "bin/create-jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/create-jest/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/create-jest/node_modules/@jest/types": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/schemas": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/create-jest/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", + "dev": true, + "license": "MIT" + }, + "node_modules/create-jest/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/create-jest/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/create-jest/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/create-jest/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/create-jest/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/create-jest/node_modules/jest-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/create-jest/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/cron-parser": { "version": "2.18.0", "resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-2.18.0.tgz", @@ -9295,15 +9436,6 @@ "node": "*" } }, - "node_modules/decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/decimal.js": { "version": "10.4.3", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", @@ -9394,19 +9526,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/define-property": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", - "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", - "dev": true, - "dependencies": { - "is-descriptor": "^1.0.2", - "isobject": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -9512,12 +9631,13 @@ } }, "node_modules/diff-sequences": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-26.6.2.tgz", - "integrity": "sha512-Mv/TDa3nZ9sbc5soK+OoA74BsS3mL37yixCvUAQkiuA4Wz6YtwP/K47n2rv2ovzHZvoiQeA5FTQOschKkEwB0Q==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", + "integrity": "sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==", "dev": true, + "license": "MIT", "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/discontinuous-range": { @@ -9746,10 +9866,11 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.442", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.442.tgz", - "integrity": "sha512-RkrZF//Ya+0aJq2NM3OdisNh5ZodZq1rdXOS96G8DdDgpDKqKE81yTbbQ3F/4CKm1JBPsGu1Lp/akkna2xO06Q==", - "dev": true + "version": "1.5.51", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.51.tgz", + "integrity": "sha512-kKeWV57KSS8jH4alKt/jKnvHPmJgBxXzGUSbMd4eQF+iOsVPl7bz2KUmu6eo80eMP8wVioTfTyTzdMgM15WXNg==", + "dev": true, + "license": "ISC" }, "node_modules/email-templates": { "version": "8.1.0", @@ -9772,12 +9893,13 @@ } }, "node_modules/emittery": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.7.2.tgz", - "integrity": "sha512-A8OG5SR/ij3SsJdWDJdkkSYUjQdCUx6APQXem0SaEePBSRg4eymGYwBkKo1Y6DU+af/Jn2dBQqDBvjnr9Vi8nQ==", + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz", + "integrity": "sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==", "dev": true, + "license": "MIT", "engines": { - "node": ">=10" + "node": ">=12" }, "funding": { "url": "https://github.com/sindresorhus/emittery?sponsor=1" @@ -9964,9 +10086,10 @@ "integrity": "sha512-SOp9Phqvqn7jtEUxPWdWfWoLmyt2VaJ6MpvP9Comy1MceMXqE6bxvaTu4iaxpYYPzhny28Lc+M87/c2cPK6lDg==" }, "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "license": "MIT", "engines": { "node": ">=6" } @@ -10533,12 +10656,6 @@ "node": ">=8.3.0" } }, - "node_modules/exec-sh": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/exec-sh/-/exec-sh-0.3.6.tgz", - "integrity": "sha512-nQn+hI3yp+oD0huYhKwvYI32+JFeq+XkNcD1GAo3Y/MjxsfVGmrrzrnzjWiNY6f+pUCP440fThsFh5gZrRAU/w==", - "dev": true - }, "node_modules/execa": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/execa/-/execa-4.1.0.tgz", @@ -10571,190 +10688,67 @@ "node": ">= 0.8.0" } }, - "node_modules/expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha512-w/ozOKR9Obk3qoWeY/WDi6MFta9AoMR+zud60mdnbniMcBxRuFJyDt2LdX/14A1UABeqk+Uk+LDfUpvoGKppZA==", - "dev": true, - "dependencies": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/expand-brackets/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/expand-brackets/node_modules/define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", - "dev": true, - "dependencies": { - "is-descriptor": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/expand-brackets/node_modules/extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", - "dev": true, - "dependencies": { - "is-extendable": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/expand-brackets/node_modules/is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==", - "dev": true, - "dependencies": { - "kind-of": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/expand-brackets/node_modules/is-accessor-descriptor/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", - "dev": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/expand-brackets/node_modules/is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==", - "dev": true, - "dependencies": { - "kind-of": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/expand-brackets/node_modules/is-data-descriptor/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", - "dev": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/expand-brackets/node_modules/is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "node_modules/expect": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.7.0.tgz", + "integrity": "sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==", "dev": true, + "license": "MIT", "dependencies": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" + "@jest/expect-utils": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0" }, "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/expand-brackets/node_modules/is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/expand-brackets/node_modules/kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true, - "engines": { - "node": ">=0.10.0" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/expand-brackets/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "dev": true - }, - "node_modules/expect": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/expect/-/expect-26.6.2.tgz", - "integrity": "sha512-9/hlOBkQl2l/PLHJx6JjoDF6xPKcJEsUlWKb23rKE7KzeDqUZKXKNMW27KIue5JMdBV9HgmoJPcc8HtO85t9IA==", + "node_modules/expect/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", - "ansi-styles": "^4.0.0", - "jest-get-type": "^26.3.0", - "jest-matcher-utils": "^26.6.2", - "jest-message-util": "^26.6.2", - "jest-regex-util": "^26.0.0" + "@sinclair/typebox": "^0.27.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/expect/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/expect/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/expect/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/expect/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -10770,6 +10764,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -10786,6 +10781,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -10797,24 +10793,35 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/expect/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, - "node_modules/expect/node_modules/jest-regex-util": { - "version": "26.0.0", - "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-26.0.0.tgz", - "integrity": "sha512-Gv3ZIs/nA48/Zvjrl34bf+oD76JHiGDUxNOVgUjh3j890sblXryjY4rss71fPtD/njchl6PSE2hIhvyWa1eT0A==", + "node_modules/expect/node_modules/jest-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/expect/node_modules/supports-color": { @@ -10822,6 +10829,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -10972,88 +10980,23 @@ "resolved": "https://registry.npmjs.org/extend-object/-/extend-object-1.0.0.tgz", "integrity": "sha512-0dHDIXC7y7LDmCh/lp1oYkmv73K25AMugQI07r8eFopkW6f7Ufn1q+ETMsJjnV9Am14SlElkqy3O92r6xEaxPw==" }, - "node_modules/extend-shallow": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", - "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", - "dev": true, + "node_modules/extract-zip": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", + "integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==", "dependencies": { - "assign-symbols": "^1.0.0", - "is-extendable": "^1.0.1" + "debug": "^4.1.1", + "get-stream": "^5.1.0", + "yauzl": "^2.10.0" }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "dependencies": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" + "bin": { + "extract-zip": "cli.js" }, "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/extglob/node_modules/define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==", - "dev": true, - "dependencies": { - "is-descriptor": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/extglob/node_modules/extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", - "dev": true, - "dependencies": { - "is-extendable": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/extglob/node_modules/is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/extract-zip": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", - "integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==", - "dependencies": { - "debug": "^4.1.1", - "get-stream": "^5.1.0", - "yauzl": "^2.10.0" - }, - "bin": { - "extract-zip": "cli.js" - }, - "engines": { - "node": ">= 10.17.0" - }, - "optionalDependencies": { - "@types/yauzl": "^2.9.1" + "node": ">= 10.17.0" + }, + "optionalDependencies": { + "@types/yauzl": "^2.9.1" } }, "node_modules/extsprintf": { @@ -11384,15 +11327,6 @@ "is-callable": "^1.1.3" } }, - "node_modules/for-in": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -11436,18 +11370,6 @@ "node": ">= 0.6" } }, - "node_modules/fragment-cache": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", - "integrity": "sha512-GMBAbW9antB8iZRHLoGw0b3HANt57diZYFO/HL1JGIC1MjKrdmhxvrJbupnVvpys0zsz7yBApXdQyfepKly2kA==", - "dev": true, - "dependencies": { - "map-cache": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", @@ -11836,15 +11758,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/get-value": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", - "integrity": "sha512-Ln0UQDlxH1BapMu3GPtf7CuYNwRZf2gwCuPqbyG6pB8WfmFpzqcy4xtAaAMUhnNqjMKTiCPZG2oMT3YSx8U2NA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/getopts": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/getopts/-/getopts-2.3.0.tgz", @@ -12050,13 +11963,6 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" }, - "node_modules/growly": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz", - "integrity": "sha512-+xGQY0YyAWCnqy7Cd++hc2JqMYzlm0dG30Jd0beaA64sROr8C4nt8Yc9V5Ro3avlSUDTN0ulqP/VBKi1/lLygw==", - "dev": true, - "optional": true - }, "node_modules/gtoken": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-5.3.2.tgz", @@ -12256,69 +12162,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/has-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", - "integrity": "sha512-IBXk4GTsLYdQ7Rvt+GRBrFSVEkmuOUy4re0Xjd9kJSUQpnTrWR4/y9RpfexN9vkAPMFuQoeWKwqzPozRTlasGw==", - "dev": true, - "dependencies": { - "get-value": "^2.0.6", - "has-values": "^1.0.0", - "isobject": "^3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/has-values": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", - "integrity": "sha512-ODYZC64uqzmtfGMEAX/FvZiRyWLpAC3vYnNunURUnkGVTS+mI0smVsWaPydRBsE3g+ok7h960jChO8mFcWlHaQ==", - "dev": true, - "dependencies": { - "is-number": "^3.0.0", - "kind-of": "^4.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/has-values/node_modules/is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==", - "dev": true, - "dependencies": { - "kind-of": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/has-values/node_modules/is-number/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", - "dev": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/has-values/node_modules/kind-of": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha512-24XsCxmEbRwEDbz/qz3stgin8TTzZ1ESR56OMCN0ujYg+vRutNSiOj9bHH9u85DKgXguraugV5sFuvbD4FW/hw==", - "dev": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/hasown": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", @@ -12386,12 +12229,6 @@ "node": ">=8" } }, - "node_modules/hosted-git-info": { - "version": "2.8.9", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", - "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", - "dev": true - }, "node_modules/html-encoding-sniffer": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz", @@ -12407,7 +12244,8 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/html-to-text": { "version": "8.2.1", @@ -12712,10 +12550,11 @@ } }, "node_modules/import-local": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", - "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.2.0.tgz", + "integrity": "sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA==", "dev": true, + "license": "MIT", "dependencies": { "pkg-dir": "^4.2.0", "resolve-cwd": "^3.0.0" @@ -12857,18 +12696,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "dependencies": { - "kind-of": "^6.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-array-buffer": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.2.tgz", @@ -12943,18 +12770,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-ci": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-2.0.0.tgz", - "integrity": "sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==", - "dev": true, - "dependencies": { - "ci-info": "^2.0.0" - }, - "bin": { - "is-ci": "bin.js" - } - }, "node_modules/is-core-module": { "version": "2.12.1", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.1.tgz", @@ -12966,18 +12781,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "dependencies": { - "kind-of": "^6.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-date-object": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz", @@ -12992,20 +12795,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "dependencies": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-docker": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", @@ -13029,18 +12818,6 @@ "object-assign": "^4.1.1" } }, - "node_modules/is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "dependencies": { - "is-plain-object": "^2.0.4" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -13063,6 +12840,7 @@ "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } @@ -13166,18 +12944,6 @@ "node": ">=8" } }, - "node_modules/is-plain-object": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "dev": true, - "dependencies": { - "isobject": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-potential-custom-element-name": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", @@ -13376,15 +13142,6 @@ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" }, - "node_modules/isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -13416,17 +13173,18 @@ } }, "node_modules/istanbul-lib-report": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", - "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "istanbul-lib-coverage": "^3.0.0", - "make-dir": "^3.0.0", + "make-dir": "^4.0.0", "supports-color": "^7.1.0" }, "engines": { - "node": ">=8" + "node": ">=10" } }, "node_modules/istanbul-lib-report/node_modules/has-flag": { @@ -13434,6 +13192,7 @@ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -13443,6 +13202,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -13455,6 +13215,7 @@ "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "debug": "^4.1.1", "istanbul-lib-coverage": "^3.0.0", @@ -13465,10 +13226,11 @@ } }, "node_modules/istanbul-reports": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", - "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz", + "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "html-escaper": "^2.0.0", "istanbul-lib-report": "^3.0.0" @@ -13478,66 +13240,91 @@ } }, "node_modules/jest": { - "version": "26.6.3", - "resolved": "https://registry.npmjs.org/jest/-/jest-26.6.3.tgz", - "integrity": "sha512-lGS5PXGAzR4RF7V5+XObhqz2KZIDUA1yD0DG6pBVmy10eh0ZIXQImRuzocsI/N2XZ1GrLFwTS27In2i2jlpq1Q==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", + "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/core": "^26.6.3", + "@jest/core": "^29.7.0", + "@jest/types": "^29.6.3", "import-local": "^3.0.2", - "jest-cli": "^26.6.3" + "jest-cli": "^29.7.0" }, "bin": { "jest": "bin/jest.js" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } } }, "node_modules/jest-changed-files": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-26.6.2.tgz", - "integrity": "sha512-fDS7szLcY9sCtIip8Fjry9oGf3I2ht/QT21bAHm5Dmf0mD4X3ReNUf17y+bO6fR8WgbIZTlbyG1ak/53cbRzKQ==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.7.0.tgz", + "integrity": "sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w==", + "dev": true, + "license": "MIT", + "dependencies": { + "execa": "^5.0.0", + "jest-util": "^29.7.0", + "p-limit": "^3.1.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-changed-files/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", - "execa": "^4.0.0", - "throat": "^5.0.0" + "@sinclair/typebox": "^0.27.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-changed-files/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-changed-files/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/jest-changed-files/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/jest-changed-files/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -13553,6 +13340,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -13569,6 +13357,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -13580,86 +13369,386 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" + }, + "node_modules/jest-changed-files/node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/jest-changed-files/node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, "node_modules/jest-changed-files/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, - "node_modules/jest-changed-files/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "node_modules/jest-changed-files/node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, + "license": "Apache-2.0", "engines": { - "node": ">=8" + "node": ">=10.17.0" } }, - "node_modules/jest-cli": { - "version": "26.6.3", - "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-26.6.3.tgz", - "integrity": "sha512-GF9noBSa9t08pSyl3CY4frMrqp+aQXFGFkf5hEPbh/pIUFYWMK6ZLTfbmadxJVcJrdRoChlWQsA2VkJcDFK8hg==", + "node_modules/jest-changed-files/node_modules/jest-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/core": "^26.6.3", - "@jest/test-result": "^26.6.2", - "@jest/types": "^26.6.2", + "@jest/types": "^29.6.3", + "@types/node": "*", "chalk": "^4.0.0", - "exit": "^0.1.2", - "graceful-fs": "^4.2.4", - "import-local": "^3.0.2", - "is-ci": "^2.0.0", - "jest-config": "^26.6.3", - "jest-util": "^26.6.2", - "jest-validate": "^26.6.2", - "prompts": "^2.0.1", - "yargs": "^15.4.1" - }, - "bin": { - "jest": "bin/jest.js" + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-cli/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "node_modules/jest-changed-files/node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", "dev": true, + "license": "MIT", "dependencies": { - "@types/istanbul-lib-coverage": "^2.0.0", - "@types/istanbul-reports": "^3.0.0", - "@types/node": "*", - "@types/yargs": "^15.0.0", - "chalk": "^4.0.0" + "yocto-queue": "^0.1.0" }, "engines": { - "node": ">= 10.14.2" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/jest-cli/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/jest-changed-files/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { - "@types/yargs-parser": "*" + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-circus": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.7.0.tgz", + "integrity": "sha512-3E1nCMgipcTkCocFwM90XXQab9bS+GMsjdpmPrlelaxwD93Ad8iVEjX/vvHPdLPnFf+L40u+5+iutRdA1N9myw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/expect": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "co": "^4.6.0", + "dedent": "^1.0.0", + "is-generator-fn": "^2.0.0", + "jest-each": "^29.7.0", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "p-limit": "^3.1.0", + "pretty-format": "^29.7.0", + "pure-rand": "^6.0.0", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-circus/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-circus/node_modules/@jest/types": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/schemas": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-circus/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", + "dev": true, + "license": "MIT" + }, + "node_modules/jest-circus/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/jest-circus/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/jest-circus/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/jest-circus/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/jest-circus/node_modules/dedent": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.3.tgz", + "integrity": "sha512-NHQtfOOW68WD8lgypbLA5oT+Bt0xXJhiYvoR6SmmNXZfpzOGXwdKWmcwG8N7PwVVWV3eF/68nmD9BaJSsTBhyQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "babel-plugin-macros": "^3.1.0" + }, + "peerDependenciesMeta": { + "babel-plugin-macros": { + "optional": true + } + } + }, + "node_modules/jest-circus/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-circus/node_modules/jest-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-circus/node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/jest-circus/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" } }, + "node_modules/jest-cli": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.7.0.tgz", + "integrity": "sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/core": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "create-jest": "^29.7.0", + "exit": "^0.1.2", + "import-local": "^3.0.2", + "jest-config": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "yargs": "^17.3.1" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-cli/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-cli/node_modules/@jest/types": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/schemas": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-cli/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", + "dev": true, + "license": "MIT" + }, "node_modules/jest-cli/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -13675,6 +13764,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -13691,6 +13781,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -13702,32 +13793,35 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/jest-cli/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/jest-cli/node_modules/jest-util": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", - "integrity": "sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", - "is-ci": "^2.0.0", - "micromatch": "^4.0.2" + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-cli/node_modules/supports-color": { @@ -13735,6 +13829,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -13743,98 +13838,122 @@ } }, "node_modules/jest-config": { - "version": "26.6.3", - "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-26.6.3.tgz", - "integrity": "sha512-t5qdIj/bCj2j7NFVHb2nFB4aUdfucDn3JRKgrZnplb8nieAirAzRSHP8uDEd+qV6ygzg9Pz4YG7UTJf94LPSyg==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.7.0.tgz", + "integrity": "sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/core": "^7.1.0", - "@jest/test-sequencer": "^26.6.3", - "@jest/types": "^26.6.2", - "babel-jest": "^26.6.3", + "@babel/core": "^7.11.6", + "@jest/test-sequencer": "^29.7.0", + "@jest/types": "^29.6.3", + "babel-jest": "^29.7.0", "chalk": "^4.0.0", + "ci-info": "^3.2.0", "deepmerge": "^4.2.2", - "glob": "^7.1.1", - "graceful-fs": "^4.2.4", - "jest-environment-jsdom": "^26.6.2", - "jest-environment-node": "^26.6.2", - "jest-get-type": "^26.3.0", - "jest-jasmine2": "^26.6.3", - "jest-regex-util": "^26.0.0", - "jest-resolve": "^26.6.2", - "jest-util": "^26.6.2", - "jest-validate": "^26.6.2", - "micromatch": "^4.0.2", - "pretty-format": "^26.6.2" + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-circus": "^29.7.0", + "jest-environment-node": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-runner": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "micromatch": "^4.0.4", + "parse-json": "^5.2.0", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "strip-json-comments": "^3.1.1" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" }, "peerDependencies": { + "@types/node": "*", "ts-node": ">=9.0.0" }, "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, "ts-node": { "optional": true } } }, + "node_modules/jest-config/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, "node_modules/jest-config/node_modules/@jest/transform": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-26.6.2.tgz", - "integrity": "sha512-E9JjhUgNzvuQ+vVAL21vlyfy12gP0GhazGgJC4h6qUt1jSdUXGWJ1wfu/X7Sd8etSgxV4ovT1pb9v5D6QW4XgA==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.7.0.tgz", + "integrity": "sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/core": "^7.1.0", - "@jest/types": "^26.6.2", - "babel-plugin-istanbul": "^6.0.0", + "@babel/core": "^7.11.6", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "babel-plugin-istanbul": "^6.1.1", "chalk": "^4.0.0", - "convert-source-map": "^1.4.0", - "fast-json-stable-stringify": "^2.0.0", - "graceful-fs": "^4.2.4", - "jest-haste-map": "^26.6.2", - "jest-regex-util": "^26.0.0", - "jest-util": "^26.6.2", - "micromatch": "^4.0.2", - "pirates": "^4.0.1", + "convert-source-map": "^2.0.0", + "fast-json-stable-stringify": "^2.1.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "micromatch": "^4.0.4", + "pirates": "^4.0.4", "slash": "^3.0.0", - "source-map": "^0.6.1", - "write-file-atomic": "^3.0.0" + "write-file-atomic": "^4.0.2" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-config/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-config/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/jest-config/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/jest-config/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -13846,53 +13965,55 @@ } }, "node_modules/jest-config/node_modules/babel-jest": { - "version": "26.6.3", - "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-26.6.3.tgz", - "integrity": "sha512-pl4Q+GAVOHwvjrck6jKjvmGhnO3jHX/xuB9d27f+EJZ/6k+6nMuPjorrYp7s++bKKdANwzElBWnLWaObvTnaZA==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz", + "integrity": "sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/transform": "^26.6.2", - "@jest/types": "^26.6.2", - "@types/babel__core": "^7.1.7", - "babel-plugin-istanbul": "^6.0.0", - "babel-preset-jest": "^26.6.2", + "@jest/transform": "^29.7.0", + "@types/babel__core": "^7.1.14", + "babel-plugin-istanbul": "^6.1.1", + "babel-preset-jest": "^29.6.3", "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", + "graceful-fs": "^4.2.9", "slash": "^3.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" }, "peerDependencies": { - "@babel/core": "^7.0.0" + "@babel/core": "^7.8.0" } }, "node_modules/jest-config/node_modules/babel-plugin-jest-hoist": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-26.6.2.tgz", - "integrity": "sha512-PO9t0697lNTmcEHH69mdtYiOIkkOlj9fySqfO3K1eCcdISevLAE0xY59VLLUj0SoiPiTX/JU2CYFpILydUa5Lw==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.6.3.tgz", + "integrity": "sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg==", "dev": true, + "license": "MIT", "dependencies": { "@babel/template": "^7.3.3", "@babel/types": "^7.3.3", - "@types/babel__core": "^7.0.0", + "@types/babel__core": "^7.1.14", "@types/babel__traverse": "^7.0.6" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-config/node_modules/babel-preset-jest": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-26.6.2.tgz", - "integrity": "sha512-YvdtlVm9t3k777c5NPQIv6cxFFFapys25HiUmuSgHwIZhfifweR5c5Sf5nwE3MAbfu327CYSvps8Yx6ANLyleQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-29.6.3.tgz", + "integrity": "sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA==", "dev": true, + "license": "MIT", "dependencies": { - "babel-plugin-jest-hoist": "^26.6.2", + "babel-plugin-jest-hoist": "^29.6.3", "babel-preset-current-node-syntax": "^1.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" }, "peerDependencies": { "@babel/core": "^7.0.0" @@ -13903,6 +14024,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -13919,6 +14041,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -13930,68 +14053,78 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" + }, + "node_modules/jest-config/node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" }, "node_modules/jest-config/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/jest-config/node_modules/jest-haste-map": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-26.6.2.tgz", - "integrity": "sha512-easWIJXIw71B2RdR8kgqpjQrbMRWQBgiBwXYEhtGUTaX+doCjBheluShdDMeR8IMfJiTqH4+zfhtg29apJf/8w==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.7.0.tgz", + "integrity": "sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", - "@types/graceful-fs": "^4.1.2", + "@jest/types": "^29.6.3", + "@types/graceful-fs": "^4.1.3", "@types/node": "*", "anymatch": "^3.0.3", "fb-watchman": "^2.0.0", - "graceful-fs": "^4.2.4", - "jest-regex-util": "^26.0.0", - "jest-serializer": "^26.6.2", - "jest-util": "^26.6.2", - "jest-worker": "^26.6.2", - "micromatch": "^4.0.2", - "sane": "^4.0.3", - "walker": "^1.0.7" + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "micromatch": "^4.0.4", + "walker": "^1.0.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" }, "optionalDependencies": { - "fsevents": "^2.1.2" + "fsevents": "^2.3.2" } }, "node_modules/jest-config/node_modules/jest-regex-util": { - "version": "26.0.0", - "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-26.0.0.tgz", - "integrity": "sha512-Gv3ZIs/nA48/Zvjrl34bf+oD76JHiGDUxNOVgUjh3j890sblXryjY4rss71fPtD/njchl6PSE2hIhvyWa1eT0A==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", "dev": true, + "license": "MIT", "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-config/node_modules/jest-util": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", - "integrity": "sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", - "is-ci": "^2.0.0", - "micromatch": "^4.0.2" + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-config/node_modules/supports-color": { @@ -13999,6 +14132,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -14006,31 +14140,20 @@ "node": ">=8" } }, - "node_modules/jest-config/node_modules/write-file-atomic": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", - "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", - "dev": true, - "dependencies": { - "imurmurhash": "^0.1.4", - "is-typedarray": "^1.0.0", - "signal-exit": "^3.0.2", - "typedarray-to-buffer": "^3.1.5" - } - }, "node_modules/jest-diff": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-26.6.2.tgz", - "integrity": "sha512-6m+9Z3Gv9wN0WFVasqjCL/06+EFCMTqDEUl/b87HYK2rAPTyfz4ZIuSlPhY51PIQRWx5TaxeF1qmXKe9gfN3sA==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.7.0.tgz", + "integrity": "sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==", "dev": true, + "license": "MIT", "dependencies": { "chalk": "^4.0.0", - "diff-sequences": "^26.6.2", - "jest-get-type": "^26.3.0", - "pretty-format": "^26.6.2" + "diff-sequences": "^29.6.3", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-diff/node_modules/ansi-styles": { @@ -14038,6 +14161,7 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -14053,6 +14177,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -14069,6 +14194,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -14080,13 +14206,15 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/jest-diff/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -14096,6 +14224,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -14104,63 +14233,79 @@ } }, "node_modules/jest-docblock": { - "version": "26.0.0", - "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-26.0.0.tgz", - "integrity": "sha512-RDZ4Iz3QbtRWycd8bUEPxQsTlYazfYn/h5R65Fc6gOfwozFhoImx+affzky/FFBuqISPTqjXomoIGJVKBWoo0w==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-29.7.0.tgz", + "integrity": "sha512-q617Auw3A612guyaFgsbFeYpNP5t2aoUNLwBUbc/0kD1R4t9ixDbyFTHd1nok4epoVFpr7PmeWHrhvuV3XaJ4g==", "dev": true, + "license": "MIT", "dependencies": { "detect-newline": "^3.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-each": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-26.6.2.tgz", - "integrity": "sha512-Mer/f0KaATbjl8MCJ+0GEpNdqmnVmDYqCTJYTvoo7rqmRiDllmp2AYN+06F93nXcY3ur9ShIjS+CO/uD+BbH4A==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-29.7.0.tgz", + "integrity": "sha512-gns+Er14+ZrEoC5fhOfYCY1LOHHr0TI+rQUHZS8Ttw2l7gl+80eHc/gFf2Ktkw0+SIACDTeWvpFcv3B04VembQ==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", + "@jest/types": "^29.6.3", "chalk": "^4.0.0", - "jest-get-type": "^26.3.0", - "jest-util": "^26.6.2", - "pretty-format": "^26.6.2" + "jest-get-type": "^29.6.3", + "jest-util": "^29.7.0", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-each/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-each/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-each/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/jest-each/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/jest-each/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -14176,6 +14321,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -14192,6 +14338,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -14203,32 +14350,35 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/jest-each/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/jest-each/node_modules/jest-util": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", - "integrity": "sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", - "is-ci": "^2.0.0", - "micromatch": "^4.0.2" + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-each/node_modules/supports-color": { @@ -14236,6 +14386,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -14243,183 +14394,68 @@ "node": ">=8" } }, - "node_modules/jest-environment-jsdom": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-environment-jsdom/-/jest-environment-jsdom-26.6.2.tgz", - "integrity": "sha512-jgPqCruTlt3Kwqg5/WVFyHIOJHsiAvhcp2qiR2QQstuG9yWox5+iHpU3ZrcBxW14T4fe5Z68jAfLRh7joCSP2Q==", + "node_modules/jest-environment-node": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.7.0.tgz", + "integrity": "sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/environment": "^26.6.2", - "@jest/fake-timers": "^26.6.2", - "@jest/types": "^26.6.2", + "@jest/environment": "^29.7.0", + "@jest/fake-timers": "^29.7.0", + "@jest/types": "^29.6.3", "@types/node": "*", - "jest-mock": "^26.6.2", - "jest-util": "^26.6.2", - "jsdom": "^16.4.0" + "jest-mock": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-environment-node/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-environment-jsdom/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "node_modules/jest-environment-node/node_modules/@jest/types": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-environment-jsdom/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/jest-environment-node/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } - }, - "node_modules/jest-environment-jsdom/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-environment-jsdom/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-environment-jsdom/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-environment-jsdom/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/jest-environment-jsdom/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-environment-jsdom/node_modules/jest-util": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", - "integrity": "sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==", - "dev": true, - "dependencies": { - "@jest/types": "^26.6.2", - "@types/node": "*", - "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", - "is-ci": "^2.0.0", - "micromatch": "^4.0.2" - }, - "engines": { - "node": ">= 10.14.2" - } - }, - "node_modules/jest-environment-jsdom/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-environment-node": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-26.6.2.tgz", - "integrity": "sha512-zhtMio3Exty18dy8ee8eJ9kjnRyZC1N4C1Nt/VShN1apyXc8rWGtJ9lI7vqiWcyyXS4BVSEn9lxAM2D+07/Tag==", - "dev": true, - "dependencies": { - "@jest/environment": "^26.6.2", - "@jest/fake-timers": "^26.6.2", - "@jest/types": "^26.6.2", - "@types/node": "*", - "jest-mock": "^26.6.2", - "jest-util": "^26.6.2" - }, - "engines": { - "node": ">= 10.14.2" - } - }, - "node_modules/jest-environment-node/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", - "dev": true, - "dependencies": { - "@types/istanbul-lib-coverage": "^2.0.0", - "@types/istanbul-reports": "^3.0.0", - "@types/node": "*", - "@types/yargs": "^15.0.0", - "chalk": "^4.0.0" - }, - "engines": { - "node": ">= 10.14.2" - } - }, - "node_modules/jest-environment-node/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", - "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/jest-environment-node/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -14435,6 +14471,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -14451,6 +14488,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -14462,32 +14500,35 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/jest-environment-node/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/jest-environment-node/node_modules/jest-util": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", - "integrity": "sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", - "is-ci": "^2.0.0", - "micromatch": "^4.0.2" + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-environment-node/node_modules/supports-color": { @@ -14495,6 +14536,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -14503,12 +14545,13 @@ } }, "node_modules/jest-get-type": { - "version": "26.3.0", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-26.3.0.tgz", - "integrity": "sha512-TpfaviN1R2pQWkIihlfEanwOXK0zcxrKEE4MlU6Tn7keoXdN6/3gK/xl0yEh8DOunn5pOVGKf8hB4R9gVh04ig==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.6.3.tgz", + "integrity": "sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==", "dev": true, + "license": "MIT", "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-haste-map": { @@ -14574,173 +14617,34 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, - "node_modules/jest-jasmine2": { - "version": "26.6.3", - "resolved": "https://registry.npmjs.org/jest-jasmine2/-/jest-jasmine2-26.6.3.tgz", - "integrity": "sha512-kPKUrQtc8aYwBV7CqBg5pu+tmYXlvFlSFYn18ev4gPFtrRzB15N2gW/Roew3187q2w2eHuu0MU9TJz6w0/nPEg==", - "dev": true, - "dependencies": { - "@babel/traverse": "^7.1.0", - "@jest/environment": "^26.6.2", - "@jest/source-map": "^26.6.2", - "@jest/test-result": "^26.6.2", - "@jest/types": "^26.6.2", - "@types/node": "*", - "chalk": "^4.0.0", - "co": "^4.6.0", - "expect": "^26.6.2", - "is-generator-fn": "^2.0.0", - "jest-each": "^26.6.2", - "jest-matcher-utils": "^26.6.2", - "jest-message-util": "^26.6.2", - "jest-runtime": "^26.6.3", - "jest-snapshot": "^26.6.2", - "jest-util": "^26.6.2", - "pretty-format": "^26.6.2", - "throat": "^5.0.0" - }, - "engines": { - "node": ">= 10.14.2" - } - }, - "node_modules/jest-jasmine2/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", - "dev": true, - "dependencies": { - "@types/istanbul-lib-coverage": "^2.0.0", - "@types/istanbul-reports": "^3.0.0", - "@types/node": "*", - "@types/yargs": "^15.0.0", - "chalk": "^4.0.0" - }, - "engines": { - "node": ">= 10.14.2" - } - }, - "node_modules/jest-jasmine2/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", - "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } - }, - "node_modules/jest-jasmine2/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-jasmine2/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-jasmine2/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-jasmine2/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/jest-jasmine2/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-jasmine2/node_modules/jest-util": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", - "integrity": "sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==", - "dev": true, - "dependencies": { - "@jest/types": "^26.6.2", - "@types/node": "*", - "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", - "is-ci": "^2.0.0", - "micromatch": "^4.0.2" - }, - "engines": { - "node": ">= 10.14.2" - } - }, - "node_modules/jest-jasmine2/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/jest-leak-detector": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-26.6.2.tgz", - "integrity": "sha512-i4xlXpsVSMeKvg2cEKdfhh0H39qlJlP5Ex1yQxwF9ubahboQYMgTtz5oML35AVA3B4Eu+YsmwaiKVev9KCvLxg==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.7.0.tgz", + "integrity": "sha512-kYA8IJcSYtST2BY9I+SMC32nDpBT3J2NvWJx8+JCuCdl/CR1I4EKUJROiP8XtCcxqgTTBGJNdbB1A8XRKbTetw==", "dev": true, + "license": "MIT", "dependencies": { - "jest-get-type": "^26.3.0", - "pretty-format": "^26.6.2" + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-matcher-utils": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-26.6.2.tgz", - "integrity": "sha512-llnc8vQgYcNqDrqRDXWwMr9i7rS5XFiCwvh6DTP7Jqa2mqpcCBBlpCbn+trkG0KNhPu/h8rzyBkriOtBstvWhw==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.7.0.tgz", + "integrity": "sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==", "dev": true, + "license": "MIT", "dependencies": { "chalk": "^4.0.0", - "jest-diff": "^26.6.2", - "jest-get-type": "^26.3.0", - "pretty-format": "^26.6.2" + "jest-diff": "^29.7.0", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-matcher-utils/node_modules/ansi-styles": { @@ -14748,6 +14652,7 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -14763,6 +14668,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -14779,6 +14685,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -14790,13 +14697,15 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/jest-matcher-utils/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -14806,6 +14715,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -14814,55 +14724,70 @@ } }, "node_modules/jest-message-util": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-26.6.2.tgz", - "integrity": "sha512-rGiLePzQ3AzwUshu2+Rn+UMFk0pHN58sOG+IaJbk5Jxuqo3NYO1U2/MIR4S1sKgsoYSXSzdtSa0TgrmtUwEbmA==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.7.0.tgz", + "integrity": "sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.0.0", - "@jest/types": "^26.6.2", + "@babel/code-frame": "^7.12.13", + "@jest/types": "^29.6.3", "@types/stack-utils": "^2.0.0", "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", - "micromatch": "^4.0.2", - "pretty-format": "^26.6.2", + "graceful-fs": "^4.2.9", + "micromatch": "^4.0.4", + "pretty-format": "^29.7.0", "slash": "^3.0.0", - "stack-utils": "^2.0.2" + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-message-util/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-message-util/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-message-util/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/jest-message-util/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/jest-message-util/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -14878,6 +14803,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -14894,6 +14820,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -14905,13 +14832,15 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/jest-message-util/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -14921,6 +14850,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -14929,48 +14859,64 @@ } }, "node_modules/jest-mock": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-26.6.2.tgz", - "integrity": "sha512-YyFjePHHp1LzpzYcmgqkJ0nm0gg/lJx2aZFzFy1S6eUqNjXsOqTK10zNRff2dNfssgokjkG65OlWNcIlgd3zew==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.7.0.tgz", + "integrity": "sha512-ITOMZn+UkYS4ZFh83xYAOzWStloNzJFO2s8DWrE4lhtGD+AorgnbkiKERe4wQVBydIGPx059g6riW5Btp6Llnw==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", - "@types/node": "*" + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-mock/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-mock/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-mock/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/jest-mock/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/jest-mock/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -14986,6 +14932,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -15002,6 +14949,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -15013,22 +14961,43 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/jest-mock/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, + "node_modules/jest-mock/node_modules/jest-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, "node_modules/jest-mock/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -15041,6 +15010,7 @@ "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" }, @@ -15063,172 +15033,94 @@ } }, "node_modules/jest-resolve": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-26.6.2.tgz", - "integrity": "sha512-sOxsZOq25mT1wRsfHcbtkInS+Ek7Q8jCHUB0ZUTP0tc/c41QHriU/NunqMfCUWsL4H3MHpvQD4QR9kSYhS7UvQ==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.7.0.tgz", + "integrity": "sha512-IOVhZSrg+UvVAshDSDtHyFCCBUl/Q3AAJv8iZ6ZjnZ74xzvwuzLXid9IIIPgTnY62SJjfuupMKZsZQRsCvxEgA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", "jest-pnp-resolver": "^1.2.2", - "jest-util": "^26.6.2", - "read-pkg-up": "^7.0.1", - "resolve": "^1.18.1", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "resolve": "^1.20.0", + "resolve.exports": "^2.0.0", "slash": "^3.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-resolve-dependencies": { - "version": "26.6.3", - "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-26.6.3.tgz", - "integrity": "sha512-pVwUjJkxbhe4RY8QEWzN3vns2kqyuldKpxlxJlzEYfKSvY6/bMvxoFrYYzUO1Gx28yKWN37qyV7rIoIp2h8fTg==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-29.7.0.tgz", + "integrity": "sha512-un0zD/6qxJ+S0et7WxeI3H5XSe9lTBBR7bOHCHXkKR6luG5mwDDlIzVQ0V5cZCuoTgEdcdwzTghYkTWfubi+nA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", - "jest-regex-util": "^26.0.0", - "jest-snapshot": "^26.6.2" + "jest-regex-util": "^29.6.3", + "jest-snapshot": "^29.7.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-resolve-dependencies/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "node_modules/jest-resolve-dependencies/node_modules/jest-regex-util": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", "dev": true, - "dependencies": { - "@types/istanbul-lib-coverage": "^2.0.0", - "@types/istanbul-reports": "^3.0.0", - "@types/node": "*", - "@types/yargs": "^15.0.0", - "chalk": "^4.0.0" - }, + "license": "MIT", "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-resolve-dependencies/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/jest-resolve/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", "dev": true, + "license": "MIT", "dependencies": { - "@types/yargs-parser": "*" - } - }, - "node_modules/jest-resolve-dependencies/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-resolve-dependencies/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-resolve-dependencies/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-resolve-dependencies/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/jest-resolve-dependencies/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-resolve-dependencies/node_modules/jest-regex-util": { - "version": "26.0.0", - "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-26.0.0.tgz", - "integrity": "sha512-Gv3ZIs/nA48/Zvjrl34bf+oD76JHiGDUxNOVgUjh3j890sblXryjY4rss71fPtD/njchl6PSE2hIhvyWa1eT0A==", - "dev": true, - "engines": { - "node": ">= 10.14.2" - } - }, - "node_modules/jest-resolve-dependencies/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-resolve/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-resolve/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/jest-resolve/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/jest-resolve/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -15244,6 +15136,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -15260,6 +15153,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -15271,32 +15165,71 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/jest-resolve/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, + "node_modules/jest-resolve/node_modules/jest-haste-map": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.7.0.tgz", + "integrity": "sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/graceful-fs": "^4.1.3", + "@types/node": "*", + "anymatch": "^3.0.3", + "fb-watchman": "^2.0.0", + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "micromatch": "^4.0.4", + "walker": "^1.0.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "optionalDependencies": { + "fsevents": "^2.3.2" + } + }, + "node_modules/jest-resolve/node_modules/jest-regex-util": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, "node_modules/jest-resolve/node_modules/jest-util": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", - "integrity": "sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", - "is-ci": "^2.0.0", - "micromatch": "^4.0.2" + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-resolve/node_modules/supports-color": { @@ -15304,6 +15237,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -15312,66 +15246,109 @@ } }, "node_modules/jest-runner": { - "version": "26.6.3", - "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-26.6.3.tgz", - "integrity": "sha512-atgKpRHnaA2OvByG/HpGA4g6CSPS/1LK0jK3gATJAoptC1ojltpmVlYC3TYgdmGp+GLuhzpH30Gvs36szSL2JQ==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-29.7.0.tgz", + "integrity": "sha512-fsc4N6cPCAahybGBfTRcq5wFR6fpLznMg47sY5aDpsoejOcVYFb07AHuSnR0liMcPTgBsA3ZJL6kFOjPdoNipQ==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/console": "^26.6.2", - "@jest/environment": "^26.6.2", - "@jest/test-result": "^26.6.2", - "@jest/types": "^26.6.2", + "@jest/console": "^29.7.0", + "@jest/environment": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", - "emittery": "^0.7.1", - "exit": "^0.1.2", - "graceful-fs": "^4.2.4", - "jest-config": "^26.6.3", - "jest-docblock": "^26.0.0", - "jest-haste-map": "^26.6.2", - "jest-leak-detector": "^26.6.2", - "jest-message-util": "^26.6.2", - "jest-resolve": "^26.6.2", - "jest-runtime": "^26.6.3", - "jest-util": "^26.6.2", - "jest-worker": "^26.6.2", - "source-map-support": "^0.5.6", - "throat": "^5.0.0" + "emittery": "^0.13.1", + "graceful-fs": "^4.2.9", + "jest-docblock": "^29.7.0", + "jest-environment-node": "^29.7.0", + "jest-haste-map": "^29.7.0", + "jest-leak-detector": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-resolve": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-util": "^29.7.0", + "jest-watcher": "^29.7.0", + "jest-worker": "^29.7.0", + "p-limit": "^3.1.0", + "source-map-support": "0.5.13" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runner/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runner/node_modules/@jest/transform": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.7.0.tgz", + "integrity": "sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "babel-plugin-istanbul": "^6.1.1", + "chalk": "^4.0.0", + "convert-source-map": "^2.0.0", + "fast-json-stable-stringify": "^2.1.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "micromatch": "^4.0.4", + "pirates": "^4.0.4", + "slash": "^3.0.0", + "write-file-atomic": "^4.0.2" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-runner/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-runner/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/jest-runner/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/jest-runner/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -15387,6 +15364,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -15403,6 +15381,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -15414,68 +15393,94 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" + }, + "node_modules/jest-runner/node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" }, "node_modules/jest-runner/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/jest-runner/node_modules/jest-haste-map": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-26.6.2.tgz", - "integrity": "sha512-easWIJXIw71B2RdR8kgqpjQrbMRWQBgiBwXYEhtGUTaX+doCjBheluShdDMeR8IMfJiTqH4+zfhtg29apJf/8w==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.7.0.tgz", + "integrity": "sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", - "@types/graceful-fs": "^4.1.2", + "@jest/types": "^29.6.3", + "@types/graceful-fs": "^4.1.3", "@types/node": "*", "anymatch": "^3.0.3", "fb-watchman": "^2.0.0", - "graceful-fs": "^4.2.4", - "jest-regex-util": "^26.0.0", - "jest-serializer": "^26.6.2", - "jest-util": "^26.6.2", - "jest-worker": "^26.6.2", - "micromatch": "^4.0.2", - "sane": "^4.0.3", - "walker": "^1.0.7" + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "micromatch": "^4.0.4", + "walker": "^1.0.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" }, "optionalDependencies": { - "fsevents": "^2.1.2" + "fsevents": "^2.3.2" } }, "node_modules/jest-runner/node_modules/jest-regex-util": { - "version": "26.0.0", - "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-26.0.0.tgz", - "integrity": "sha512-Gv3ZIs/nA48/Zvjrl34bf+oD76JHiGDUxNOVgUjh3j890sblXryjY4rss71fPtD/njchl6PSE2hIhvyWa1eT0A==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", "dev": true, + "license": "MIT", "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-runner/node_modules/jest-util": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", - "integrity": "sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", - "is-ci": "^2.0.0", - "micromatch": "^4.0.2" + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runner/node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/jest-runner/node_modules/supports-color": { @@ -15483,6 +15488,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -15491,102 +15497,110 @@ } }, "node_modules/jest-runtime": { - "version": "26.6.3", - "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-26.6.3.tgz", - "integrity": "sha512-lrzyR3N8sacTAMeonbqpnSka1dHNux2uk0qqDXVkMv2c/A3wYnvQ4EXuI013Y6+gSKSCxdaczvf4HF0mVXHRdw==", - "dev": true, - "dependencies": { - "@jest/console": "^26.6.2", - "@jest/environment": "^26.6.2", - "@jest/fake-timers": "^26.6.2", - "@jest/globals": "^26.6.2", - "@jest/source-map": "^26.6.2", - "@jest/test-result": "^26.6.2", - "@jest/transform": "^26.6.2", - "@jest/types": "^26.6.2", - "@types/yargs": "^15.0.0", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.7.0.tgz", + "integrity": "sha512-gUnLjgwdGqW7B4LvOIkbKs9WGbn+QLqRQQ9juC6HndeDiezIwhDP+mhMwHWCEcfQ5RUXa6OPnFF8BJh5xegwwQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/fake-timers": "^29.7.0", + "@jest/globals": "^29.7.0", + "@jest/source-map": "^29.6.3", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", "chalk": "^4.0.0", - "cjs-module-lexer": "^0.6.0", + "cjs-module-lexer": "^1.0.0", "collect-v8-coverage": "^1.0.0", - "exit": "^0.1.2", "glob": "^7.1.3", - "graceful-fs": "^4.2.4", - "jest-config": "^26.6.3", - "jest-haste-map": "^26.6.2", - "jest-message-util": "^26.6.2", - "jest-mock": "^26.6.2", - "jest-regex-util": "^26.0.0", - "jest-resolve": "^26.6.2", - "jest-snapshot": "^26.6.2", - "jest-util": "^26.6.2", - "jest-validate": "^26.6.2", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-mock": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", "slash": "^3.0.0", - "strip-bom": "^4.0.0", - "yargs": "^15.4.1" + "strip-bom": "^4.0.0" }, - "bin": { - "jest-runtime": "bin/jest-runtime.js" + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runtime/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-runtime/node_modules/@jest/transform": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-26.6.2.tgz", - "integrity": "sha512-E9JjhUgNzvuQ+vVAL21vlyfy12gP0GhazGgJC4h6qUt1jSdUXGWJ1wfu/X7Sd8etSgxV4ovT1pb9v5D6QW4XgA==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.7.0.tgz", + "integrity": "sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/core": "^7.1.0", - "@jest/types": "^26.6.2", - "babel-plugin-istanbul": "^6.0.0", + "@babel/core": "^7.11.6", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "babel-plugin-istanbul": "^6.1.1", "chalk": "^4.0.0", - "convert-source-map": "^1.4.0", - "fast-json-stable-stringify": "^2.0.0", - "graceful-fs": "^4.2.4", - "jest-haste-map": "^26.6.2", - "jest-regex-util": "^26.0.0", - "jest-util": "^26.6.2", - "micromatch": "^4.0.2", - "pirates": "^4.0.1", + "convert-source-map": "^2.0.0", + "fast-json-stable-stringify": "^2.1.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "micromatch": "^4.0.4", + "pirates": "^4.0.4", "slash": "^3.0.0", - "source-map": "^0.6.1", - "write-file-atomic": "^3.0.0" + "write-file-atomic": "^4.0.2" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-runtime/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-runtime/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/jest-runtime/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/jest-runtime/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -15602,6 +15616,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -15618,6 +15633,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -15629,68 +15645,78 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" + }, + "node_modules/jest-runtime/node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" }, "node_modules/jest-runtime/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/jest-runtime/node_modules/jest-haste-map": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-26.6.2.tgz", - "integrity": "sha512-easWIJXIw71B2RdR8kgqpjQrbMRWQBgiBwXYEhtGUTaX+doCjBheluShdDMeR8IMfJiTqH4+zfhtg29apJf/8w==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.7.0.tgz", + "integrity": "sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", - "@types/graceful-fs": "^4.1.2", + "@jest/types": "^29.6.3", + "@types/graceful-fs": "^4.1.3", "@types/node": "*", "anymatch": "^3.0.3", "fb-watchman": "^2.0.0", - "graceful-fs": "^4.2.4", - "jest-regex-util": "^26.0.0", - "jest-serializer": "^26.6.2", - "jest-util": "^26.6.2", - "jest-worker": "^26.6.2", - "micromatch": "^4.0.2", - "sane": "^4.0.3", - "walker": "^1.0.7" + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "micromatch": "^4.0.4", + "walker": "^1.0.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" }, "optionalDependencies": { - "fsevents": "^2.1.2" + "fsevents": "^2.3.2" } }, "node_modules/jest-runtime/node_modules/jest-regex-util": { - "version": "26.0.0", - "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-26.0.0.tgz", - "integrity": "sha512-Gv3ZIs/nA48/Zvjrl34bf+oD76JHiGDUxNOVgUjh3j890sblXryjY4rss71fPtD/njchl6PSE2hIhvyWa1eT0A==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", "dev": true, + "license": "MIT", "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-runtime/node_modules/jest-util": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", - "integrity": "sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", - "is-ci": "^2.0.0", - "micromatch": "^4.0.2" + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-runtime/node_modules/strip-bom": { @@ -15698,6 +15724,7 @@ "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -15707,6 +15734,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -15714,88 +15742,109 @@ "node": ">=8" } }, - "node_modules/jest-runtime/node_modules/write-file-atomic": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", - "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", + "node_modules/jest-snapshot": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.7.0.tgz", + "integrity": "sha512-Rm0BMWtxBcioHr1/OX5YCP8Uov4riHvKPknOGs804Zg9JGZgmIBkbtlxJC/7Z4msKYVbIJtfU+tKb8xlYNfdkw==", "dev": true, + "license": "MIT", "dependencies": { - "imurmurhash": "^0.1.4", - "is-typedarray": "^1.0.0", - "signal-exit": "^3.0.2", - "typedarray-to-buffer": "^3.1.5" + "@babel/core": "^7.11.6", + "@babel/generator": "^7.7.2", + "@babel/plugin-syntax-jsx": "^7.7.2", + "@babel/plugin-syntax-typescript": "^7.7.2", + "@babel/types": "^7.3.3", + "@jest/expect-utils": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "babel-preset-current-node-syntax": "^1.0.0", + "chalk": "^4.0.0", + "expect": "^29.7.0", + "graceful-fs": "^4.2.9", + "jest-diff": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "natural-compare": "^1.4.0", + "pretty-format": "^29.7.0", + "semver": "^7.5.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-serializer": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-serializer/-/jest-serializer-26.6.2.tgz", - "integrity": "sha512-S5wqyz0DXnNJPd/xfIzZ5Xnp1HrJWBczg8mMfMpN78OJ5eDxXyf+Ygld9wX1DnUWbIbhM1YDY95NjR4CBXkb2g==", + "node_modules/jest-snapshot/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", "dev": true, + "license": "MIT", "dependencies": { - "@types/node": "*", - "graceful-fs": "^4.2.4" + "@sinclair/typebox": "^0.27.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-snapshot": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-26.6.2.tgz", - "integrity": "sha512-OLhxz05EzUtsAmOMzuupt1lHYXCNib0ECyuZ/PZOx9TrZcC8vL0x+DUG3TL+GLX3yHG45e6YGjIm0XwDc3q3og==", + "node_modules/jest-snapshot/node_modules/@jest/transform": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.7.0.tgz", + "integrity": "sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/types": "^7.0.0", - "@jest/types": "^26.6.2", - "@types/babel__traverse": "^7.0.4", - "@types/prettier": "^2.0.0", + "@babel/core": "^7.11.6", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "babel-plugin-istanbul": "^6.1.1", "chalk": "^4.0.0", - "expect": "^26.6.2", - "graceful-fs": "^4.2.4", - "jest-diff": "^26.6.2", - "jest-get-type": "^26.3.0", - "jest-haste-map": "^26.6.2", - "jest-matcher-utils": "^26.6.2", - "jest-message-util": "^26.6.2", - "jest-resolve": "^26.6.2", - "natural-compare": "^1.4.0", - "pretty-format": "^26.6.2", - "semver": "^7.3.2" + "convert-source-map": "^2.0.0", + "fast-json-stable-stringify": "^2.1.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "micromatch": "^4.0.4", + "pirates": "^4.0.4", + "slash": "^3.0.0", + "write-file-atomic": "^4.0.2" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-snapshot/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-snapshot/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/jest-snapshot/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/jest-snapshot/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -15811,6 +15860,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -15827,6 +15877,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -15838,90 +15889,86 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" + }, + "node_modules/jest-snapshot/node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" }, "node_modules/jest-snapshot/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/jest-snapshot/node_modules/jest-haste-map": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-26.6.2.tgz", - "integrity": "sha512-easWIJXIw71B2RdR8kgqpjQrbMRWQBgiBwXYEhtGUTaX+doCjBheluShdDMeR8IMfJiTqH4+zfhtg29apJf/8w==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.7.0.tgz", + "integrity": "sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", - "@types/graceful-fs": "^4.1.2", + "@jest/types": "^29.6.3", + "@types/graceful-fs": "^4.1.3", "@types/node": "*", "anymatch": "^3.0.3", "fb-watchman": "^2.0.0", - "graceful-fs": "^4.2.4", - "jest-regex-util": "^26.0.0", - "jest-serializer": "^26.6.2", - "jest-util": "^26.6.2", - "jest-worker": "^26.6.2", - "micromatch": "^4.0.2", - "sane": "^4.0.3", - "walker": "^1.0.7" + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "micromatch": "^4.0.4", + "walker": "^1.0.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" }, "optionalDependencies": { - "fsevents": "^2.1.2" + "fsevents": "^2.3.2" } }, "node_modules/jest-snapshot/node_modules/jest-regex-util": { - "version": "26.0.0", - "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-26.0.0.tgz", - "integrity": "sha512-Gv3ZIs/nA48/Zvjrl34bf+oD76JHiGDUxNOVgUjh3j890sblXryjY4rss71fPtD/njchl6PSE2hIhvyWa1eT0A==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", "dev": true, + "license": "MIT", "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-snapshot/node_modules/jest-util": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", - "integrity": "sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", - "is-ci": "^2.0.0", - "micromatch": "^4.0.2" - }, - "engines": { - "node": ">= 10.14.2" - } - }, - "node_modules/jest-snapshot/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" }, "engines": { - "node": ">=10" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-snapshot/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, + "license": "ISC", "bin": { "semver": "bin/semver.js" }, @@ -15934,6 +15981,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -15941,12 +15989,6 @@ "node": ">=8" } }, - "node_modules/jest-snapshot/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, "node_modules/jest-util": { "version": "28.1.3", "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-28.1.3.tgz", @@ -15995,21 +16037,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/jest-util/node_modules/ci-info": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", - "integrity": "sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/sibiraj-s" - } - ], - "engines": { - "node": ">=8" - } - }, "node_modules/jest-util/node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -16050,52 +16077,67 @@ } }, "node_modules/jest-validate": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-26.6.2.tgz", - "integrity": "sha512-NEYZ9Aeyj0i5rQqbq+tpIOom0YS1u2MVu6+euBsvpgIme+FOfRmoC4R5p0JiAUpaFvFy24xgrpMknarR/93XjQ==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.7.0.tgz", + "integrity": "sha512-ZB7wHqaRGVw/9hST/OuFUReG7M8vKeq0/J2egIGLdvjHCmYqGARhzXmtgi+gVeZ5uXFF219aOc3Ls2yLg27tkw==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", - "camelcase": "^6.0.0", + "@jest/types": "^29.6.3", + "camelcase": "^6.2.0", "chalk": "^4.0.0", - "jest-get-type": "^26.3.0", + "jest-get-type": "^29.6.3", "leven": "^3.1.0", - "pretty-format": "^26.6.2" + "pretty-format": "^29.7.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-validate/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-validate/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/jest-validate/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/jest-validate/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -16111,18 +16153,302 @@ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/jest-validate/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/jest-validate/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/jest-validate/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/jest-validate/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-validate/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-watcher": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-29.7.0.tgz", + "integrity": "sha512-49Fg7WXkU3Vl2h6LbLtMQ/HyB6rXSIX7SqvBLQmssRBGN9I0PNvPmAmCWSOY6SOvrjhI/F7/bGAv9RtnsPA03g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "emittery": "^0.13.1", + "jest-util": "^29.7.0", + "string-length": "^4.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-watcher/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-watcher/node_modules/@jest/types": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/schemas": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-watcher/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", + "dev": true, + "license": "MIT" + }, + "node_modules/jest-watcher/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/jest-watcher/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/jest-watcher/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/jest-watcher/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/jest-watcher/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-watcher/node_modules/jest-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-watcher/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-worker": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.7.0.tgz", + "integrity": "sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "jest-util": "^29.7.0", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker/node_modules/@jest/types": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/schemas": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", + "dev": true, + "license": "MIT" + }, + "node_modules/jest-worker/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, "engines": { - "node": ">=10" + "node": ">=8" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/jest-validate/node_modules/chalk": { + "node_modules/jest-worker/node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -16134,11 +16460,25 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/jest-validate/node_modules/color-convert": { + "node_modules/jest-worker/node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-worker/node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -16146,81 +16486,101 @@ "node": ">=7.0.0" } }, - "node_modules/jest-validate/node_modules/color-name": { + "node_modules/jest-worker/node_modules/color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, - "node_modules/jest-validate/node_modules/has-flag": { + "node_modules/jest-worker/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, - "node_modules/jest-validate/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "node_modules/jest-worker/node_modules/jest-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, "engines": { - "node": ">=8" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" } }, - "node_modules/jest-watcher": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-26.6.2.tgz", - "integrity": "sha512-WKJob0P/Em2csiVthsI68p6aGKTIcsfjH9Gsx1f0A3Italz43e3ho0geSAVsmj09RWOELP1AZ/DXyJgOgDKxXQ==", + "node_modules/jest/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/test-result": "^26.6.2", - "@jest/types": "^26.6.2", - "@types/node": "*", - "ansi-escapes": "^4.2.1", - "chalk": "^4.0.0", - "jest-util": "^26.6.2", - "string-length": "^4.0.1" + "@sinclair/typebox": "^0.27.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-watcher/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "node_modules/jest/node_modules/@jest/types": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", "dev": true, + "license": "MIT", "dependencies": { + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^15.0.0", + "@types/yargs": "^17.0.8", "chalk": "^4.0.0" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-watcher/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/jest/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, - "node_modules/jest-watcher/node_modules/ansi-styles": { + "node_modules/jest/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -16231,11 +16591,12 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/jest-watcher/node_modules/chalk": { + "node_modules/jest/node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -16247,11 +16608,12 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/jest-watcher/node_modules/color-convert": { + "node_modules/jest/node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -16259,78 +16621,29 @@ "node": ">=7.0.0" } }, - "node_modules/jest-watcher/node_modules/color-name": { + "node_modules/jest/node_modules/color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/jest-watcher/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-watcher/node_modules/jest-util": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", - "integrity": "sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==", - "dev": true, - "dependencies": { - "@jest/types": "^26.6.2", - "@types/node": "*", - "chalk": "^4.0.0", - "graceful-fs": "^4.2.4", - "is-ci": "^2.0.0", - "micromatch": "^4.0.2" - }, - "engines": { - "node": ">= 10.14.2" - } - }, - "node_modules/jest-watcher/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-worker": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-26.6.2.tgz", - "integrity": "sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==", "dev": true, - "dependencies": { - "@types/node": "*", - "merge-stream": "^2.0.0", - "supports-color": "^7.0.0" - }, - "engines": { - "node": ">= 10.13.0" - } + "license": "MIT" }, - "node_modules/jest-worker/node_modules/has-flag": { + "node_modules/jest/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, - "node_modules/jest-worker/node_modules/supports-color": { + "node_modules/jest/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -16463,15 +16776,16 @@ "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==" }, "node_modules/jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz", + "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==", "dev": true, + "license": "MIT", "bin": { "jsesc": "bin/jsesc" }, "engines": { - "node": ">=4" + "node": ">=6" } }, "node_modules/json-2-csv": { @@ -16756,20 +17070,12 @@ "node": ">=12.0.0" } }, - "node_modules/kind-of": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", - "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/kleur": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } @@ -16909,6 +17215,7 @@ "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } @@ -17722,20 +18029,34 @@ } }, "node_modules/make-dir": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", - "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", "dev": true, + "license": "MIT", "dependencies": { - "semver": "^6.0.0" + "semver": "^7.5.3" }, "engines": { - "node": ">=8" + "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/make-dir/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/make-plural": { "version": "7.3.0", "resolved": "https://registry.npmjs.org/make-plural/-/make-plural-7.3.0.tgz", @@ -17750,33 +18071,12 @@ "tmpl": "1.0.5" } }, - "node_modules/map-cache": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha512-8y/eV9QQZCiyn1SprXSrCmqJN0yNRATe+PO8ztwqrvrbdRLA3eYJF0yaR0YayLWkMbsQSKWS9N2gPcGEc4UsZg==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/map-stream": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", "integrity": "sha512-CkYQrPYZfWnu/DAmVCpTSX/xHpKZ80eKh2lAkyA6AJTef6bW+6JpbQZN5rofum7da+SyN1bi5ctTm+lTfcCW3g==", "dev": true }, - "node_modules/map-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", - "integrity": "sha512-4y7uGv8bd2WdM9vpQsiQNo41Ln1NvhvDRuVt0k2JZQ+ezN2uaQes7lZeZ+QQUHOLQAtDaBJ+7wCbi+ab/KFs+w==", - "dev": true, - "dependencies": { - "object-visit": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/matcher-collection": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/matcher-collection/-/matcher-collection-2.0.1.tgz", @@ -17911,19 +18211,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/mixin-deep": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", - "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", - "dev": true, - "dependencies": { - "for-in": "^1.0.2", - "is-extendable": "^1.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", @@ -18192,28 +18479,6 @@ "mustache": "bin/mustache" } }, - "node_modules/nanomatch": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", - "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", - "dev": true, - "dependencies": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "fragment-cache": "^0.2.1", - "is-windows": "^1.0.2", - "kind-of": "^6.0.2", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -18342,57 +18607,6 @@ "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", "dev": true }, - "node_modules/node-notifier": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.2.tgz", - "integrity": "sha512-oJP/9NAdd9+x2Q+rfphB2RJCHjod70RcRLjosiPMMu5gjIfwVnOUGq2nbTjTUbmy0DJ/tFIVT30+Qe3nzl4TJg==", - "dev": true, - "optional": true, - "dependencies": { - "growly": "^1.3.0", - "is-wsl": "^2.2.0", - "semver": "^7.3.2", - "shellwords": "^0.1.1", - "uuid": "^8.3.0", - "which": "^2.0.2" - } - }, - "node_modules/node-notifier/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "optional": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/node-notifier/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, - "optional": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/node-notifier/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true, - "optional": true - }, "node_modules/node-readfiles": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/node-readfiles/-/node-readfiles-0.2.0.tgz", @@ -18402,10 +18616,11 @@ } }, "node_modules/node-releases": { - "version": "2.0.12", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.12.tgz", - "integrity": "sha512-QzsYKWhXTWx8h1kIvqfnC++o0pEmpRQA/aenALsL2F4pqNVr7YzcdMlDij5WBnwftRbJCNJL/O7zdKaxKPHqgQ==", - "dev": true + "version": "2.0.18", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz", + "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==", + "dev": true, + "license": "MIT" }, "node_modules/node-schedule": { "version": "1.3.3", @@ -18486,27 +18701,6 @@ "node": "*" } }, - "node_modules/normalize-package-data": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", - "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", - "dev": true, - "dependencies": { - "hosted-git-info": "^2.1.4", - "resolve": "^1.10.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" - } - }, - "node_modules/normalize-package-data/node_modules/semver": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", - "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", - "dev": true, - "bin": { - "semver": "bin/semver" - } - }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -18582,62 +18776,16 @@ "integrity": "sha512-Yx5PWQNZomfEhPPOphFbZKi9W93CocQj18NlD2Pa4GWZzdZpSJvYwoiuurRI7m3SpcChrnO08hkuQDL3FGsVFQ==", "dependencies": { "node-fetch-h2": "^2.3.0", - "oas-kit-common": "^1.0.8", - "reftools": "^1.1.9", - "yaml": "^1.10.0", - "yargs": "^17.0.1" - }, - "bin": { - "resolve": "resolve.js" - }, - "funding": { - "url": "https://github.com/Mermade/oas-kit?sponsor=1" - } - }, - "node_modules/oas-resolver/node_modules/cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/oas-resolver/node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "engines": { - "node": ">=10" - } - }, - "node_modules/oas-resolver/node_modules/yargs": { - "version": "17.7.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", - "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", - "dependencies": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" + "oas-kit-common": "^1.0.8", + "reftools": "^1.1.9", + "yaml": "^1.10.0", + "yargs": "^17.0.1" }, - "engines": { - "node": ">=12" - } - }, - "node_modules/oas-resolver/node_modules/yargs-parser": { - "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", - "engines": { - "node": ">=12" + "bin": { + "resolve": "resolve.js" + }, + "funding": { + "url": "https://github.com/Mermade/oas-kit?sponsor=1" } }, "node_modules/oas-schema-walker": { @@ -18682,91 +18830,6 @@ "node": ">=0.10.0" } }, - "node_modules/object-copy": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", - "integrity": "sha512-79LYn6VAb63zgtmAteVOWo9Vdj71ZVBy3Pbse+VqxDpEP83XuujMrGqHIwAXJ5I/aM0zU7dIyIAhifVTPrNItQ==", - "dev": true, - "dependencies": { - "copy-descriptor": "^0.1.0", - "define-property": "^0.2.5", - "kind-of": "^3.0.3" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-copy/node_modules/define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", - "dev": true, - "dependencies": { - "is-descriptor": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-copy/node_modules/is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==", - "dev": true, - "dependencies": { - "kind-of": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-copy/node_modules/is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==", - "dev": true, - "dependencies": { - "kind-of": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-copy/node_modules/is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "dependencies": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-copy/node_modules/is-descriptor/node_modules/kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-copy/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", - "dev": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/object-hash": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-2.2.0.tgz", @@ -18794,18 +18857,6 @@ "node": ">= 0.4" } }, - "node_modules/object-visit": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", - "integrity": "sha512-GBaMwwAVK9qbQN3Scdo0OyvgPW7l3lnaVMj84uTOZlswkX0KpF6fyDBJhtTthf7pymztoN36/KEr1DyhF96zEA==", - "dev": true, - "dependencies": { - "isobject": "^3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/object.assign": { "version": "4.1.4", "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz", @@ -18841,18 +18892,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/object.pick": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ==", - "dev": true, - "dependencies": { - "isobject": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/objection": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/objection/-/objection-3.0.1.tgz", @@ -18994,18 +19033,6 @@ "safe-buffer": "~5.1.0" } }, - "node_modules/p-each-series": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-each-series/-/p-each-series-2.2.0.tgz", - "integrity": "sha512-ycIL2+1V32th+8scbpTvyHNaHe02z0sjgh91XXjAk+ZeXoPN4Z46DVUnzdso0aX4KckKw0FNNFHdjZ2UsZvxiA==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/p-event": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/p-event/-/p-event-4.2.0.tgz", @@ -19202,15 +19229,6 @@ "node": ">= 0.8" } }, - "node_modules/pascalcase": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", - "integrity": "sha512-XHXfu/yOQRy9vYOtUDVMN60OEJjW013GoObG1o+xwQTpB9eYJX/BjXMsdW13ZDPruFhYYn0AG22w0xgQMwl3Nw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/path-dirname": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", @@ -19391,10 +19409,11 @@ } }, "node_modules/picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" }, "node_modules/picomatch": { "version": "2.3.1", @@ -19445,15 +19464,6 @@ "semver-compare": "^1.0.0" } }, - "node_modules/posix-character-classes": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", - "integrity": "sha512-xTgYBc3fuo7Yt7JbiuFxSYGToMoz8fLoE6TC9Wx1P/u+LfeThMOAqmuyECnlBaaJb+u1m9hHiXUEtwW4OzfUJg==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/postgres-array": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", @@ -19511,113 +19521,51 @@ } }, "node_modules/pretty-format": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-26.6.2.tgz", - "integrity": "sha512-7AeGuCYNGmycyQbCqd/3PWH4eOoX/OiCa0uphp57NVTeAGdJGaAliecxwBDHYQCIvrW7aDBZCYeNTP/WX69mkg==", + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", + "integrity": "sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==", "dev": true, + "license": "MIT", "dependencies": { - "@jest/types": "^26.6.2", - "ansi-regex": "^5.0.0", - "ansi-styles": "^4.0.0", - "react-is": "^17.0.1" + "@jest/schemas": "^29.6.3", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" }, "engines": { - "node": ">= 10" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/pretty-format/node_modules/@jest/types": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", - "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", + "node_modules/pretty-format/node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", "dev": true, + "license": "MIT", "dependencies": { - "@types/istanbul-lib-coverage": "^2.0.0", - "@types/istanbul-reports": "^3.0.0", - "@types/node": "*", - "@types/yargs": "^15.0.0", - "chalk": "^4.0.0" + "@sinclair/typebox": "^0.27.8" }, "engines": { - "node": ">= 10.14.2" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/pretty-format/node_modules/@types/yargs": { - "version": "15.0.15", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.15.tgz", - "integrity": "sha512-IziEYMU9XoVj8hWg7k+UJrXALkGFjWJhn5QFEv9q4p+v40oZhSuC135M38st8XPjICL7Ey4TV64ferBGUoJhBg==", + "node_modules/pretty-format/node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } + "license": "MIT" }, "node_modules/pretty-format/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/pretty-format/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, + "license": "MIT", "engines": { "node": ">=10" }, "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/pretty-format/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/pretty-format/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/pretty-format/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/pretty-format/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" + "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, "node_modules/preview-email": { @@ -19641,20 +19589,6 @@ "node": ">=14" } }, - "node_modules/preview-email/node_modules/ci-info": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", - "integrity": "sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/sibiraj-s" - } - ], - "engines": { - "node": ">=8" - } - }, "node_modules/preview-email/node_modules/uuid": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", @@ -19714,6 +19648,7 @@ "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", "dev": true, + "license": "MIT", "dependencies": { "kleur": "^3.0.3", "sisteransi": "^1.0.5" @@ -19964,6 +19899,23 @@ } } }, + "node_modules/pure-rand": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.1.0.tgz", + "integrity": "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/dubzzz" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fast-check" + } + ], + "license": "MIT" + }, "node_modules/qs": { "version": "6.13.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", @@ -20085,60 +20037,11 @@ } }, "node_modules/react-is": { - "version": "17.0.2", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", - "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", - "dev": true - }, - "node_modules/read-pkg": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", - "integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==", - "dev": true, - "dependencies": { - "@types/normalize-package-data": "^2.4.0", - "normalize-package-data": "^2.5.0", - "parse-json": "^5.0.0", - "type-fest": "^0.6.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/read-pkg-up": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-7.0.1.tgz", - "integrity": "sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==", - "dev": true, - "dependencies": { - "find-up": "^4.1.0", - "read-pkg": "^5.2.0", - "type-fest": "^0.8.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/read-pkg-up/node_modules/type-fest": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", - "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", + "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==", "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/read-pkg/node_modules/type-fest": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", - "integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==", - "dev": true, - "engines": { - "node": ">=8" - } + "license": "MIT" }, "node_modules/readable-stream": { "version": "3.6.2", @@ -20268,19 +20171,6 @@ "@babel/runtime": "^7.8.4" } }, - "node_modules/regex-not": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", - "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", - "dev": true, - "dependencies": { - "extend-shallow": "^3.0.2", - "safe-regex": "^1.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/regexp.prototype.flags": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.0.tgz", @@ -20415,28 +20305,10 @@ } }, "node_modules/remove-trailing-separator": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha512-/hS+Y0u3aOfIETiaiirUFwDBDzmXPvO+jAfKTitUngIPzdKc6Z0LoFjM/CK5PL4C+eKwHohlHAb6H0VFfmmUsw==", - "dev": true - }, - "node_modules/repeat-element": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.4.tgz", - "integrity": "sha512-LFiNfRcSu7KK3evMyYOuCzv3L10TW7yC1G2/+StMjK8Y6Vqd2MG7r/Qjw4ghtuCOjFvlnms/iMmLqpvW/ES/WQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==", - "dev": true, - "engines": { - "node": ">=0.10" - } + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha512-/hS+Y0u3aOfIETiaiirUFwDBDzmXPvO+jAfKTitUngIPzdKc6Z0LoFjM/CK5PL4C+eKwHohlHAb6H0VFfmmUsw==", + "dev": true }, "node_modules/replace-ext": { "version": "1.0.1", @@ -20580,12 +20452,6 @@ "node": ">=0.10.0" } }, - "node_modules/require-main-filename": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", - "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", - "dev": true - }, "node_modules/requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", @@ -20612,6 +20478,7 @@ "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", "dev": true, + "license": "MIT", "dependencies": { "resolve-from": "^5.0.0" }, @@ -20639,12 +20506,15 @@ "node": ">= 0.10" } }, - "node_modules/resolve-url": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha512-ZuF55hVUQaaczgOIwqWzkEcEidmlD/xl44x1UZnhOXcYuFN2S6+rcxpG+C1N3So0wvNI3DmJICUFfu2SxhBmvg==", - "deprecated": "https://github.com/lydell/resolve-url#deprecated", - "dev": true + "node_modules/resolve.exports": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz", + "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + } }, "node_modules/restore-cursor": { "version": "3.1.0", @@ -20880,15 +20750,6 @@ "resolved": "https://registry.npmjs.org/safe-identifier/-/safe-identifier-0.4.2.tgz", "integrity": "sha512-6pNbSMW6OhAi9j+N8V+U715yBQsaWJ7eyEUaOrawX+isg5ZxhUlV1NipNtgaKHmFGiABwt+ZF04Ii+3Xjkg+8w==" }, - "node_modules/safe-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", - "integrity": "sha512-aJXcif4xnaNUzvUuC5gcb46oTS7zvg4jpMTnuqtrEPlR3vFr4pxtdTwaF1Qs3Enjn9HK+ZlwQui+a7z0SywIzg==", - "dev": true, - "dependencies": { - "ret": "~0.1.10" - } - }, "node_modules/safe-regex-test": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz", @@ -20915,300 +20776,6 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, - "node_modules/sane": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/sane/-/sane-4.1.0.tgz", - "integrity": "sha512-hhbzAgTIX8O7SHfp2c8/kREfEn4qO/9q8C9beyY6+tvZ87EpoZ3i1RIEvp27YBswnNbY9mWd6paKVmKbAgLfZA==", - "deprecated": "some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added", - "dev": true, - "dependencies": { - "@cnakazawa/watch": "^1.0.3", - "anymatch": "^2.0.0", - "capture-exit": "^2.0.0", - "exec-sh": "^0.3.2", - "execa": "^1.0.0", - "fb-watchman": "^2.0.0", - "micromatch": "^3.1.4", - "minimist": "^1.1.1", - "walker": "~1.0.5" - }, - "bin": { - "sane": "src/cli.js" - }, - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/sane/node_modules/anymatch": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", - "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", - "dev": true, - "dependencies": { - "micromatch": "^3.1.4", - "normalize-path": "^2.1.1" - } - }, - "node_modules/sane/node_modules/braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, - "dependencies": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/sane/node_modules/braces/node_modules/extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", - "dev": true, - "dependencies": { - "is-extendable": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/sane/node_modules/cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", - "dev": true, - "dependencies": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - }, - "engines": { - "node": ">=4.8" - } - }, - "node_modules/sane/node_modules/execa": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", - "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", - "dev": true, - "dependencies": { - "cross-spawn": "^6.0.0", - "get-stream": "^4.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/sane/node_modules/fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha512-VcpLTWqWDiTerugjj8e3+esbg+skS3M9e54UuR3iCeIDMXCLTsAH8hTSzDQU/X6/6t3eYkOKoZSef2PlU6U1XQ==", - "dev": true, - "dependencies": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/sane/node_modules/fill-range/node_modules/extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", - "dev": true, - "dependencies": { - "is-extendable": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/sane/node_modules/get-stream": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", - "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", - "dev": true, - "dependencies": { - "pump": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/sane/node_modules/is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/sane/node_modules/is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==", - "dev": true, - "dependencies": { - "kind-of": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/sane/node_modules/is-number/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", - "dev": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/sane/node_modules/is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/sane/node_modules/micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "dependencies": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/sane/node_modules/normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w==", - "dev": true, - "dependencies": { - "remove-trailing-separator": "^1.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/sane/node_modules/npm-run-path": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw==", - "dev": true, - "dependencies": { - "path-key": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/sane/node_modules/path-key": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/sane/node_modules/semver": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", - "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", - "dev": true, - "bin": { - "semver": "bin/semver" - } - }, - "node_modules/sane/node_modules/shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==", - "dev": true, - "dependencies": { - "shebang-regex": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/sane/node_modules/shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/sane/node_modules/to-regex-range": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha512-ZZWNfCjUokXXDGXFpZehJIkZqq91BcULFq/Pi7M5i4JnxXdhMKAK682z8bCW3o8Hj1wuuzoKcW3DfVzaP6VuNg==", - "dev": true, - "dependencies": { - "is-number": "^3.0.0", - "repeat-string": "^1.6.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/sane/node_modules/which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "which": "bin/which" - } - }, "node_modules/saxes": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/saxes/-/saxes-5.0.1.tgz", @@ -21302,69 +20869,27 @@ "dependencies": { "encodeurl": "~2.0.0", "escape-html": "~1.0.3", - "parseurl": "~1.3.3", - "send": "0.19.0" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", - "dev": true - }, - "node_modules/set-function-length": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", - "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", - "dependencies": { - "define-data-property": "^1.1.4", - "es-errors": "^1.3.0", - "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.4", - "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/set-value": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", - "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", - "dev": true, - "dependencies": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.3", - "split-string": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/set-value/node_modules/extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", - "dev": true, - "dependencies": { - "is-extendable": "^0.1.0" + "parseurl": "~1.3.3", + "send": "0.19.0" }, "engines": { - "node": ">=0.10.0" + "node": ">= 0.8.0" } }, - "node_modules/set-value/node_modules/is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", - "dev": true, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, "engines": { - "node": ">=0.10.0" + "node": ">= 0.4" } }, "node_modules/setimmediate": { @@ -21398,13 +20923,6 @@ "node": ">=8" } }, - "node_modules/shellwords": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz", - "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==", - "dev": true, - "optional": true - }, "node_modules/should": { "version": "13.2.3", "resolved": "https://registry.npmjs.org/should/-/should-13.2.3.tgz", @@ -21555,7 +21073,8 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/slash": { "version": "3.0.0", @@ -21631,203 +21150,6 @@ "npm": ">= 3.0.0" } }, - "node_modules/snapdragon": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", - "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", - "dev": true, - "dependencies": { - "base": "^0.11.1", - "debug": "^2.2.0", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "map-cache": "^0.2.2", - "source-map": "^0.5.6", - "source-map-resolve": "^0.5.0", - "use": "^3.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon-node": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", - "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", - "dev": true, - "dependencies": { - "define-property": "^1.0.0", - "isobject": "^3.0.0", - "snapdragon-util": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon-node/node_modules/define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==", - "dev": true, - "dependencies": { - "is-descriptor": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon-util": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", - "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", - "dev": true, - "dependencies": { - "kind-of": "^3.2.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon-util/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", - "dev": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/snapdragon/node_modules/define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", - "dev": true, - "dependencies": { - "is-descriptor": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon/node_modules/extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", - "dev": true, - "dependencies": { - "is-extendable": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon/node_modules/is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==", - "dev": true, - "dependencies": { - "kind-of": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon/node_modules/is-accessor-descriptor/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", - "dev": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon/node_modules/is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==", - "dev": true, - "dependencies": { - "kind-of": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon/node_modules/is-data-descriptor/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", - "dev": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon/node_modules/is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "dependencies": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon/node_modules/is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon/node_modules/kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "dev": true - }, - "node_modules/snapdragon/node_modules/source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/socks": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", @@ -21871,37 +21193,17 @@ "node": ">=0.10.0" } }, - "node_modules/source-map-resolve": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz", - "integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==", - "deprecated": "See https://github.com/lydell/source-map-resolve#deprecated", - "dev": true, - "dependencies": { - "atob": "^2.1.2", - "decode-uri-component": "^0.2.0", - "resolve-url": "^0.2.1", - "source-map-url": "^0.4.0", - "urix": "^0.1.0" - } - }, "node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "version": "0.5.13", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", + "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", "dev": true, + "license": "MIT", "dependencies": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" } }, - "node_modules/source-map-url": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.1.tgz", - "integrity": "sha512-cPiFOTLUKvJFIg4SKVScy4ilPPW6rFgMgfuZJPNoDuMs3nC1HbMUycBoJw77xFIp6z1UJQJOfx6C9GMH80DiTw==", - "deprecated": "See https://github.com/lydell/source-map-url#deprecated", - "dev": true - }, "node_modules/sparse-bitfield": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", @@ -21912,38 +21214,6 @@ "memory-pager": "^1.0.2" } }, - "node_modules/spdx-correct": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz", - "integrity": "sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==", - "dev": true, - "dependencies": { - "spdx-expression-parse": "^3.0.0", - "spdx-license-ids": "^3.0.0" - } - }, - "node_modules/spdx-exceptions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", - "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==", - "dev": true - }, - "node_modules/spdx-expression-parse": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", - "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", - "dev": true, - "dependencies": { - "spdx-exceptions": "^2.1.0", - "spdx-license-ids": "^3.0.0" - } - }, - "node_modules/spdx-license-ids": { - "version": "3.0.13", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.13.tgz", - "integrity": "sha512-XkD+zwiqXHikFZm4AX/7JSCXA98U5Db4AFd5XUg/+9UNtnH75+Z9KxtpYiJZx36mUDVOwH83pl7yvCer6ewM3w==", - "dev": true - }, "node_modules/split": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", @@ -21964,18 +21234,6 @@ "node": ">=6" } }, - "node_modules/split-string": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", - "dev": true, - "dependencies": { - "extend-shallow": "^3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/split2": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", @@ -22027,6 +21285,7 @@ "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", "dev": true, + "license": "MIT", "dependencies": { "escape-string-regexp": "^2.0.0" }, @@ -22039,6 +21298,7 @@ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -22083,133 +21343,37 @@ "human-signals": "^2.1.0", "is-stream": "^2.0.0", "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.1", - "onetime": "^5.1.2", - "signal-exit": "^3.0.3", - "strip-final-newline": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sindresorhus/execa?sponsor=1" - } - }, - "node_modules/start-server-and-test/node_modules/get-stream": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", - "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/start-server-and-test/node_modules/human-signals": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", - "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", - "dev": true, - "engines": { - "node": ">=10.17.0" - } - }, - "node_modules/static-extend": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", - "integrity": "sha512-72E9+uLc27Mt718pMHt9VMNiAL4LMsmDbBva8mxWUCkT07fSzEGMYUCk0XWY6lp0j6RBAG4cJ3mWuZv2OE3s0g==", - "dev": true, - "dependencies": { - "define-property": "^0.2.5", - "object-copy": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/static-extend/node_modules/define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", - "dev": true, - "dependencies": { - "is-descriptor": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/static-extend/node_modules/is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==", - "dev": true, - "dependencies": { - "kind-of": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/static-extend/node_modules/is-accessor-descriptor/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", - "dev": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/static-extend/node_modules/is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==", - "dev": true, - "dependencies": { - "kind-of": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/static-extend/node_modules/is-data-descriptor/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", - "dev": true, - "dependencies": { - "is-buffer": "^1.1.5" + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, - "node_modules/static-extend/node_modules/is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "node_modules/start-server-and-test/node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", "dev": true, - "dependencies": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - }, "engines": { - "node": ">=0.10.0" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/static-extend/node_modules/kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "node_modules/start-server-and-test/node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", "dev": true, "engines": { - "node": ">=0.10.0" + "node": ">=10.17.0" } }, "node_modules/statuses": { @@ -22281,6 +21445,7 @@ "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==", "dev": true, + "license": "MIT", "dependencies": { "char-regex": "^1.0.2", "strip-ansi": "^6.0.0" @@ -22487,40 +21652,6 @@ "node": ">=4" } }, - "node_modules/supports-hyperlinks": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-2.3.0.tgz", - "integrity": "sha512-RpsAZlpWcDwOPQA22aCH4J0t7L8JmAvsCxfOSEwm7cQs3LshN36QaTkwd70DnBOXDWGssw2eUoc8CaRWT0XunA==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0", - "supports-color": "^7.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/supports-hyperlinks/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/supports-hyperlinks/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", @@ -22577,52 +21708,6 @@ "url": "https://github.com/Mermade/oas-kit?sponsor=1" } }, - "node_modules/swagger2openapi/node_modules/cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/swagger2openapi/node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "engines": { - "node": ">=10" - } - }, - "node_modules/swagger2openapi/node_modules/yargs": { - "version": "17.7.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", - "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", - "dependencies": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/swagger2openapi/node_modules/yargs-parser": { - "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", - "engines": { - "node": ">=12" - } - }, "node_modules/symbol-tree": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", @@ -22734,22 +21819,6 @@ "node": ">=8.0.0" } }, - "node_modules/terminal-link": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/terminal-link/-/terminal-link-2.1.1.tgz", - "integrity": "sha512-un0FmiRUQNr5PJqy9kP7c40F5BOfpGlYTrxonDChEZB7pzZxRNp/bt+ymiy9/npwXya9KH99nJ/GXFIiUkYGFQ==", - "dev": true, - "dependencies": { - "ansi-escapes": "^4.2.1", - "supports-hyperlinks": "^2.0.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", @@ -22775,12 +21844,6 @@ "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, - "node_modules/throat": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/throat/-/throat-5.0.0.tgz", - "integrity": "sha512-fcwX4mndzpLQKBS1DVYhGAcYaYt7vsHNIvQV+WXMvnow5cgjPphq5CaayLaGsjRdSCKZFNGt7/GYAuXaNOiYCA==", - "dev": true - }, "node_modules/through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -22899,53 +21962,6 @@ "node": ">=0.10.0" } }, - "node_modules/to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", - "engines": { - "node": ">=4" - } - }, - "node_modules/to-object-path": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", - "integrity": "sha512-9mWHdnGRuh3onocaHzukyvCZhzvr6tiflAy/JRFXcJX0TjgfWA9pk9t8CMbzmBE4Jfw58pXbkngtBtqYxzNEyg==", - "dev": true, - "dependencies": { - "kind-of": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/to-object-path/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", - "dev": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/to-regex": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", - "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", - "dev": true, - "dependencies": { - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "regex-not": "^1.0.2", - "safe-regex": "^1.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -23172,15 +22188,6 @@ "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" }, - "node_modules/typedarray-to-buffer": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", - "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", - "dev": true, - "dependencies": { - "is-typedarray": "^1.0.0" - } - }, "node_modules/typescript": { "version": "3.9.10", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", @@ -23329,30 +22336,6 @@ "node": ">=4" } }, - "node_modules/union-value": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", - "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", - "dev": true, - "dependencies": { - "arr-union": "^3.1.0", - "get-value": "^2.0.6", - "is-extendable": "^0.1.1", - "set-value": "^2.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/union-value/node_modules/is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/unique-stream": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-2.3.1.tgz", @@ -23380,54 +22363,6 @@ "node": ">= 0.8" } }, - "node_modules/unset-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", - "integrity": "sha512-PcA2tsuGSF9cnySLHTLSh2qrQiJ70mn+r+Glzxv2TWZblxsxCC52BDlZoPCsz7STd9pN7EZetkWZBAvk4cgZdQ==", - "dev": true, - "dependencies": { - "has-value": "^0.3.1", - "isobject": "^3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/unset-value/node_modules/has-value": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", - "integrity": "sha512-gpG936j8/MzaeID5Yif+577c17TxaDmhuyVgSwtnL/q8UUTySg8Mecb+8Cf1otgLoD7DDH75axp86ER7LFsf3Q==", - "dev": true, - "dependencies": { - "get-value": "^2.0.3", - "has-values": "^0.1.4", - "isobject": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/unset-value/node_modules/has-value/node_modules/isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha512-+OUdGJlgjOBZDfxnDjYYG6zp487z0JGNQq3cYQYg5f5hKR+syHMsaztzGeml/4kGG55CSpKSpWTY+jYGgsHLgA==", - "dev": true, - "dependencies": { - "isarray": "1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/unset-value/node_modules/has-values": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", - "integrity": "sha512-J8S0cEdWuQbqD9//tlZxiMuMNmxB8PlEwvYwuxsTmR1G5RXUePEX/SJn7aD0GMLieuZYSwNH0cQuJGwnYunXRQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/unzipper": { "version": "0.10.14", "resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.10.14.tgz", @@ -23478,9 +22413,9 @@ } }, "node_modules/update-browserslist-db": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.11.tgz", - "integrity": "sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz", + "integrity": "sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A==", "dev": true, "funding": [ { @@ -23496,9 +22431,10 @@ "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "dependencies": { - "escalade": "^3.1.1", - "picocolors": "^1.0.0" + "escalade": "^3.2.0", + "picocolors": "^1.1.0" }, "bin": { "update-browserslist-db": "cli.js" @@ -23515,13 +22451,6 @@ "punycode": "^2.1.0" } }, - "node_modules/urix": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha512-Am1ousAhSLBeB9cG/7k7r2R0zj50uDRlZHPGbazid5s9rlF1F/QKYObEKSIunSjIOkJZqwRRLpvewjEkM7pSqg==", - "deprecated": "Please see https://github.com/lydell/urix#deprecated", - "dev": true - }, "node_modules/url-parse": { "version": "1.5.10", "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", @@ -23531,15 +22460,6 @@ "requires-port": "^1.0.0" } }, - "node_modules/use": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", - "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -23585,27 +22505,26 @@ "dev": true }, "node_modules/v8-to-istanbul": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-7.1.2.tgz", - "integrity": "sha512-TxNb7YEUwkLXCQYeudi6lgQ/SZrzNO4kMdlqVxaZPUIUjCv6iSSypUQX70kNBSERpQ8fk48+d61FXk+tgqcWow==", + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", + "integrity": "sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA==", "dev": true, + "license": "ISC", "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", "@types/istanbul-lib-coverage": "^2.0.1", - "convert-source-map": "^1.6.0", - "source-map": "^0.7.3" + "convert-source-map": "^2.0.0" }, "engines": { - "node": ">=10.10.0" + "node": ">=10.12.0" } }, - "node_modules/v8-to-istanbul/node_modules/source-map": { - "version": "0.7.4", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", - "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==", + "node_modules/v8-to-istanbul/node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true, - "engines": { - "node": ">= 8" - } + "license": "MIT" }, "node_modules/valid-data-url": { "version": "3.0.1", @@ -23615,16 +22534,6 @@ "node": ">=10" } }, - "node_modules/validate-npm-package-license": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", - "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", - "dev": true, - "dependencies": { - "spdx-correct": "^3.0.0", - "spdx-expression-parse": "^3.0.0" - } - }, "node_modules/value-or-function": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/value-or-function/-/value-or-function-3.0.0.tgz", @@ -24029,12 +22938,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/which-module": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", - "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", - "dev": true - }, "node_modules/which-typed-array": { "version": "1.1.9", "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz", @@ -24246,10 +23149,13 @@ } }, "node_modules/y18n": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", - "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", - "dev": true + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "license": "ISC", + "engines": { + "node": ">=10" + } }, "node_modules/yallist": { "version": "3.1.1", @@ -24266,38 +23172,30 @@ } }, "node_modules/yargs": { - "version": "15.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", - "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", - "dev": true, + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "license": "MIT", "dependencies": { - "cliui": "^6.0.0", - "decamelize": "^1.2.0", - "find-up": "^4.1.0", - "get-caller-file": "^2.0.1", + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^4.2.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^18.1.2" + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" }, "engines": { - "node": ">=8" + "node": ">=12" } }, "node_modules/yargs-parser": { - "version": "18.1.3", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", - "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", - "dev": true, - "dependencies": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - }, + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "license": "ISC", "engines": { - "node": ">=6" + "node": ">=12" } }, "node_modules/yauzl": { @@ -24309,6 +23207,19 @@ "fd-slicer": "~1.1.0" } }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/zip-stream": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/zip-stream/-/zip-stream-4.1.1.tgz", diff --git a/packages/api/package.json b/packages/api/package.json index 22d4b1009a..4dbfca4445 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -113,7 +113,7 @@ "eslint-config-prettier": "^7.0.0", "eslint-plugin-json": "^3.1.0", "i18next-parser": "^5.3.0", - "jest": "^26.4.2", + "jest": "^29.7.0", "lint-staged": "^10.5.3", "nodemon": "^2.0.22", "prettier": "2.2.1", diff --git a/packages/api/tests/animal.test.js b/packages/api/tests/animal.test.js index 4156b8844d..c998cda971 100644 --- a/packages/api/tests/animal.test.js +++ b/packages/api/tests/animal.test.js @@ -143,10 +143,9 @@ describe('Animal Tests', () => { [newOwner] = await mocks.usersFactory(); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); // GET TESTS diff --git a/packages/api/tests/animal_batch.test.js b/packages/api/tests/animal_batch.test.js index 95a3bd69f4..86532e8f1c 100644 --- a/packages/api/tests/animal_batch.test.js +++ b/packages/api/tests/animal_batch.test.js @@ -148,10 +148,9 @@ describe('Animal Batch Tests', () => { [newOwner] = await mocks.usersFactory(); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); // GET TESTS diff --git a/packages/api/tests/animal_group.test.js b/packages/api/tests/animal_group.test.js index c0e6136763..f00665b006 100644 --- a/packages/api/tests/animal_group.test.js +++ b/packages/api/tests/animal_group.test.js @@ -40,30 +40,24 @@ describe('Animal Group Tests', () => { let farm; let newOwner; - function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { - chai + function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .get('/animal_groups') .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - const getRequestAsPromise = util.promisify(getRequest); - - function postRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { - chai + function postRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post('/animal_groups') .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - const postRequestAsPromise = util.promisify(postRequest); - function fakeUserFarm(role = 1) { return { ...mocks.fakeUserFarm(), role_id: role }; } @@ -127,10 +121,9 @@ describe('Animal Group Tests', () => { [newOwner] = await mocks.usersFactory(); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); // GET TESTS @@ -169,7 +162,7 @@ describe('Animal Group Tests', () => { // Create a third animal group belonging to a different farm await makeAnimalGroup(secondFarm); - const res = await getRequestAsPromise({ + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -206,7 +199,7 @@ describe('Animal Group Tests', () => { await makeAnimalGroup(mainFarm); const [unAuthorizedUser] = await mocks.usersFactory(); - const res = await getRequestAsPromise({ + const res = await getRequest({ user_id: unAuthorizedUser.user_id, farm_id: mainFarm.farm_id, }); @@ -228,7 +221,7 @@ describe('Animal Group Tests', () => { await makeAnimalGroupRelationship(group, animal); await makeAnimalBatchGroupRelationship(group, batch); - const res = await getRequestAsPromise({ + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -263,7 +256,7 @@ describe('Animal Group Tests', () => { const related_animal_ids = [firstAnimal.id, secondAnimal.id]; const related_batch_ids = [firstAnimalBatch.id, secondAnimalBatch.id]; - const res = await postRequestAsPromise( + const res = await postRequest( { ...animalGroup, related_animal_ids, @@ -320,7 +313,7 @@ describe('Animal Group Tests', () => { const animalGroup = mocks.fakeAnimalGroup(); - const res = await postRequestAsPromise( + const res = await postRequest( { ...animalGroup, related_animal_ids: [firstAnimal.id, secondAnimal.id], @@ -343,7 +336,7 @@ describe('Animal Group Tests', () => { const animalGroup = mocks.fakeAnimalGroup(); - const res = await postRequestAsPromise( + const res = await postRequest( { ...animalGroup, related_animal_ids: [], @@ -387,7 +380,7 @@ describe('Animal Group Tests', () => { const animalGroup = mocks.fakeAnimalGroup(); - await postRequestAsPromise( + await postRequest( { ...animalGroup, related_animal_ids: [], @@ -399,7 +392,7 @@ describe('Animal Group Tests', () => { }, ); - const res = await postRequestAsPromise( + const res = await postRequest( { ...animalGroup, related_animal_ids: [], @@ -427,7 +420,7 @@ describe('Animal Group Tests', () => { const animalGroup = mocks.fakeAnimalGroup(); - const res = await postRequestAsPromise( + const res = await postRequest( { ...animalGroup, related_animal_ids, @@ -470,7 +463,7 @@ describe('Animal Group Tests', () => { const animalGroup = mocks.fakeAnimalGroup(); - const res = await postRequestAsPromise( + const res = await postRequest( { ...animalGroup, related_animal_ids, diff --git a/packages/api/tests/animal_identifier_color.test.js b/packages/api/tests/animal_identifier_color.test.js index 3df28fc978..dc2531a68c 100644 --- a/packages/api/tests/animal_identifier_color.test.js +++ b/packages/api/tests/animal_identifier_color.test.js @@ -37,17 +37,14 @@ describe('Animal Identifier Color Tests', () => { let farm; let newOwner; - function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { - chai + function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .get('/animal_identifier_colors') .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - const getRequestAsPromise = util.promisify(getRequest); - function fakeUserFarm(role = 1) { return { ...mocks.fakeUserFarm(), role_id: role }; } @@ -78,14 +75,12 @@ describe('Animal Identifier Color Tests', () => { [newOwner] = await mocks.usersFactory(); }); - afterEach(async (done) => { + afterEach(async () => { await tableCleanup(knex); - done(); }); - afterAll(async (done) => { + afterAll(async () => { await knex.destroy(); - done(); }); // GET TESTS @@ -98,7 +93,7 @@ describe('Animal Identifier Color Tests', () => { for (const role of roles) { const { mainFarm, user } = await returnUserFarms(role); - const res = await getRequestAsPromise({ + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id, }); diff --git a/packages/api/tests/animal_identifier_type.test.js b/packages/api/tests/animal_identifier_type.test.js index 593d811862..cc23a50ebe 100644 --- a/packages/api/tests/animal_identifier_type.test.js +++ b/packages/api/tests/animal_identifier_type.test.js @@ -55,14 +55,12 @@ describe('Animal identifier type tests', () => { [newOwner] = await mocks.usersFactory(); }); - afterEach(async (done) => { + afterEach(async () => { await tableCleanup(knex); - done(); }); - afterAll(async (done) => { + afterAll(async () => { await knex.destroy(); - done(); }); test('should return all animal identifiers for all users', async () => { diff --git a/packages/api/tests/animal_origin.test.js b/packages/api/tests/animal_origin.test.js index c6cd5ee38f..c2a7f7dc20 100644 --- a/packages/api/tests/animal_origin.test.js +++ b/packages/api/tests/animal_origin.test.js @@ -37,17 +37,14 @@ describe('Animal Origin Tests', () => { let farm; let newOwner; - function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { - chai + function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .get('/animal_origins') .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - const getRequestAsPromise = util.promisify(getRequest); - function fakeUserFarm(role = 1) { return { ...mocks.fakeUserFarm(), role_id: role }; } @@ -76,14 +73,12 @@ describe('Animal Origin Tests', () => { [newOwner] = await mocks.usersFactory(); }); - afterEach(async (done) => { + afterEach(async () => { await tableCleanup(knex); - done(); }); - afterAll(async (done) => { + afterAll(async () => { await knex.destroy(); - done(); }); // GET TESTS @@ -96,7 +91,7 @@ describe('Animal Origin Tests', () => { for (const role of roles) { const { mainFarm, user } = await returnUserFarms(role); - const res = await getRequestAsPromise({ + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id, }); diff --git a/packages/api/tests/animal_removal_reason.test.js b/packages/api/tests/animal_removal_reason.test.js index aa84dfda36..82f81fcab1 100644 --- a/packages/api/tests/animal_removal_reason.test.js +++ b/packages/api/tests/animal_removal_reason.test.js @@ -74,14 +74,12 @@ describe('Animal Removal Reason Tests', () => { [newOwner] = await mocks.usersFactory(); }); - afterEach(async (done) => { + afterEach(async () => { await tableCleanup(knex); - done(); }); - afterAll(async (done) => { + afterAll(async () => { await knex.destroy(); - done(); }); // GET TESTS diff --git a/packages/api/tests/animal_sex.test.js b/packages/api/tests/animal_sex.test.js index ff1fbce786..7b83f5c7a7 100644 --- a/packages/api/tests/animal_sex.test.js +++ b/packages/api/tests/animal_sex.test.js @@ -37,17 +37,14 @@ describe('Animal Sex Tests', () => { let farm; let newOwner; - function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { - chai + function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .get('/animal_sexes') .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - const getRequestAsPromise = util.promisify(getRequest); - function fakeUserFarm(role = 1) { return { ...mocks.fakeUserFarm(), role_id: role }; } @@ -78,14 +75,12 @@ describe('Animal Sex Tests', () => { [newOwner] = await mocks.usersFactory(); }); - afterEach(async (done) => { + afterEach(async () => { await tableCleanup(knex); - done(); }); - afterAll(async (done) => { + afterAll(async () => { await knex.destroy(); - done(); }); // GET TESTS @@ -98,7 +93,7 @@ describe('Animal Sex Tests', () => { for (const role of roles) { const { mainFarm, user } = await returnUserFarms(role); - const res = await getRequestAsPromise({ + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id, }); diff --git a/packages/api/tests/animal_union_batch.test.js b/packages/api/tests/animal_union_batch.test.js index 5e33f2fa6e..0fb0447a02 100644 --- a/packages/api/tests/animal_union_batch.test.js +++ b/packages/api/tests/animal_union_batch.test.js @@ -21,14 +21,12 @@ import animalUnionBatchIdViewModel from '../src/models/animalUnionBatchIdViewMod import { makeAnimalOrBatchForFarm } from './utils/animalUtils.js'; describe('Animal Union Batch Tests', () => { - afterEach(async (done) => { + afterEach(async () => { await tableCleanup(knex); - done(); }); - afterAll(async (done) => { + afterAll(async () => { await knex.destroy(); - done(); }); // MODEL TESTS diff --git a/packages/api/tests/animal_use.test.js b/packages/api/tests/animal_use.test.js index 777f971110..b06bd31c16 100644 --- a/packages/api/tests/animal_use.test.js +++ b/packages/api/tests/animal_use.test.js @@ -84,14 +84,12 @@ describe('Animal Use Tests', () => { [newOwner] = await mocks.usersFactory(); }); - afterEach(async (done) => { + afterEach(async () => { await tableCleanup(knex); - done(); }); - afterAll(async (done) => { + afterAll(async () => { await knex.destroy(); - done(); }); describe('Get animal use tests', () => { diff --git a/packages/api/tests/authorization.test.js b/packages/api/tests/authorization.test.js index de4bc69ece..c5cbc07f18 100644 --- a/packages/api/tests/authorization.test.js +++ b/packages/api/tests/authorization.test.js @@ -44,51 +44,51 @@ xdescribe('Authorization Tests', () => { token = global.token; }); - function postRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { - chai + function postRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post(`/pesticide`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function getRequest( - { user_id = newOwner.user_id, farm_id = farm.farm_id, header_farm_id = farm.farm_id }, - callback, - ) { - chai + function getRequest({ + user_id = newOwner.user_id, + farm_id = farm.farm_id, + header_farm_id = farm.farm_id, + }) { + return chai .request(server) .get(`/pesticide/farm/${header_farm_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - function deleteRequest( - { user_id = newOwner.user_id, farm_id = farm.farm_id, pesticide_id, data = {} }, - callback, - ) { - chai + function deleteRequest({ + user_id = newOwner.user_id, + farm_id = farm.farm_id, + pesticide_id, + data = {}, + }) { + return chai .request(server) .delete(`/pesticide/${pesticide_id}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function putCropRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { + function putCropRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { const { crop_id } = data; - chai + + return chai .request(server) .put(`/crop/${crop_id}`) .set('farm_id', farm_id) .set('user_id', user_id) - .send(data) - .end(callback); + .send(data); } function fakeUserFarm(role = 1) { @@ -117,10 +117,9 @@ xdescribe('Authorization Tests', () => { ); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('userFarm status validations', () => { @@ -128,7 +127,7 @@ xdescribe('Authorization Tests', () => { beforeEach(async () => { [pesticide] = await mocks.pesticideFactory({ promisedFarm: [farm] }); }); - test('Invited user should not delete a pesticide', async (done) => { + test('Invited user should not delete a pesticide', async () => { const [invitedManager] = await mocks.usersFactory(); const [managerFarm] = await mocks.userFarmFactory( { @@ -137,16 +136,14 @@ xdescribe('Authorization Tests', () => { }, { ...fakeUserFarm(2), status: 'Invited' }, ); - deleteRequest( - { user_id: invitedManager.user_id, pesticide_id: pesticide.pesticide_id }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + const res = await deleteRequest({ + user_id: invitedManager.user_id, + pesticide_id: pesticide.pesticide_id, + }); + expect(res.status).toBe(403); }); - test('Inactive user should not delete a pesticide', async (done) => { + test('Inactive user should not delete a pesticide', async () => { const [invitedManager] = await mocks.usersFactory(); const [managerFarm] = await mocks.userFarmFactory( { @@ -155,13 +152,11 @@ xdescribe('Authorization Tests', () => { }, { ...fakeUserFarm(2), status: 'Inactive' }, ); - deleteRequest( - { user_id: invitedManager.user_id, pesticide_id: pesticide.pesticide_id }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + const res = await deleteRequest({ + user_id: invitedManager.user_id, + pesticide_id: pesticide.pesticide_id, + }); + expect(res.status).toBe(403); }); }); @@ -207,107 +202,86 @@ xdescribe('Authorization Tests', () => { ); }); - test('Owner should delete a fertlizer', async (done) => { - deleteRequest({ pesticide_id: pesticide.pesticide_id }, async (err, res) => { - expect(res.status).toBe(200); - const pesticideRes = await pesiticideModel - .query() - .context({ showHidden: true }) - .where('pesticide_id', pesticide.pesticide_id); - expect(pesticideRes.length).toBe(1); - expect(pesticideRes[0].deleted).toBe(true); - done(); - }); + test('Owner should delete a fertlizer', async () => { + const res = await deleteRequest({ pesticide_id: pesticide.pesticide_id }); + expect(res.status).toBe(200); + const pesticideRes = await pesiticideModel + .query() + .context({ showHidden: true }) + .where('pesticide_id', pesticide.pesticide_id); + expect(pesticideRes.length).toBe(1); + expect(pesticideRes[0].deleted).toBe(true); }); - test('Manager should delete a pesticide', async (done) => { - deleteRequest( - { user_id: manager.user_id, pesticide_id: pesticide.pesticide_id }, - async (err, res) => { - expect(res.status).toBe(200); - const pesticideRes = await pesiticideModel - .query() - .context({ showHidden: true }) - .where('pesticide_id', pesticide.pesticide_id); - expect(pesticideRes.length).toBe(1); - expect(pesticideRes[0].deleted).toBe(true); - done(); - }, - ); + test('Manager should delete a pesticide', async () => { + const res = await deleteRequest({ + user_id: manager.user_id, + pesticide_id: pesticide.pesticide_id, + }); + expect(res.status).toBe(200); + const pesticideRes = await pesiticideModel + .query() + .context({ showHidden: true }) + .where('pesticide_id', pesticide.pesticide_id); + expect(pesticideRes.length).toBe(1); + expect(pesticideRes[0].deleted).toBe(true); }); - test('should return 403 if an unauthorized user tries to delete a pesticide', async (done) => { - deleteRequest( - { - user_id: unAuthorizedUser.user_id, - pesticide_id: pesticide.pesticide_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('should return 403 if an unauthorized user tries to delete a pesticide', async () => { + const res = await deleteRequest({ + user_id: unAuthorizedUser.user_id, + pesticide_id: pesticide.pesticide_id, + }); + + expect(res.status).toBe(403); }); - test('should return 403 if a worker tries to delete a pesticide', async (done) => { - deleteRequest( - { user_id: newWorker.user_id, pesticide_id: pesticide.pesticide_id }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('should return 403 if a worker tries to delete a pesticide', async () => { + const res = await deleteRequest({ + user_id: newWorker.user_id, + pesticide_id: pesticide.pesticide_id, + }); + expect(res.status).toBe(403); }); describe('Circumventions', () => { - test('Circumvent authorization by modifying farm_id', async (done) => { - deleteRequest( - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - pesticide_id: pesticide.pesticide_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modifying farm_id', async () => { + const res = await deleteRequest({ + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + pesticide_id: pesticide.pesticide_id, + }); + + expect(res.status).toBe(403); }); - test('Circumvent authorization by modifying farm_id in body', async (done) => { - deleteRequest( - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - pesticide_id: pesticide.pesticide_id, - data: { farm_id: farmunAuthorizedUser.farm_id }, - }, - async (err, res) => { - expect(res.status).toBe(400); - done(); - }, - ); + test('Circumvent authorization by modifying farm_id in body', async () => { + const res = await deleteRequest({ + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + pesticide_id: pesticide.pesticide_id, + data: { farm_id: farmunAuthorizedUser.farm_id }, + }); + + expect(res.status).toBe(400); }); - test('Circumvent authorization by modifying field_id in body', async (done) => { + test('Circumvent authorization by modifying field_id in body', async () => { const [fieldunauthorizaed] = await mocks.fieldFactory({ promisedFarm: [farmunAuthorizedUser], }); - deleteRequest( - { - user_id: unAuthorizedUser.user_id, + + const res = await deleteRequest({ + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + pesticide_id: pesticide.pesticide_id, + data: { + field_id: fieldunauthorizaed.field_id, farm_id: farmunAuthorizedUser.farm_id, - pesticide_id: pesticide.pesticide_id, - data: { - field_id: fieldunauthorizaed.field_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - }, - async (err, res) => { - expect(res.status).toBe(400); - done(); }, - ); + }); + + expect(res.status).toBe(400); }); }); }); @@ -356,79 +330,65 @@ xdescribe('Authorization Tests', () => { ); }); - test('Owner should post and get a valid crop', async (done) => { - postRequest(fakepesticide, {}, async (err, res) => { - expect(res.status).toBe(201); - const pesticides = await pesiticideModel - .query() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(pesticides.length).toBe(1); - expect(pesticides[0].pesticide_name).toBe(fakepesticide.pesticide_name); - done(); - }); + test('Owner should post and get a valid crop', async () => { + const res = await postRequest(fakepesticide, {}); + expect(res.status).toBe(201); + const pesticides = await pesiticideModel + .query() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(pesticides.length).toBe(1); + expect(pesticides[0].pesticide_name).toBe(fakepesticide.pesticide_name); }); - test('Manager should post and get a valid crop', async (done) => { - postRequest(fakepesticide, { user_id: manager.user_id }, async (err, res) => { - expect(res.status).toBe(201); - const pesticides = await pesiticideModel - .query() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(pesticides.length).toBe(1); - expect(pesticides[0].pesticide_name).toBe(fakepesticide.pesticide_name); - done(); - }); + test('Manager should post and get a valid crop', async () => { + const res = await postRequest(fakepesticide, { user_id: manager.user_id }); + expect(res.status).toBe(201); + const pesticides = await pesiticideModel + .query() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(pesticides.length).toBe(1); + expect(pesticides[0].pesticide_name).toBe(fakepesticide.pesticide_name); }); - test('should return 403 status if pesticide is posted by worker', async (done) => { - postRequest(fakepesticide, { user_id: newWorker.user_id }, async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): add:pesticides', - ); - done(); - }); + test('should return 403 status if pesticide is posted by worker', async () => { + const res = await postRequest(fakepesticide, { user_id: newWorker.user_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): add:pesticides', + ); }); - test('should return 403 status if pesticide is posted by unauthorized user', async (done) => { - postRequest(fakepesticide, { user_id: unAuthorizedUser.user_id }, async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): add:pesticides', - ); - done(); - }); + test('should return 403 status if pesticide is posted by unauthorized user', async () => { + const res = await postRequest(fakepesticide, { user_id: unAuthorizedUser.user_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): add:pesticides', + ); }); describe('Circumventions', () => { - test('Circumvent authorization by adding farm_id to req.body', async (done) => { - postRequest( - fakepesticide, - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by adding farm_id to req.body', async () => { + const res = await postRequest(fakepesticide, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); }); - test('Circumvent authorization by adding field_id to req.body', async (done) => { + test('Circumvent authorization by adding field_id to req.body', async () => { const [fieldunauthorizaed] = await mocks.fieldFactory({ promisedFarm: [farmunAuthorizedUser], }); - postRequest( + + const res = await postRequest( { ...fakepesticide, field_id: fieldunauthorizaed.field_id }, { user_id: unAuthorizedUser.user_id, farm_id: farmunAuthorizedUser.farm_id }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, ); + + expect(res.status).toBe(403); }); }); }); @@ -476,37 +436,63 @@ xdescribe('Authorization Tests', () => { ); }); - test('Owner should be able to edit a crop', async (done) => { + test('Owner should be able to edit a crop', async () => { let newCrop = { ...crop, ...mocks.fakeCrop() }; - putCropRequest(newCrop, {}, async (err, res) => { - expect(res.status).toBe(200); - const cropRes = await cropModel - .query() - .context({ showHidden: true }) - .where('crop_id', crop.crop_id) - .first(); - expect(cropRes.crop_genus).toBe(newCrop.crop_genus); - done(); - }); + const res = await putCropRequest(newCrop, {}); + expect(res.status).toBe(200); + const cropRes = await cropModel + .query() + .context({ showHidden: true }) + .where('crop_id', crop.crop_id) + .first(); + expect(cropRes.crop_genus).toBe(newCrop.crop_genus); }); - test('Manager should be able to edit a crop', async (done) => { + test('Manager should be able to edit a crop', async () => { let newCrop = { ...crop, ...mocks.fakeCrop() }; - putCropRequest(newCrop, { user_id: manager.user_id }, async (err, res) => { - expect(res.status).toBe(200); - const cropRes = await cropModel - .query() - .context({ showHidden: true }) - .where('crop_id', crop.crop_id) - .first(); - expect(cropRes.crop_genus).toBe(newCrop.crop_genus); - done(); - }); + const res = await putCropRequest(newCrop, { user_id: manager.user_id }); + expect(res.status).toBe(200); + const cropRes = await cropModel + .query() + .context({ showHidden: true }) + .where('crop_id', crop.crop_id) + .first(); + expect(cropRes.crop_genus).toBe(newCrop.crop_genus); }); - test('should return 403 when a worker tries to edit crop', async (done) => { + test('should return 403 when a worker tries to edit crop', async () => { let newCrop = { ...crop, ...mocks.fakeCrop() }; - putCropRequest(newCrop, { user_id: newWorker.user_id }, async (err, res) => { + const res = await putCropRequest(newCrop, { user_id: newWorker.user_id }); + expect(res.status).toBe(403); + const cropRes = await cropModel + .query() + .context({ showHidden: true }) + .where('crop_id', crop.crop_id) + .first(); + expect(cropRes.crop_genus).toBe(crop.crop_genus); + }); + + test('should return 403 when an unauthorized tries to edit crop', async () => { + let newCrop = { ...crop, ...mocks.fakeCrop() }; + const res = await putCropRequest(newCrop, { user_id: unAuthorizedUser.user_id }); + expect(res.status).toBe(403); + const cropRes = await cropModel + .query() + .context({ showHidden: true }) + .where('crop_id', crop.crop_id) + .first(); + expect(cropRes.crop_genus).toBe(crop.crop_genus); + }); + + describe('circumventions', () => { + test('Circumvent authorization by modifying farm_id', async () => { + let newCrop = { ...crop, ...mocks.fakeCrop() }; + + const res = await putCropRequest(newCrop, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + expect(res.status).toBe(403); const cropRes = await cropModel .query() @@ -514,90 +500,44 @@ xdescribe('Authorization Tests', () => { .where('crop_id', crop.crop_id) .first(); expect(cropRes.crop_genus).toBe(crop.crop_genus); - done(); }); - }); - test('should return 403 when an unauthorized tries to edit crop', async (done) => { - let newCrop = { ...crop, ...mocks.fakeCrop() }; - putCropRequest(newCrop, { user_id: unAuthorizedUser.user_id }, async (err, res) => { + test('Unauthorized users should not edit a crop by change farm_id in req.body', async () => { + let newCrop = { ...crop, ...mocks.fakeCrop(), farm_id: farmunAuthorizedUser.farm_id }; + + const res = await putCropRequest(newCrop, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + expect(res.status).toBe(403); const cropRes = await cropModel .query() .context({ showHidden: true }) - .where('crop_id', crop.crop_id) + .where('crop_id', newCrop.crop_id) .first(); - expect(cropRes.crop_genus).toBe(crop.crop_genus); - done(); - }); - }); - - describe('circumventions', () => { - test('Circumvent authorization by modifying farm_id', async (done) => { - let newCrop = { ...crop, ...mocks.fakeCrop() }; - putCropRequest( - newCrop, - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - const cropRes = await cropModel - .query() - .context({ showHidden: true }) - .where('crop_id', crop.crop_id) - .first(); - expect(cropRes.crop_genus).toBe(crop.crop_genus); - done(); - }, - ); - }); - - test('Unauthorized users should not edit a crop by change farm_id in req.body', async (done) => { - let newCrop = { ...crop, ...mocks.fakeCrop(), farm_id: farmunAuthorizedUser.farm_id }; - putCropRequest( - newCrop, - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - const cropRes = await cropModel - .query() - .context({ showHidden: true }) - .where('crop_id', newCrop.crop_id) - .first(); - expect(cropRes.farm_id).toBe(crop.farm_id); - done(); - }, - ); + expect(cropRes.farm_id).toBe(crop.farm_id); }); // TODO: set crop.farm_id as immutable - xtest('Unauthorized user post crop to farm they do not have access to', async (done) => { + xtest('Unauthorized user post crop to farm they do not have access to', async () => { let [cropUnauthorizedUser] = await mocks.cropFactory({ promisedFarm: [farmunAuthorizedUser], }); let newCrop = { ...cropUnauthorizedUser, ...mocks.fakeCrop(), farm_id: farm.farm_id }; - putCropRequest( - newCrop, - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - async (err, res) => { - // expect(res.status).toBe(403); - const cropRes = await cropModel - .query() - .context({ showHidden: true }) - .where('crop_id', cropUnauthorizedUser.crop_id) - .first(); - expect(cropRes.farm_id).toBe(cropUnauthorizedUser.farm_id); - done(); - }, - ); + + const res = await putCropRequest(newCrop, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + // expect(res.status).toBe(403); + const cropRes = await cropModel + .query() + .context({ showHidden: true }) + .where('crop_id', cropUnauthorizedUser.crop_id) + .first(); + expect(cropRes.farm_id).toBe(cropUnauthorizedUser.farm_id); }); }); }); diff --git a/packages/api/tests/crop.test.js b/packages/api/tests/crop.test.js index 2ab258d740..3bb4747b8f 100644 --- a/packages/api/tests/crop.test.js +++ b/packages/api/tests/crop.test.js @@ -40,34 +40,33 @@ describe('Crop Tests', () => { token = global.token; }); - function postCropRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { - chai + function postCropRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post('/crop') .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function getRequest(url, { user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { - chai.request(server).get(url).set('user_id', user_id).set('farm_id', farm_id).end(callback); + function getRequest(url, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai.request(server).get(url).set('user_id', user_id).set('farm_id', farm_id); } - function putCropRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { + function putCropRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { const { crop_id } = data; - chai + + return chai .request(server) .put(`/crop/${crop_id}`) .set('farm_id', farm_id) .set('user_id', user_id) - .send(data) - .end(callback); + .send(data); } - function deleteRequest(url, { user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { - chai.request(server).delete(url).set('user_id', user_id).set('farm_id', farm_id).end(callback); + function deleteRequest(url, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai.request(server).delete(url).set('user_id', user_id).set('farm_id', farm_id); } function fakeUserFarm(role = 1) { @@ -92,10 +91,9 @@ describe('Crop Tests', () => { ); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('Get && delete && put crop', () => { @@ -126,36 +124,28 @@ describe('Crop Tests', () => { }); describe('Get crop', () => { - test('Workers should get crop by farm id', async (done) => { - getRequest(`/crop/farm/${farm.farm_id}`, { user_id: worker.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].crop_id).toBe(crop.crop_id); - done(); - }); + test('Workers should get crop by farm id', async () => { + const res = await getRequest(`/crop/farm/${farm.farm_id}`, { user_id: worker.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].crop_id).toBe(crop.crop_id); }); - xtest('Workers should get seeded crops', async (done) => { - getRequest(`/crop/farm/${farm.farm_id}`, { user_id: worker.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[1].crop_id).toBe(seededCrop.crop_id); - done(); - }); + xtest('Workers should get seeded crops', async () => { + const res = await getRequest(`/crop/farm/${farm.farm_id}`, { user_id: worker.user_id }); + expect(res.status).toBe(200); + expect(res.body[1].crop_id).toBe(seededCrop.crop_id); }); - test('Workers should get crop by id', async (done) => { - getRequest(`/crop/${crop.crop_id}`, { user_id: worker.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].crop_id).toBe(crop.crop_id); - done(); - }); + test('Workers should get crop by id', async () => { + const res = await getRequest(`/crop/${crop.crop_id}`, { user_id: worker.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].crop_id).toBe(crop.crop_id); }); - test('Should filter out deleted crop', async (done) => { + test('Should filter out deleted crop', async () => { await cropModel.query().context(newOwner).findById(crop.crop_id).delete(); - getRequest(`/crop/${crop.crop_id}`, { user_id: worker.user_id }, (err, res) => { - expect(res.status).toBe(404); - done(); - }); + const res = await getRequest(`/crop/${crop.crop_id}`, { user_id: worker.user_id }); + expect(res.status).toBe(404); }); describe('Get crop authorization tests', () => { @@ -193,42 +183,33 @@ describe('Crop Tests', () => { ); }); - test('Owner should get crop by farm id', async (done) => { - getRequest(`/crop/${crop.crop_id}`, { user_id: newOwner.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].crop_id).toBe(crop.crop_id); - done(); - }); + test('Owner should get crop by farm id', async () => { + const res = await getRequest(`/crop/${crop.crop_id}`, { user_id: newOwner.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].crop_id).toBe(crop.crop_id); }); - test('Manager should get crop by farm id', async (done) => { - getRequest(`/crop/${crop.crop_id}`, { user_id: manager.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].crop_id).toBe(crop.crop_id); - done(); - }); + test('Manager should get crop by farm id', async () => { + const res = await getRequest(`/crop/${crop.crop_id}`, { user_id: manager.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].crop_id).toBe(crop.crop_id); }); - test('Should get status 403 if an unauthorizedUser tries to get crop by farm id', async (done) => { - getRequest(`/crop/${crop.crop_id}`, { user_id: unAuthorizedUser.user_id }, (err, res) => { - expect(res.status).toBe(403); - done(); + test('Should get status 403 if an unauthorizedUser tries to get crop by farm id', async () => { + const res = await getRequest(`/crop/${crop.crop_id}`, { + user_id: unAuthorizedUser.user_id, }); + expect(res.status).toBe(403); }); // TODO switch to JWT - test('Circumvent authorization by modifying farm_id', async (done) => { - getRequest( - `/crop/${crop.crop_id}`, - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modifying farm_id', async () => { + const res = await getRequest(`/crop/${crop.crop_id}`, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); }); }); }); @@ -247,48 +228,40 @@ describe('Crop Tests', () => { ); }); - test('Owner should delete a crop that is referenced by a managementPlan', async (done) => { - deleteRequest(`/crop/${crop.crop_id}`, {}, async (err, res) => { - expect(res.status).toBe(200); - const crops = await cropModel - .query() - .whereDeleted() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(crops.length).toBe(1); - expect(crops[0].deleted).toBe(true); - expect(crops[0].crop_genus).toBe(crop.crop_genus); - done(); - }); + test('Owner should delete a crop that is referenced by a managementPlan', async () => { + const res = await deleteRequest(`/crop/${crop.crop_id}`, {}); + expect(res.status).toBe(200); + const crops = await cropModel + .query() + .whereDeleted() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(crops.length).toBe(1); + expect(crops[0].deleted).toBe(true); + expect(crops[0].crop_genus).toBe(crop.crop_genus); }); - test('should delete a crop that is not in use', async (done) => { - deleteRequest(`/crop/${cropNotInUse.crop_id}`, {}, async (err, res) => { - expect(res.status).toBe(200); - const cropsDeleted = await cropModel - .query() - .whereDeleted() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(cropsDeleted.length).toBe(1); - expect(cropsDeleted[0].deleted).toBe(true); - expect(cropsDeleted[0].crop_genus).toBe(cropNotInUse.crop_genus); - done(); - }); + test('should delete a crop that is not in use', async () => { + const res = await deleteRequest(`/crop/${cropNotInUse.crop_id}`, {}); + expect(res.status).toBe(200); + const cropsDeleted = await cropModel + .query() + .whereDeleted() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(cropsDeleted.length).toBe(1); + expect(cropsDeleted[0].deleted).toBe(true); + expect(cropsDeleted[0].crop_genus).toBe(cropNotInUse.crop_genus); }); - test('should return 403 if user tries to delete a seeded crop', async (done) => { - deleteRequest(`/crop/${seededCrop.crop_id}`, {}, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + test('should return 403 if user tries to delete a seeded crop', async () => { + const res = await deleteRequest(`/crop/${seededCrop.crop_id}`, {}); + expect(res.status).toBe(403); }); - test('should return 403 if user tries to delete a seeded crop with farm_id == null', async (done) => { - deleteRequest(`/crop/${seededCrop.crop_id}`, { farm_id: null }, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + test('should return 403 if user tries to delete a seeded crop with farm_id == null', async () => { + const res = await deleteRequest(`/crop/${seededCrop.crop_id}`, { farm_id: null }); + expect(res.status).toBe(403); }); describe('Delete crop Authorization test', () => { @@ -326,79 +299,58 @@ describe('Crop Tests', () => { ); }); - test('Manager should delete a crop that is not in use', async (done) => { - deleteRequest( - `/crop/${cropNotInUse.crop_id}`, - { user_id: manager.user_id }, - async (err, res) => { - expect(res.status).toBe(200); - const cropsDeleted = await cropModel - .query() - .whereDeleted() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(cropsDeleted.length).toBe(1); - expect(cropsDeleted[0].deleted).toBe(true); - expect(cropsDeleted[0].crop_genus).toBe(cropNotInUse.crop_genus); - done(); - }, - ); + test('Manager should delete a crop that is not in use', async () => { + const res = await deleteRequest(`/crop/${cropNotInUse.crop_id}`, { + user_id: manager.user_id, + }); + expect(res.status).toBe(200); + const cropsDeleted = await cropModel + .query() + .whereDeleted() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(cropsDeleted.length).toBe(1); + expect(cropsDeleted[0].deleted).toBe(true); + expect(cropsDeleted[0].crop_genus).toBe(cropNotInUse.crop_genus); }); - test('should return 403 if unauthorized user tries to delete a crop that is not in use', async (done) => { - deleteRequest( - `/crop/${cropNotInUse.crop_id}`, - { user_id: unAuthorizedUser.user_id }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('should return 403 if unauthorized user tries to delete a crop that is not in use', async () => { + const res = await deleteRequest(`/crop/${cropNotInUse.crop_id}`, { + user_id: unAuthorizedUser.user_id, + }); + expect(res.status).toBe(403); }); - test('Circumvent authorization by modifying farm_id', async (done) => { - deleteRequest( - `/crop/${cropNotInUse.crop_id}`, - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modifying farm_id', async () => { + const res = await deleteRequest(`/crop/${cropNotInUse.crop_id}`, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); }); - test('should return 403 if a worker tries to delete a crop that is not in use', async (done) => { - deleteRequest( - `/crop/${cropNotInUse.crop_id}`, - { user_id: worker.user_id }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('should return 403 if a worker tries to delete a crop that is not in use', async () => { + const res = await deleteRequest(`/crop/${cropNotInUse.crop_id}`, { + user_id: worker.user_id, + }); + expect(res.status).toBe(403); }); }); describe('Put crop', () => { - test('Owner should be able to edit a crop', async (done) => { + test('Owner should be able to edit a crop', async () => { let newCrop = { ...crop, ...mocks.fakeCrop() }; - putCropRequest(newCrop, {}, async (err, res) => { - expect(res.status).toBe(200); - const cropRes = await cropModel.query().where('crop_id', crop.crop_id).first(); - expect(cropRes.crop_genus).toBe(newCrop.crop_genus); - done(); - }); + const res = await putCropRequest(newCrop, {}); + expect(res.status).toBe(200); + const cropRes = await cropModel.query().where('crop_id', crop.crop_id).first(); + expect(cropRes.crop_genus).toBe(newCrop.crop_genus); }); - test('Should return 403 if user tries to edit a seeded crop', async (done) => { + test('Should return 403 if user tries to edit a seeded crop', async () => { let newCrop = { ...seededCrop, ...mocks.fakeCrop() }; - putCropRequest(newCrop, {}, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await putCropRequest(newCrop, {}); + expect(res.status).toBe(403); }); describe('Put crop authorization tests', () => { @@ -436,51 +388,41 @@ describe('Crop Tests', () => { ); }); - test('Manager should be able to edit a crop', async (done) => { + test('Manager should be able to edit a crop', async () => { let newCrop = { ...crop, ...mocks.fakeCrop() }; - putCropRequest(newCrop, { user_id: manager.user_id }, async (err, res) => { - expect(res.status).toBe(200); - const cropRes = await cropModel.query().where('crop_id', crop.crop_id).first(); - expect(cropRes.crop_genus).toBe(newCrop.crop_genus); - done(); - }); + const res = await putCropRequest(newCrop, { user_id: manager.user_id }); + expect(res.status).toBe(200); + const cropRes = await cropModel.query().where('crop_id', crop.crop_id).first(); + expect(cropRes.crop_genus).toBe(newCrop.crop_genus); }); - test('should return 403 when a worker tries to edit crop', async (done) => { + test('should return 403 when a worker tries to edit crop', async () => { let newCrop = { ...crop, ...mocks.fakeCrop() }; - putCropRequest(newCrop, { user_id: worker.user_id }, async (err, res) => { - expect(res.status).toBe(403); - const cropRes = await cropModel.query().where('crop_id', crop.crop_id).first(); - expect(cropRes.crop_genus).toBe(crop.crop_genus); - done(); - }); + const res = await putCropRequest(newCrop, { user_id: worker.user_id }); + expect(res.status).toBe(403); + const cropRes = await cropModel.query().where('crop_id', crop.crop_id).first(); + expect(cropRes.crop_genus).toBe(crop.crop_genus); }); - test('should return 403 when an unauthorized tries to edit crop', async (done) => { + test('should return 403 when an unauthorized tries to edit crop', async () => { let newCrop = { ...crop, ...mocks.fakeCrop() }; - putCropRequest(newCrop, { user_id: unAuthorizedUser.user_id }, async (err, res) => { - expect(res.status).toBe(403); - const cropRes = await cropModel.query().where('crop_id', crop.crop_id).first(); - expect(cropRes.crop_genus).toBe(crop.crop_genus); - done(); - }); + const res = await putCropRequest(newCrop, { user_id: unAuthorizedUser.user_id }); + expect(res.status).toBe(403); + const cropRes = await cropModel.query().where('crop_id', crop.crop_id).first(); + expect(cropRes.crop_genus).toBe(crop.crop_genus); }); - test('Circumvent authorization by modifying farm_id', async (done) => { + test('Circumvent authorization by modifying farm_id', async () => { let newCrop = { ...crop, ...mocks.fakeCrop() }; - putCropRequest( - newCrop, - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - const cropRes = await cropModel.query().where('crop_id', crop.crop_id).first(); - expect(cropRes.crop_genus).toBe(crop.crop_genus); - done(); - }, - ); + + const res = await putCropRequest(newCrop, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); + const cropRes = await cropModel.query().where('crop_id', crop.crop_id).first(); + expect(cropRes.crop_genus).toBe(crop.crop_genus); }); }); }); @@ -488,49 +430,41 @@ describe('Crop Tests', () => { }); describe('Post crop', () => { - test('should return 400 status if crop is posted w/o crop_common_name', async (done) => { + test('should return 400 status if crop is posted w/o crop_common_name', async () => { let crop = fakeCrop(); delete crop.crop_common_name; - postCropRequest(crop, {}, (err, res) => { - expect(res.status).toBe(400); - expect(JSON.parse(res.error.text).error.data.crop_common_name[0].keyword).toBe('required'); - done(); - }); + const res = await postCropRequest(crop, {}); + expect(res.status).toBe(400); + expect(JSON.parse(res.error.text).error.data.crop_common_name[0].keyword).toBe('required'); }); - test('should return 403 status if headers.farm_id is set to null', async (done) => { + test('should return 403 status if headers.farm_id is set to null', async () => { let crop = fakeCrop(); crop.farm_id = null; - postCropRequest(crop, {}, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await postCropRequest(crop, {}); + expect(res.status).toBe(403); }); - test('should post and get a valid crop', async (done) => { + test('should post and get a valid crop', async () => { let crop = fakeCrop(); crop.crop_common_name = `${crop.crop_specie} - ${crop.crop_genus}`; - postCropRequest(crop, {}, async (err, res) => { - expect(res.status).toBe(201); - const crops = await cropModel.query().where('farm_id', farm.farm_id); - expect(crops.length).toBe(1); - expect(crops[0].crop_common_name).toBe(crop.crop_common_name); - done(); - }); + const res = await postCropRequest(crop, {}); + expect(res.status).toBe(201); + const crops = await cropModel.query().where('farm_id', farm.farm_id); + expect(crops.length).toBe(1); + expect(crops[0].crop_common_name).toBe(crop.crop_common_name); }); describe('crop_common_name + genus + species uniqueness tests', function () { - test('should return 400 status if crop is posted w/o variety name', async (done) => { + test('should return 400 status if crop is posted w/o variety name', async () => { let crop = fakeCrop(); crop.crop_common_name = `${crop.crop_specie} - ${crop.crop_genus}`; [crop] = await mocks.cropFactory({ promisedFarm: [farm], createdUser: [newOwner] }, crop); - postCropRequest(crop, {}, (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postCropRequest(crop, {}); + expect(res.status).toBe(400); }); - test('should post a crop and its variety', async (done) => { + test('should post a crop and its variety', async () => { let crop = fakeCrop(); crop.crop_common_name = `${crop.crop_specie} - ${crop.crop_genus}`; const [crop1] = await mocks.cropFactory( @@ -538,14 +472,12 @@ describe('Crop Tests', () => { crop, ); crop.crop_common_name += ' - 1'; - postCropRequest(crop, {}, async (err, res) => { - expect(res.status).toBe(201); - const crops = await cropModel.query().where('farm_id', farm.farm_id); - expect(crops.length).toBe(2); - expect(crops[0].crop_common_name).toBe(crop1.crop_common_name); - expect(crops[1].crop_common_name).toBe(crop.crop_common_name); - done(); - }); + const res = await postCropRequest(crop, {}); + expect(res.status).toBe(201); + const crops = await cropModel.query().where('farm_id', farm.farm_id); + expect(crops.length).toBe(2); + expect(crops[0].crop_common_name).toBe(crop1.crop_common_name); + expect(crops[1].crop_common_name).toBe(crop.crop_common_name); }); }); @@ -584,53 +516,43 @@ describe('Crop Tests', () => { ); }); - test('owner should return 403 status if crop is posted by unauthorized user', async (done) => { + test('owner should return 403 status if crop is posted by unauthorized user', async () => { let crop = fakeCrop(); crop.crop_common_name = `${crop.crop_specie} - ${crop.crop_genus}`; - postCropRequest(crop, { user_id: unAuthorizedUser.user_id }, (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('User does not have the following permission(s): add:crops'); - done(); - }); + const res = await postCropRequest(crop, { user_id: unAuthorizedUser.user_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): add:crops'); }); - test('should return 403 status if crop is posted by newWorker', async (done) => { + test('should return 403 status if crop is posted by newWorker', async () => { let crop = fakeCrop(); crop.crop_common_name = `${crop.crop_specie} - ${crop.crop_genus}`; - postCropRequest(crop, { user_id: worker.user_id }, (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('User does not have the following permission(s): add:crops'); - done(); - }); + const res = await postCropRequest(crop, { user_id: worker.user_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): add:crops'); }); - test('manager should post and get a valid crop', async (done) => { + test('manager should post and get a valid crop', async () => { let crop = fakeCrop(); crop.crop_common_name = `${crop.crop_specie} - ${crop.crop_genus}`; - postCropRequest(crop, { user_id: manager.user_id }, async (err, res) => { - expect(res.status).toBe(201); - const crops = await cropModel.query().where('farm_id', farm.farm_id); - expect(crops.length).toBe(1); - expect(crops[0].crop_common_name).toBe(crop.crop_common_name); - done(); - }); + const res = await postCropRequest(crop, { user_id: manager.user_id }); + expect(res.status).toBe(201); + const crops = await cropModel.query().where('farm_id', farm.farm_id); + expect(crops.length).toBe(1); + expect(crops[0].crop_common_name).toBe(crop.crop_common_name); }); - test('Circumvent authorization by modify farm_id', async (done) => { + test('Circumvent authorization by modify farm_id', async () => { let crop = fakeCrop(); crop.crop_common_name = `${crop.crop_specie} - ${crop.crop_genus}`; - postCropRequest( - crop, - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('user not authorized to access farm'); - done(); - }, - ); + + const res = await postCropRequest(crop, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); + expect(res.error.text).toBe('user not authorized to access farm'); }); }); }); diff --git a/packages/api/tests/crop_variety.test.js b/packages/api/tests/crop_variety.test.js index daa9df2474..81c4f2edc1 100644 --- a/packages/api/tests/crop_variety.test.js +++ b/packages/api/tests/crop_variety.test.js @@ -42,42 +42,33 @@ describe('CropVariety Tests', () => { token = global.token; }); - function postCropVarietyRequest( - data, - { user_id = newOwner.user_id, farm_id = farm.farm_id }, - callback, - ) { - chai + function postCropVarietyRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post('/crop_variety') .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function getRequest(url, { user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { - chai.request(server).get(url).set('user_id', user_id).set('farm_id', farm_id).end(callback); + function getRequest(url, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai.request(server).get(url).set('user_id', user_id).set('farm_id', farm_id); } - function putCropVarietyRequest( - data, - { user_id = newOwner.user_id, farm_id = farm.farm_id }, - callback, - ) { + function putCropVarietyRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { const { crop_variety_id } = data; - chai + + return chai .request(server) .put(`/crop_variety/${crop_variety_id}`) .set('farm_id', farm_id) .set('user_id', user_id) - .send(data) - .end(callback); + .send(data); } - function deleteRequest(url, { user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { - chai.request(server).delete(url).set('user_id', user_id).set('farm_id', farm_id).end(callback); + function deleteRequest(url, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai.request(server).delete(url).set('user_id', user_id).set('farm_id', farm_id); } function fakeUserFarm(role = 1) { @@ -101,10 +92,9 @@ describe('CropVariety Tests', () => { ); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('Get && delete && put cropVariety', () => { @@ -128,44 +118,35 @@ describe('CropVariety Tests', () => { }); describe('Get cropVariety', () => { - test('Workers should get cropVariety by farm id', async (done) => { - getRequest( - `/crop_variety/farm/${farm.farm_id}`, - { user_id: worker.user_id }, - (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].crop_variety_id).toBe(cropVariety.crop_variety_id); - done(); - }, - ); + test('Workers should get cropVariety by farm id', async () => { + const res = await getRequest(`/crop_variety/farm/${farm.farm_id}`, { + user_id: worker.user_id, + }); + expect(res.status).toBe(200); + expect(res.body[0].crop_variety_id).toBe(cropVariety.crop_variety_id); }); - test('Workers should get cropVariety by id', async (done) => { - getRequest( - `/crop_variety/${cropVariety.crop_variety_id}`, - { user_id: worker.user_id }, - (err, res) => { - expect(res.status).toBe(200); - expect(res.body.crop_variety_id).toBe(cropVariety.crop_variety_id); - done(); - }, - ); + test('Workers should get cropVariety by id', async () => { + const res = await getRequest(`/crop_variety/${cropVariety.crop_variety_id}`, { + user_id: worker.user_id, + }); + + expect(res.status).toBe(200); + expect(res.body.crop_variety_id).toBe(cropVariety.crop_variety_id); }); - test('Should filter out deleted cropVariety', async (done) => { + test('Should filter out deleted cropVariety', async () => { await cropVarietyModel .query() .context(newOwner) .findById(cropVariety.crop_variety_id) .delete(); - getRequest( - `/crop_variety/${cropVariety.crop_variety_id}`, - { user_id: worker.user_id }, - (err, res) => { - expect(res.status).toBe(404); - done(); - }, - ); + + const res = await getRequest(`/crop_variety/${cropVariety.crop_variety_id}`, { + user_id: worker.user_id, + }); + + expect(res.status).toBe(404); }); describe('Get cropVariety authorization tests', () => { @@ -203,53 +184,39 @@ describe('CropVariety Tests', () => { ); }); - test('Owner should get cropVariety by farm id', async (done) => { - getRequest( - `/crop_variety/${cropVariety.crop_variety_id}`, - { user_id: newOwner.user_id }, - (err, res) => { - expect(res.status).toBe(200); - expect(res.body.crop_variety_id).toBe(cropVariety.crop_variety_id); - done(); - }, - ); + test('Owner should get cropVariety by farm id', async () => { + const res = await getRequest(`/crop_variety/${cropVariety.crop_variety_id}`, { + user_id: newOwner.user_id, + }); + + expect(res.status).toBe(200); + expect(res.body.crop_variety_id).toBe(cropVariety.crop_variety_id); }); - test('Manager should get cropVariety by farm id', async (done) => { - getRequest( - `/crop_variety/${cropVariety.crop_variety_id}`, - { user_id: manager.user_id }, - (err, res) => { - expect(res.status).toBe(200); - expect(res.body.crop_variety_id).toBe(cropVariety.crop_variety_id); - done(); - }, - ); + test('Manager should get cropVariety by farm id', async () => { + const res = await getRequest(`/crop_variety/${cropVariety.crop_variety_id}`, { + user_id: manager.user_id, + }); + + expect(res.status).toBe(200); + expect(res.body.crop_variety_id).toBe(cropVariety.crop_variety_id); }); - test('Should get status 403 if an unauthorizedUser tries to get cropVariety by farm id', async (done) => { - getRequest( - `/crop_variety/${cropVariety.crop_variety_id}`, - { user_id: unAuthorizedUser.user_id }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Should get status 403 if an unauthorizedUser tries to get cropVariety by farm id', async () => { + const res = await getRequest(`/crop_variety/${cropVariety.crop_variety_id}`, { + user_id: unAuthorizedUser.user_id, + }); + + expect(res.status).toBe(403); }); - test('Circumvent authorization by modifying farm_id', async (done) => { - getRequest( - `/crop_variety/${cropVariety.crop_variety_id}`, - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modifying farm_id', async () => { + const res = await getRequest(`/crop_variety/${cropVariety.crop_variety_id}`, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); }); }); }); @@ -267,28 +234,22 @@ describe('CropVariety Tests', () => { ); }); - test('should delete a cropVariety that is not in use', async (done) => { - deleteRequest( - `/crop_variety/${cropVarietyNotInUse.crop_variety_id}`, - {}, - async (err, res) => { - expect(res.status).toBe(200); - const cropVarietysDeleted = await cropVarietyModel - .query() - .whereDeleted() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(cropVarietysDeleted.length).toBe(1); - expect(cropVarietysDeleted[0].deleted).toBe(true); - expect(cropVarietysDeleted[0].crop_variety_name).toBe( - cropVarietyNotInUse.crop_variety_name, - ); - done(); - }, + test('should delete a cropVariety that is not in use', async () => { + const res = await deleteRequest(`/crop_variety/${cropVarietyNotInUse.crop_variety_id}`, {}); + expect(res.status).toBe(200); + const cropVarietysDeleted = await cropVarietyModel + .query() + .whereDeleted() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(cropVarietysDeleted.length).toBe(1); + expect(cropVarietysDeleted[0].deleted).toBe(true); + expect(cropVarietysDeleted[0].crop_variety_name).toBe( + cropVarietyNotInUse.crop_variety_name, ); }); - test('Should delete a cropVariety referenced by a completed management plan', async (done) => { + test('Should delete a cropVariety referenced by a completed management plan', async () => { const [{ farm_id, user_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 1 }, @@ -301,29 +262,21 @@ describe('CropVariety Tests', () => { complete_date: new Date('December 18, 1995 03:24:00'), }, ); - deleteRequest( - `/crop_variety/${crop_variety_id}`, - { user_id, farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - const cropVarietiesDeleted = await cropVarietyModel - .query() - .whereDeleted() - .context({ showHidden: true }) - .where('farm_id', farm_id); - expect(cropVarietiesDeleted.length).toBe(1); - expect(cropVarietiesDeleted[0].deleted).toBe(true); - expect(cropVarietiesDeleted[0].crop_variety_id).toBe(crop_variety_id); - const managementPlan = await knex('management_plan') - .where({ management_plan_id }) - .first(); - expect(managementPlan.deleted).toBe(true); - done(); - }, - ); + const res = await deleteRequest(`/crop_variety/${crop_variety_id}`, { user_id, farm_id }); + expect(res.status).toBe(200); + const cropVarietiesDeleted = await cropVarietyModel + .query() + .whereDeleted() + .context({ showHidden: true }) + .where('farm_id', farm_id); + expect(cropVarietiesDeleted.length).toBe(1); + expect(cropVarietiesDeleted[0].deleted).toBe(true); + expect(cropVarietiesDeleted[0].crop_variety_id).toBe(crop_variety_id); + const managementPlan = await knex('management_plan').where({ management_plan_id }).first(); + expect(managementPlan.deleted).toBe(true); }); - test('Should delete a cropVariety referenced by a abandoned management plan', async (done) => { + test('Should delete a cropVariety referenced by a abandoned management plan', async () => { const [{ farm_id, user_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 1 }, @@ -336,29 +289,21 @@ describe('CropVariety Tests', () => { abandon_date: new Date('December 18, 1995 03:24:00'), }, ); - deleteRequest( - `/crop_variety/${crop_variety_id}`, - { user_id, farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - const cropVarietiesDeleted = await cropVarietyModel - .query() - .whereDeleted() - .context({ showHidden: true }) - .where('farm_id', farm_id); - expect(cropVarietiesDeleted.length).toBe(1); - expect(cropVarietiesDeleted[0].deleted).toBe(true); - expect(cropVarietiesDeleted[0].crop_variety_id).toBe(crop_variety_id); - const managementPlan = await knex('management_plan') - .where({ management_plan_id }) - .first(); - expect(managementPlan.deleted).toBe(true); - done(); - }, - ); + const res = await deleteRequest(`/crop_variety/${crop_variety_id}`, { user_id, farm_id }); + expect(res.status).toBe(200); + const cropVarietiesDeleted = await cropVarietyModel + .query() + .whereDeleted() + .context({ showHidden: true }) + .where('farm_id', farm_id); + expect(cropVarietiesDeleted.length).toBe(1); + expect(cropVarietiesDeleted[0].deleted).toBe(true); + expect(cropVarietiesDeleted[0].crop_variety_id).toBe(crop_variety_id); + const managementPlan = await knex('management_plan').where({ management_plan_id }).first(); + expect(managementPlan.deleted).toBe(true); }); - test('Management plan with any complete date or abandon date is considered completed or abandoned', async (done) => { + test('Management plan with any complete date or abandon date is considered completed or abandoned', async () => { const [{ farm_id, user_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 1 }, @@ -371,25 +316,19 @@ describe('CropVariety Tests', () => { abandon_date: new Date(faker.date.future()), }, ); - deleteRequest( - `/crop_variety/${crop_variety_id}`, - { user_id, farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - const cropVarietiesDeleted = await cropVarietyModel - .query() - .whereDeleted() - .context({ showHidden: true }) - .where('farm_id', farm_id); - expect(cropVarietiesDeleted.length).toBe(1); - expect(cropVarietiesDeleted[0].deleted).toBe(true); - expect(cropVarietiesDeleted[0].crop_variety_id).toBe(crop_variety_id); - done(); - }, - ); + const res = await deleteRequest(`/crop_variety/${crop_variety_id}`, { user_id, farm_id }); + expect(res.status).toBe(200); + const cropVarietiesDeleted = await cropVarietyModel + .query() + .whereDeleted() + .context({ showHidden: true }) + .where('farm_id', farm_id); + expect(cropVarietiesDeleted.length).toBe(1); + expect(cropVarietiesDeleted[0].deleted).toBe(true); + expect(cropVarietiesDeleted[0].crop_variety_id).toBe(crop_variety_id); }); - test('Should not delete a cropVariety that is part of an active management plan', async (done) => { + test('Should not delete a cropVariety that is part of an active management plan', async () => { const [{ farm_id, user_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 1 }, @@ -400,20 +339,17 @@ describe('CropVariety Tests', () => { }, {}, ); - deleteRequest( - `/crop_variety/${managementPlan.crop_variety_id}`, - { user_id, farm_id }, - async (err, res) => { - expect(res.status).toBe(400); - const cropVarietyNotDeleted = await cropVarietyModel - .query() - .whereDeleted() - .context({ showHidden: false }) - .where('farm_id', farm_id); - expect(cropVarietyNotDeleted.length).toBe(0); - done(); - }, - ); + const res = await deleteRequest(`/crop_variety/${managementPlan.crop_variety_id}`, { + user_id, + farm_id, + }); + expect(res.status).toBe(400); + const cropVarietyNotDeleted = await cropVarietyModel + .query() + .whereDeleted() + .context({ showHidden: false }) + .where('farm_id', farm_id); + expect(cropVarietyNotDeleted.length).toBe(0); }); describe('Delete cropVariety Authorization test', () => { @@ -451,7 +387,7 @@ describe('CropVariety Tests', () => { ); }); - test('Manager should delete a cropVariety that has past management plan', async (done) => { + test('Manager should delete a cropVariety that has past management plan', async () => { const [{ farm_id, user_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 2 }, @@ -466,73 +402,57 @@ describe('CropVariety Tests', () => { }, ); console.log(crop_variety_id); - deleteRequest( - `/crop_variety/${crop_variety_id}`, - { user_id, farm_id }, - async (err, response) => { - expect(response.status).toBe(200); - const cropVarietiesDeleted = await cropVarietyModel - .query() - .whereDeleted() - .context({ showHidden: true }) - .where('farm_id', farm_id); - expect(cropVarietiesDeleted.length).toBe(1); - expect(cropVarietiesDeleted[0].deleted).toBe(true); - expect(cropVarietiesDeleted[0].crop_variety_id).toBe(crop_variety_id); - done(); - }, - ); + const response = await deleteRequest(`/crop_variety/${crop_variety_id}`, { + user_id, + farm_id, + }); + expect(response.status).toBe(200); + const cropVarietiesDeleted = await cropVarietyModel + .query() + .whereDeleted() + .context({ showHidden: true }) + .where('farm_id', farm_id); + expect(cropVarietiesDeleted.length).toBe(1); + expect(cropVarietiesDeleted[0].deleted).toBe(true); + expect(cropVarietiesDeleted[0].crop_variety_id).toBe(crop_variety_id); }); - test('should return 403 if unauthorized user tries to delete a cropVariety that is not in use', async (done) => { - deleteRequest( - `/crop_variety/${cropVarietyNotInUse.crop_variety_id}`, - { user_id: unAuthorizedUser.user_id }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('should return 403 if unauthorized user tries to delete a cropVariety that is not in use', async () => { + const res = await deleteRequest(`/crop_variety/${cropVarietyNotInUse.crop_variety_id}`, { + user_id: unAuthorizedUser.user_id, + }); + + expect(res.status).toBe(403); }); - test('Circumvent authorization by modifying farm_id', async (done) => { - deleteRequest( - `/crop_variety/${cropVarietyNotInUse.crop_variety_id}`, - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modifying farm_id', async () => { + const res = await deleteRequest(`/crop_variety/${cropVarietyNotInUse.crop_variety_id}`, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); }); - test('should return 403 if a worker tries to delete a cropVariety that is not in use', async (done) => { - deleteRequest( - `/crop_variety/${cropVarietyNotInUse.crop_variety_id}`, - { user_id: worker.user_id }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('should return 403 if a worker tries to delete a cropVariety that is not in use', async () => { + const res = await deleteRequest(`/crop_variety/${cropVarietyNotInUse.crop_variety_id}`, { + user_id: worker.user_id, + }); + + expect(res.status).toBe(403); }); }); describe('Put cropVariety', () => { - test('Owner should be able to edit a cropVariety', async (done) => { + test('Owner should be able to edit a cropVariety', async () => { const newCropVariety = { ...cropVariety, ...mocks.fakeCropVariety() }; - putCropVarietyRequest(newCropVariety, {}, async (err, res) => { - expect(res.status).toBe(200); - const cropVarietyRes = await cropVarietyModel - .query() - .where('crop_variety_id', cropVariety.crop_variety_id) - .first(); - expect(cropVarietyRes.crop_variety_name).toBe(newCropVariety.crop_variety_name); - done(); - }); + const res = await putCropVarietyRequest(newCropVariety, {}); + expect(res.status).toBe(200); + const cropVarietyRes = await cropVarietyModel + .query() + .where('crop_variety_id', cropVariety.crop_variety_id) + .first(); + expect(cropVarietyRes.crop_variety_name).toBe(newCropVariety.crop_variety_name); }); describe('Put cropVariety authorization tests', () => { @@ -570,71 +490,55 @@ describe('CropVariety Tests', () => { ); }); - test('Manager should be able to edit a cropVariety', async (done) => { + test('Manager should be able to edit a cropVariety', async () => { const newCropVariety = { ...cropVariety, ...mocks.fakeCropVariety() }; - putCropVarietyRequest( - newCropVariety, - { user_id: manager.user_id }, - async (err, res) => { - expect(res.status).toBe(200); - const cropVarietyRes = await cropVarietyModel - .query() - .where('crop_variety_id', cropVariety.crop_variety_id) - .first(); - expect(cropVarietyRes.crop_variety_name).toBe(newCropVariety.crop_variety_name); - done(); - }, - ); + const res = await putCropVarietyRequest(newCropVariety, { user_id: manager.user_id }); + expect(res.status).toBe(200); + const cropVarietyRes = await cropVarietyModel + .query() + .where('crop_variety_id', cropVariety.crop_variety_id) + .first(); + expect(cropVarietyRes.crop_variety_name).toBe(newCropVariety.crop_variety_name); }); - test('should return 403 when a worker tries to edit cropVariety', async (done) => { + test('should return 403 when a worker tries to edit cropVariety', async () => { const newCropVariety = { ...cropVariety, ...mocks.fakeCropVariety() }; - putCropVarietyRequest(newCropVariety, { user_id: worker.user_id }, async (err, res) => { - expect(res.status).toBe(403); - const cropVarietyRes = await cropVarietyModel - .query() - .where('crop_variety_id', cropVariety.crop_variety_id) - .first(); - expect(cropVarietyRes.crop_variety_name).toBe(cropVariety.crop_variety_name); - done(); - }); + const res = await putCropVarietyRequest(newCropVariety, { user_id: worker.user_id }); + expect(res.status).toBe(403); + const cropVarietyRes = await cropVarietyModel + .query() + .where('crop_variety_id', cropVariety.crop_variety_id) + .first(); + expect(cropVarietyRes.crop_variety_name).toBe(cropVariety.crop_variety_name); }); - test('should return 403 when an unauthorized tries to edit cropVariety', async (done) => { + test('should return 403 when an unauthorized tries to edit cropVariety', async () => { const newCropVariety = { ...cropVariety, ...mocks.fakeCropVariety() }; - putCropVarietyRequest( - newCropVariety, - { user_id: unAuthorizedUser.user_id }, - async (err, res) => { - expect(res.status).toBe(403); - const cropVarietyRes = await cropVarietyModel - .query() - .where('crop_variety_id', cropVariety.crop_variety_id) - .first(); - expect(cropVarietyRes.crop_variety_name).toBe(cropVariety.crop_variety_name); - done(); - }, - ); + const res = await putCropVarietyRequest(newCropVariety, { + user_id: unAuthorizedUser.user_id, + }); + expect(res.status).toBe(403); + const cropVarietyRes = await cropVarietyModel + .query() + .where('crop_variety_id', cropVariety.crop_variety_id) + .first(); + expect(cropVarietyRes.crop_variety_name).toBe(cropVariety.crop_variety_name); }); - test('Circumvent authorization by modifying farm_id', async (done) => { + test('Circumvent authorization by modifying farm_id', async () => { const newCropVariety = { ...cropVariety, ...mocks.fakeCropVariety() }; - putCropVarietyRequest( - newCropVariety, - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - const cropVarietyRes = await cropVarietyModel - .query() - .where('crop_variety_id', cropVariety.crop_variety_id) - .first(); - expect(cropVarietyRes.crop_variety_name).toBe(cropVariety.crop_variety_name); - done(); - }, - ); + + const res = await putCropVarietyRequest(newCropVariety, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); + const cropVarietyRes = await cropVarietyModel + .query() + .where('crop_variety_id', cropVariety.crop_variety_id) + .first(); + expect(cropVarietyRes.crop_variety_name).toBe(cropVariety.crop_variety_name); }); }); }); @@ -647,40 +551,34 @@ describe('CropVariety Tests', () => { [crop] = await mocks.cropFactory({ promisedFarm: [farm] }); }); - test('should return 400 status if cropVariety is posted w/o crop_variety_name', async (done) => { + test('should return 400 status if cropVariety is posted w/o crop_variety_name', async () => { const cropVariety = fakeCropVariety(crop.crop_id); delete cropVariety.crop_variety_name; - postCropVarietyRequest(cropVariety, {}, (err, res) => { - expect(res.status).toBe(400); - expect(JSON.parse(res.error.text).error.data.crop_variety_name[0].keyword).toBe('required'); - done(); - }); + const res = await postCropVarietyRequest(cropVariety, {}); + expect(res.status).toBe(400); + expect(JSON.parse(res.error.text).error.data.crop_variety_name[0].keyword).toBe('required'); }); - test('should return 403 status if headers.farm_id is set to null', async (done) => { + test('should return 403 status if headers.farm_id is set to null', async () => { const cropVariety = fakeCropVariety(crop.crop_id); cropVariety.farm_id = null; - postCropVarietyRequest(cropVariety, {}, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await postCropVarietyRequest(cropVariety, {}); + expect(res.status).toBe(403); }); - test('should post and get a valid cropVariety', async (done) => { + test('should post and get a valid cropVariety', async () => { const cropVariety = fakeCropVariety(crop.crop_id); cropVariety.crop_variety_name = `${cropVariety.cropVariety_specie} - ${cropVariety.crop_variety_name}`; delete cropVariety.nutrient_credits; - postCropVarietyRequest(cropVariety, {}, async (err, res) => { - expect(res.status).toBe(201); - const cropVarietys = await knex('crop_variety').where('farm_id', farm.farm_id); - expect(cropVarietys.length).toBe(1); - expect(cropVarietys[0].crop_variety_name).toBe(cropVariety.crop_variety_name); - expect(cropVarietys[0].nutrient_credits).toBe(crop.nutrient_credits); - done(); - }); + const res = await postCropVarietyRequest(cropVariety, {}); + expect(res.status).toBe(201); + const cropVarietys = await knex('crop_variety').where('farm_id', farm.farm_id); + expect(cropVarietys.length).toBe(1); + expect(cropVarietys[0].crop_variety_name).toBe(cropVariety.crop_variety_name); + expect(cropVarietys[0].nutrient_credits).toBe(crop.nutrient_credits); }); - test('should post and get a valid cropVariety with null compliance info', async (done) => { + test('should post and get a valid cropVariety with null compliance info', async () => { const cropVariety = fakeCropVariety(crop.crop_id); cropVariety.crop_variety_name = `${cropVariety.cropVariety_specie} - ${cropVariety.crop_variety_name}`; cropVariety.compliance_file_url = ''; @@ -688,31 +586,27 @@ describe('CropVariety Tests', () => { cropVariety.treated = null; cropVariety.genetically_engineered = null; cropVariety.searched = null; - postCropVarietyRequest(cropVariety, {}, async (err, res) => { - expect(res.status).toBe(201); - const cropVarietys = await cropVarietyModel.query().where('farm_id', farm.farm_id); - expect(cropVarietys.length).toBe(1); - expect(cropVarietys[0].crop_variety_name).toBe(cropVariety.crop_variety_name); - expect(cropVarietys[0].organic).toBe(null); - done(); - }); + const res = await postCropVarietyRequest(cropVariety, {}); + expect(res.status).toBe(201); + const cropVarietys = await cropVarietyModel.query().where('farm_id', farm.farm_id); + expect(cropVarietys.length).toBe(1); + expect(cropVarietys[0].crop_variety_name).toBe(cropVariety.crop_variety_name); + expect(cropVarietys[0].organic).toBe(null); }); describe('crop_variety_name + genus + species uniqueness tests', function () { - test('should return 400 status if cropVariety is posted w/o variety name', async (done) => { + test('should return 400 status if cropVariety is posted w/o variety name', async () => { let cropVariety = fakeCropVariety(crop.crop_id); cropVariety.crop_variety_name = `${cropVariety.cropVariety_specie} - ${cropVariety.crop_variety_name}`; [cropVariety] = await mocks.crop_varietyFactory( { promisedFarm: [farm], createdUser: [newOwner] }, cropVariety, ); - postCropVarietyRequest(cropVariety, {}, (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postCropVarietyRequest(cropVariety, {}); + expect(res.status).toBe(400); }); - test('should post a cropVariety and its variety', async (done) => { + test('should post a cropVariety and its variety', async () => { const cropVariety = fakeCropVariety(crop.crop_id); cropVariety.crop_variety_name = `${cropVariety.cropVariety_specie} - ${cropVariety.crop_variety_name}`; const [cropVariety1] = await mocks.crop_varietyFactory( @@ -723,14 +617,12 @@ describe('CropVariety Tests', () => { cropVariety, ); cropVariety.crop_variety_name += ' - 1'; - postCropVarietyRequest(cropVariety, {}, async (err, res) => { - expect(res.status).toBe(201); - const cropVarietys = await cropVarietyModel.query().where('farm_id', farm.farm_id); - expect(cropVarietys.length).toBe(2); - expect(cropVarietys[0].crop_variety_name).toBe(cropVariety1.crop_variety_name); - expect(cropVarietys[1].crop_variety_name).toBe(cropVariety.crop_variety_name); - done(); - }); + const res = await postCropVarietyRequest(cropVariety, {}); + expect(res.status).toBe(201); + const cropVarietys = await cropVarietyModel.query().where('farm_id', farm.farm_id); + expect(cropVarietys.length).toBe(2); + expect(cropVarietys[0].crop_variety_name).toBe(cropVariety1.crop_variety_name); + expect(cropVarietys[1].crop_variety_name).toBe(cropVariety.crop_variety_name); }); }); @@ -771,57 +663,49 @@ describe('CropVariety Tests', () => { [crop] = await mocks.cropFactory({ promisedFarm: [farm] }); }); - test('owner should return 403 status if cropVariety is posted by unauthorized user', async (done) => { + test('owner should return 403 status if cropVariety is posted by unauthorized user', async () => { const cropVariety = fakeCropVariety(crop.crop_id); cropVariety.crop_variety_name = `${cropVariety.cropVariety_specie} - ${cropVariety.crop_variety_name}`; - postCropVarietyRequest(cropVariety, { user_id: unAuthorizedUser.user_id }, (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): add:crop_variety', - ); - done(); + const res = await postCropVarietyRequest(cropVariety, { + user_id: unAuthorizedUser.user_id, }); + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): add:crop_variety', + ); }); - test('should return 403 status if cropVariety is posted by newWorker', async (done) => { + test('should return 403 status if cropVariety is posted by newWorker', async () => { const cropVariety = fakeCropVariety(crop.crop_id); cropVariety.crop_variety_name = `${cropVariety.cropVariety_specie} - ${cropVariety.crop_variety_name}`; - postCropVarietyRequest(cropVariety, { user_id: worker.user_id }, (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): add:crop_variety', - ); - done(); - }); + const res = await postCropVarietyRequest(cropVariety, { user_id: worker.user_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): add:crop_variety', + ); }); - test('manager should post and get a valid cropVariety', async (done) => { + test('manager should post and get a valid cropVariety', async () => { const cropVariety = fakeCropVariety(crop.crop_id); cropVariety.crop_variety_name = `${cropVariety.cropVariety_specie} - ${cropVariety.crop_variety_name}`; - postCropVarietyRequest(cropVariety, { user_id: manager.user_id }, async (err, res) => { - expect(res.status).toBe(201); - const cropVarietys = await cropVarietyModel.query().where('farm_id', farm.farm_id); - expect(cropVarietys.length).toBe(1); - expect(cropVarietys[0].crop_variety_name).toBe(cropVariety.crop_variety_name); - done(); - }); + const res = await postCropVarietyRequest(cropVariety, { user_id: manager.user_id }); + expect(res.status).toBe(201); + const cropVarietys = await cropVarietyModel.query().where('farm_id', farm.farm_id); + expect(cropVarietys.length).toBe(1); + expect(cropVarietys[0].crop_variety_name).toBe(cropVariety.crop_variety_name); }); - test('Circumvent authorization by modify farm_id', async (done) => { + test('Circumvent authorization by modify farm_id', async () => { const cropVariety = fakeCropVariety(crop.crop_id); cropVariety.crop_variety_name = `${cropVariety.cropVariety_specie} - ${cropVariety.crop_variety_name}`; - postCropVarietyRequest( - cropVariety, - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('user not authorized to access farm'); - done(); - }, - ); + + const res = await postCropVarietyRequest(cropVariety, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); + expect(res.error.text).toBe('user not authorized to access farm'); }); }); }); diff --git a/packages/api/tests/custom_animal_breed.test.js b/packages/api/tests/custom_animal_breed.test.js index 6d3a1cbd4a..40178ac2e0 100644 --- a/packages/api/tests/custom_animal_breed.test.js +++ b/packages/api/tests/custom_animal_breed.test.js @@ -44,33 +44,24 @@ describe('Custom Animal Breed Tests', () => { defaultTypeId = defaultAnimalType.id; }); - function getRequest( - { user_id = newOwner.user_id, farm_id = farm.farm_id, query_params_string }, - callback, - ) { - chai + function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id, query_params_string }) { + return chai .request(server) .get(`/custom_animal_breeds?${query_params_string}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - const getRequestAsPromise = util.promisify(getRequest); - - function postRequest(data, { user_id, farm_id }, callback) { - chai + function postRequest(data, { user_id, farm_id }) { + return chai .request(server) .post(`/custom_animal_breeds`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - const postRequestAsPromise = util.promisify(postRequest); - function fakeUserFarm(role = 1) { return { ...mocks.fakeUserFarm(), role_id: role }; } @@ -114,10 +105,9 @@ describe('Custom Animal Breed Tests', () => { [newOwner] = await mocks.usersFactory(); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); // GET TESTS @@ -134,7 +124,7 @@ describe('Custom Animal Breed Tests', () => { }); await makeCustomAnimalBreed(mainFarm); - const res = await getRequestAsPromise({ + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id, query_params_string: `default_type_id=${defaultTypeId}`, @@ -160,7 +150,7 @@ describe('Custom Animal Breed Tests', () => { }); const secondBreed = await makeCustomAnimalBreed(mainFarm); - const res = await getRequestAsPromise({ + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id, query_params_string: `custom_type_id=${secondBreed.custom_type_id}`, @@ -183,7 +173,7 @@ describe('Custom Animal Breed Tests', () => { await makeCustomAnimalBreed(mainFarm); await makeCustomAnimalBreed(mainFarm); - const res = await getRequestAsPromise({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); expect(res.status).toBe(200); // Should return both breeds @@ -199,7 +189,7 @@ describe('Custom Animal Breed Tests', () => { await makeCustomAnimalBreed(mainFarm); const [unAuthorizedUser] = await mocks.usersFactory(); - const res = await getRequestAsPromise({ + const res = await getRequest({ user_id: unAuthorizedUser.user_id, farm_id: mainFarm.farm_id, }); @@ -213,7 +203,7 @@ describe('Custom Animal Breed Tests', () => { test('Returns 400 if both default and custom type ID are specified', async () => { const { mainFarm, user } = await returnUserFarms(1); - const res = await getRequestAsPromise({ + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id, query_params_string: 'default_type_id=1&custom_type_id=1', @@ -232,7 +222,7 @@ describe('Custom Animal Breed Tests', () => { const { mainFarm, user } = await returnUserFarms(role); const animal_type = await makeDefaultAnimalType(); const animal_breed = mocks.fakeCustomAnimalBreed({ default_type_id: animal_type.id }); - const res = await postRequestAsPromise(animal_breed, { + const res = await postRequest(animal_breed, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -263,7 +253,7 @@ describe('Custom Animal Breed Tests', () => { const animal_type = await makeDefaultAnimalType(); const animal_breed = mocks.fakeCustomAnimalBreed({ default_type_id: animal_type.id }); - const res = await postRequestAsPromise(animal_breed, { + const res = await postRequest(animal_breed, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -290,12 +280,12 @@ describe('Custom Animal Breed Tests', () => { const animal_type = await makeDefaultAnimalType(); const animal_breed = mocks.fakeCustomAnimalBreed({ default_type_id: animal_type.id }); - await postRequestAsPromise(animal_breed, { + await postRequest(animal_breed, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); - const res = await postRequestAsPromise(animal_breed, { + const res = await postRequest(animal_breed, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -319,7 +309,7 @@ describe('Custom Animal Breed Tests', () => { const animal_type = await makeDefaultAnimalType(); const animal_breed = mocks.fakeCustomAnimalBreed({ default_type_id: animal_type.id }); - await postRequestAsPromise(animal_breed, { + await postRequest(animal_breed, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -332,7 +322,7 @@ describe('Custom Animal Breed Tests', () => { .andWhere('breed', animal_breed.breed) .delete(); - const res = await postRequestAsPromise(animal_breed, { + const res = await postRequest(animal_breed, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -365,7 +355,7 @@ describe('Custom Animal Breed Tests', () => { const animal_breed = mocks.fakeCustomAnimalBreed({ custom_type_id: animal_type.id }); // Try to make a custom breed in using custom type - const res = await postRequestAsPromise(animal_breed, { + const res = await postRequest(animal_breed, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -391,7 +381,7 @@ describe('Custom Animal Breed Tests', () => { }); // Try to make a custom breed in Farm 1 using Farm 2's custom type - const res = await postRequestAsPromise(animal_breed, { + const res = await postRequest(animal_breed, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); diff --git a/packages/api/tests/custom_animal_type.test.js b/packages/api/tests/custom_animal_type.test.js index 4d7ff1e309..98938a8e10 100644 --- a/packages/api/tests/custom_animal_type.test.js +++ b/packages/api/tests/custom_animal_type.test.js @@ -42,10 +42,9 @@ describe('Custom Animal Type Tests', () => { token = global.token; }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); async function getRequest({ user_id, farm_id }, query = '') { @@ -56,19 +55,16 @@ describe('Custom Animal Type Tests', () => { .set('farm_id', farm_id); } - function postRequest(data, { user_id, farm_id }, callback) { - chai + function postRequest(data, { user_id, farm_id }) { + return chai .request(server) .post(`/custom_animal_types`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - const postRequestAsPromise = util.promisify(postRequest); - function fakeUserFarm(role = 1) { return { ...mocks.fakeUserFarm(), role_id: role }; } @@ -271,7 +267,7 @@ describe('Custom Animal Type Tests', () => { const { mainFarm, user } = await returnUserFarms(role); const animal_type = mocks.fakeCustomAnimalType(); - const res = await postRequestAsPromise(animal_type, { + const res = await postRequest(animal_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -300,7 +296,7 @@ describe('Custom Animal Type Tests', () => { const { mainFarm, user } = await returnUserFarms(3); const animal_type = mocks.fakeCustomAnimalType(); - const res = await postRequestAsPromise(animal_type, { + const res = await postRequest(animal_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -326,12 +322,12 @@ describe('Custom Animal Type Tests', () => { const animal_type = mocks.fakeCustomAnimalType(); - await postRequestAsPromise(animal_type, { + await postRequest(animal_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); - const res = await postRequestAsPromise(animal_type, { + const res = await postRequest(animal_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -354,7 +350,7 @@ describe('Custom Animal Type Tests', () => { const animal_type = mocks.fakeCustomAnimalType(); - await postRequestAsPromise(animal_type, { + await postRequest(animal_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -366,7 +362,7 @@ describe('Custom Animal Type Tests', () => { .andWhere('type', animal_type.type) .delete(); - const res = await postRequestAsPromise(animal_type, { + const res = await postRequest(animal_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); diff --git a/packages/api/tests/default_animal_breed.test.js b/packages/api/tests/default_animal_breed.test.js index c7da8b686e..199a8962c6 100644 --- a/packages/api/tests/default_animal_breed.test.js +++ b/packages/api/tests/default_animal_breed.test.js @@ -37,20 +37,14 @@ describe('Default Animal Breed Tests', () => { let farm; let newOwner; - function getRequest( - { user_id = newOwner.user_id, farm_id = farm.farm_id, query_params_string }, - callback, - ) { - chai + function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id, query_params_string }) { + return chai .request(server) .get(`/default_animal_breeds?${query_params_string}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - const getRequestAsPromise = util.promisify(getRequest); - function fakeUserFarm(role = 1) { return { ...mocks.fakeUserFarm(), role_id: role }; } @@ -79,14 +73,12 @@ describe('Default Animal Breed Tests', () => { [newOwner] = await mocks.usersFactory(); }); - afterEach(async (done) => { + afterEach(async () => { await tableCleanup(knex); - done(); }); - afterAll(async (done) => { + afterAll(async () => { await knex.destroy(); - done(); }); // GET TESTS @@ -101,7 +93,7 @@ describe('Default Animal Breed Tests', () => { for (const role of roles) { const { mainFarm, user } = await returnUserFarms(role); - const res = await getRequestAsPromise({ + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id, query_params_string: `default_type_id=${firstBreed.default_type_id}`, @@ -124,7 +116,7 @@ describe('Default Animal Breed Tests', () => { for (const role of roles) { const { mainFarm, user } = await returnUserFarms(role); - const res = await getRequestAsPromise({ + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id, }); diff --git a/packages/api/tests/default_animal_type.test.js b/packages/api/tests/default_animal_type.test.js index df930e7110..8eba9d3396 100644 --- a/packages/api/tests/default_animal_type.test.js +++ b/packages/api/tests/default_animal_type.test.js @@ -39,14 +39,12 @@ describe('Default Animal Type Tests', () => { token = global.token; }); - afterEach(async (done) => { + afterEach(async () => { await tableCleanup(knex); - done(); }); - afterAll(async (done) => { + afterAll(async () => { await knex.destroy(); - done(); }); async function getRequest({ user_id, farm_id }, query = '') { diff --git a/packages/api/tests/disease.test.js b/packages/api/tests/disease.test.js index e6132a6234..c9d2346073 100644 --- a/packages/api/tests/disease.test.js +++ b/packages/api/tests/disease.test.js @@ -46,36 +46,30 @@ describe('Disease Tests', () => { token = global.token; }); - function addRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }, callback) { - chai + function addRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post(`/disease`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function getRequest({ user_id = owner.user_id, farm_id = farm.farm_id }, callback) { - chai + function getRequest({ user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .get(`/disease/farm/${farm_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - function deleteRequest( - { user_id = owner.user_id, farm_id = farm.farm_id, disease_id }, - callback, - ) { - chai + function deleteRequest({ user_id = owner.user_id, farm_id = farm.farm_id, disease_id }) { + return chai .request(server) .delete(`/disease/${disease_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } function fakeUserFarm(role) { @@ -124,10 +118,9 @@ describe('Disease Tests', () => { ); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('Get && delete disease', () => { @@ -137,7 +130,7 @@ describe('Disease Tests', () => { [disease] = await mocks.diseaseFactory({ promisedFarm: [farm] }); }); - test('Should fail to get deleted disease', async (done) => { + test('Should fail to get deleted disease', async () => { await diseaseModel .query() .context({ @@ -146,149 +139,123 @@ describe('Disease Tests', () => { }) .findById(disease.disease_id) .delete(); - getRequest({ user_id: owner.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.length).toBe(0); - done(); - }); + const res = await getRequest({ user_id: owner.user_id }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(0); }); - test('Should get seeded disease', async (done) => { + test('Should get seeded disease', async () => { let [seededDisease] = await mocks.diseaseFactory( { promisedFarm: [{ farm_id: null }] }, mocks.fakeDisease(), ); - getRequest({ user_id: owner.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[1].disease_id).toBe(seededDisease.disease_id); - done(); - }); + const res = await getRequest({ user_id: owner.user_id }); + expect(res.status).toBe(200); + expect(res.body[1].disease_id).toBe(seededDisease.disease_id); }); describe('Get disease authorization tests', () => { - test('Owner should get disease by farm id', async (done) => { - getRequest({ user_id: owner.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].disease_id).toBe(disease.disease_id); - done(); - }); + test('Owner should get disease by farm id', async () => { + const res = await getRequest({ user_id: owner.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].disease_id).toBe(disease.disease_id); }); - test('Manager should get disease by farm id', async (done) => { - getRequest({ user_id: manager.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].disease_id).toBe(disease.disease_id); - done(); - }); + test('Manager should get disease by farm id', async () => { + const res = await getRequest({ user_id: manager.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].disease_id).toBe(disease.disease_id); }); - test('Worker should get disease by farm id', async (done) => { - getRequest({ user_id: worker.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].disease_id).toBe(disease.disease_id); - done(); - }); + test('Worker should get disease by farm id', async () => { + const res = await getRequest({ user_id: worker.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].disease_id).toBe(disease.disease_id); }); - test('Return 403 if unauthorized user tries to get disease by farm id', async (done) => { - getRequest({ user_id: unauthorizedUser.user_id }, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + test('Return 403 if unauthorized user tries to get disease by farm id', async () => { + const res = await getRequest({ user_id: unauthorizedUser.user_id }); + expect(res.status).toBe(403); }); }); describe('Delete disease tests', function () { - test('should return 403 if user tries to delete a seeded disease', async (done) => { + test('should return 403 if user tries to delete a seeded disease', async () => { let [seedDisease] = await mocks.diseaseFactory( { promisedFarm: [{ farm_id: null }] }, mocks.fakeDisease(), ); - deleteRequest({ disease_id: seedDisease.disease_id }, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await deleteRequest({ disease_id: seedDisease.disease_id }); + expect(res.status).toBe(403); }); describe('Delete disease authorization tests', () => { - test('Owner should delete a disease', async (done) => { - deleteRequest({ disease_id: disease.disease_id }, async (err, res) => { - expect(res.status).toBe(200); - const deletedDisease = await diseaseModel - .query() - .context({ showHidden: true }) - .where('disease_id', disease.disease_id); - expect(deletedDisease.length).toBe(1); - expect(deletedDisease[0].deleted).toBe(true); - done(); - }); + test('Owner should delete a disease', async () => { + const res = await deleteRequest({ disease_id: disease.disease_id }); + expect(res.status).toBe(200); + const deletedDisease = await diseaseModel + .query() + .context({ showHidden: true }) + .where('disease_id', disease.disease_id); + expect(deletedDisease.length).toBe(1); + expect(deletedDisease[0].deleted).toBe(true); }); - test('Manager should delete a disease', async (done) => { - deleteRequest( - { user_id: manager.user_id, disease_id: disease.disease_id }, - async (err, res) => { - expect(res.status).toBe(200); - const deletedDisease = await diseaseModel - .query() - .context({ showHidden: true }) - .where('disease_id', disease.disease_id); - expect(deletedDisease.length).toBe(1); - expect(deletedDisease[0].deleted).toBe(true); - done(); - }, - ); + test('Manager should delete a disease', async () => { + const res = await deleteRequest({ + user_id: manager.user_id, + disease_id: disease.disease_id, + }); + expect(res.status).toBe(200); + const deletedDisease = await diseaseModel + .query() + .context({ showHidden: true }) + .where('disease_id', disease.disease_id); + expect(deletedDisease.length).toBe(1); + expect(deletedDisease[0].deleted).toBe(true); }); - test('Return 403 if farm worker tries to delete disease', async (done) => { - deleteRequest( - { user_id: worker.user_id, disease_id: disease.disease_id }, - async (err, res) => { - expect(res.status).toBe(403); - const diseaseNotDeleted = await diseaseModel - .query() - .context({ showHidden: true }) - .where('disease_id', disease.disease_id); - expect(diseaseNotDeleted.length).toBe(1); - expect(diseaseNotDeleted[0].deleted).toBe(false); - done(); - }, - ); + test('Return 403 if farm worker tries to delete disease', async () => { + const res = await deleteRequest({ + user_id: worker.user_id, + disease_id: disease.disease_id, + }); + expect(res.status).toBe(403); + const diseaseNotDeleted = await diseaseModel + .query() + .context({ showHidden: true }) + .where('disease_id', disease.disease_id); + expect(diseaseNotDeleted.length).toBe(1); + expect(diseaseNotDeleted[0].deleted).toBe(false); }); - test('Return 403 if unauthorized tries to delete disease', async (done) => { - deleteRequest( - { user_id: unauthorizedUser.user_id, disease_id: disease.disease_id }, - async (err, res) => { - expect(res.status).toBe(403); - const diseaseNotDeleted = await diseaseModel - .query() - .context({ showHidden: true }) - .where('disease_id', disease.disease_id); - expect(diseaseNotDeleted.length).toBe(1); - expect(diseaseNotDeleted[0].deleted).toBe(false); - done(); - }, - ); + test('Return 403 if unauthorized tries to delete disease', async () => { + const res = await deleteRequest({ + user_id: unauthorizedUser.user_id, + disease_id: disease.disease_id, + }); + expect(res.status).toBe(403); + const diseaseNotDeleted = await diseaseModel + .query() + .context({ showHidden: true }) + .where('disease_id', disease.disease_id); + expect(diseaseNotDeleted.length).toBe(1); + expect(diseaseNotDeleted[0].deleted).toBe(false); }); - test('Return 403 if unauthorized tries to delete disease', async (done) => { - deleteRequest( - { - user_id: unauthorizedUser.user_id, - farm_id: unauthorizedFarm.farm_id, - disease_id: disease.disease_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - const diseaseNotDeleted = await diseaseModel - .query() - .context({ showHidden: true }) - .where('disease_id', disease.disease_id); - expect(diseaseNotDeleted.length).toBe(1); - expect(diseaseNotDeleted[0].deleted).toBe(false); - done(); - }, - ); + test('Return 403 if unauthorized tries to delete disease', async () => { + const res = await deleteRequest({ + user_id: unauthorizedUser.user_id, + farm_id: unauthorizedFarm.farm_id, + disease_id: disease.disease_id, + }); + + expect(res.status).toBe(403); + const diseaseNotDeleted = await diseaseModel + .query() + .context({ showHidden: true }) + .where('disease_id', disease.disease_id); + expect(diseaseNotDeleted.length).toBe(1); + expect(diseaseNotDeleted[0].deleted).toBe(false); }); }); }); @@ -300,72 +267,57 @@ describe('Disease Tests', () => { diseaseToAdd = createDiseaseObj(); }); - test('should return 403 status if headers.farm_id is set to null', async (done) => { + test('should return 403 status if headers.farm_id is set to null', async () => { diseaseToAdd.farm_id = null; - addRequest(diseaseToAdd, {}, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await addRequest(diseaseToAdd, {}); + expect(res.status).toBe(403); }); - test('Owner should successfully add disease', async (done) => { - addRequest(diseaseToAdd, { user_id: owner.user_id }, async (err, res) => { - expect(res.status).toBe(201); - const addedDisease = await diseaseModel - .query() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(addedDisease.length).toBe(1); - expect(addedDisease[0].disease_scientific_name).toBe(diseaseToAdd.disease_scientific_name); - expect(addedDisease[0].disease_common_name).toBe(diseaseToAdd.disease_common_name); - expect(addedDisease[0].disease_group).toBe(diseaseToAdd.disease_group); - done(); - }); + test('Owner should successfully add disease', async () => { + const res = await addRequest(diseaseToAdd, { user_id: owner.user_id }); + expect(res.status).toBe(201); + const addedDisease = await diseaseModel + .query() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(addedDisease.length).toBe(1); + expect(addedDisease[0].disease_scientific_name).toBe(diseaseToAdd.disease_scientific_name); + expect(addedDisease[0].disease_common_name).toBe(diseaseToAdd.disease_common_name); + expect(addedDisease[0].disease_group).toBe(diseaseToAdd.disease_group); }); - test('Manager should successfully add disease', async (done) => { - addRequest(diseaseToAdd, { user_id: manager.user_id }, async (err, res) => { - expect(res.status).toBe(201); - const addedDisease = await diseaseModel - .query() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(addedDisease.length).toBe(1); - expect(addedDisease[0].disease_scientific_name).toBe(diseaseToAdd.disease_scientific_name); - expect(addedDisease[0].disease_common_name).toBe(diseaseToAdd.disease_common_name); - expect(addedDisease[0].disease_group).toBe(diseaseToAdd.disease_group); - done(); - }); + test('Manager should successfully add disease', async () => { + const res = await addRequest(diseaseToAdd, { user_id: manager.user_id }); + expect(res.status).toBe(201); + const addedDisease = await diseaseModel + .query() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(addedDisease.length).toBe(1); + expect(addedDisease[0].disease_scientific_name).toBe(diseaseToAdd.disease_scientific_name); + expect(addedDisease[0].disease_common_name).toBe(diseaseToAdd.disease_common_name); + expect(addedDisease[0].disease_group).toBe(diseaseToAdd.disease_group); }); - test('Return 403 if farm worker tries to add disease', async (done) => { - addRequest(diseaseToAdd, { user_id: worker.user_id }, async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('User does not have the following permission(s): add:diseases'); - done(); - }); + test('Return 403 if farm worker tries to add disease', async () => { + const res = await addRequest(diseaseToAdd, { user_id: worker.user_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): add:diseases'); }); - test('Return 403 if unauthorized tries to add disease', async (done) => { - addRequest(diseaseToAdd, { user_id: unauthorizedUser.user_id }, async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('User does not have the following permission(s): add:diseases'); - done(); - }); + test('Return 403 if unauthorized tries to add disease', async () => { + const res = await addRequest(diseaseToAdd, { user_id: unauthorizedUser.user_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): add:diseases'); }); - test('Return 403 if farm owner tries to add disease of farm that they do not own', async (done) => { - addRequest( - diseaseToAdd, - { - user_id: unauthorizedUser.user_id, - farm_id: unauthorizedFarm.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Return 403 if farm owner tries to add disease of farm that they do not own', async () => { + const res = await addRequest(diseaseToAdd, { + user_id: unauthorizedUser.user_id, + farm_id: unauthorizedFarm.farm_id, + }); + + expect(res.status).toBe(403); }); }); }); diff --git a/packages/api/tests/documents.test.js b/packages/api/tests/documents.test.js index 6c6103e596..e0c99530ad 100644 --- a/packages/api/tests/documents.test.js +++ b/packages/api/tests/documents.test.js @@ -15,81 +15,72 @@ import mocks from './mock.factories.js'; import { tableCleanup } from './testEnvironment.js'; describe('Document tests', () => { - function getRequest(url, { user_id, farm_id }, callback) { - chai.request(server).get(url).set('user_id', user_id).set('farm_id', farm_id).end(callback); + function getRequest(url, { user_id, farm_id }) { + return chai.request(server).get(url).set('user_id', user_id).set('farm_id', farm_id); } - function patchDocumentArchiveRequest(document_id, data, { user_id, farm_id }, callback) { - chai + function patchDocumentArchiveRequest(document_id, data, { user_id, farm_id }) { + return chai .request(server) .patch(`/document/archive/${document_id}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function postManagementPlanRequest(url, data, { user_id, farm_id }, callback) { - chai + function postManagementPlanRequest(url, data, { user_id, farm_id }) { + return chai .request(server) .post(url) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function putDocumentRequest(data, { user_id, farm_id }, callback) { + function putDocumentRequest(data, { user_id, farm_id }) { const { document_id } = data; - chai + + return chai .request(server) .put(`/document/${document_id}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } function fakeUserFarm(role = 1) { return { ...mocks.fakeUserFarm(), role_id: role }; } - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('GET Authorization tests', () => { - test('Owner should GET documents if they exist', async (done) => { + test('Owner should GET documents if they exist', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); await mocks.documentFactory({ promisedFarm: [{ farm_id }] }); - getRequest(`/document/farm/${farm_id}`, { user_id, farm_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.length).toBe(1); - done(); - }); + const res = await getRequest(`/document/farm/${farm_id}`, { user_id, farm_id }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(1); }); - test('Manager should GET documents if they exist', async (done) => { + test('Manager should GET documents if they exist', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(2)); await mocks.documentFactory({ promisedFarm: [{ farm_id }] }); - getRequest(`/document/farm/${farm_id}`, { user_id, farm_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.length).toBe(1); - done(); - }); + const res = await getRequest(`/document/farm/${farm_id}`, { user_id, farm_id }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(1); }); - test('EO should GET documents if they exist', async (done) => { + test('EO should GET documents if they exist', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(5)); await mocks.documentFactory({ promisedFarm: [{ farm_id }] }); - getRequest(`/document/farm/${farm_id}`, { user_id, farm_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.length).toBe(1); - done(); - }); + const res = await getRequest(`/document/farm/${farm_id}`, { user_id, farm_id }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(1); }); }); @@ -103,123 +94,116 @@ describe('Document tests', () => { } describe('Post document test', () => { - test('Should return 400 when files === []', async (done) => { + test('Should return 400 when files === []', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); - postManagementPlanRequest( + + const res = await postManagementPlanRequest( `/document/farm/${farm_id}`, getFakeDocument(farm_id, 0), { user_id, farm_id, }, - (err, res) => { - expect(res.status).toBe(400); - done(); - }, ); + + expect(res.status).toBe(400); }); - test('Should return 400 when files is not an array', async (done) => { + test('Should return 400 when files is not an array', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); - postManagementPlanRequest( + + const res = await postManagementPlanRequest( `/document/farm/${farm_id}`, getFakeDocument(farm_id, 0, 'files'), { user_id, farm_id, }, - (err, res) => { - expect(res.status).toBe(400); - done(); - }, ); + + expect(res.status).toBe(400); }); - test('Should post document with multiple files', async (done) => { + test('Should post document with multiple files', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); - postManagementPlanRequest( + + const res = await postManagementPlanRequest( `/document/farm/${farm_id}`, getFakeDocument(farm_id, 4), { user_id, farm_id, }, - async (err, res) => { - expect(res.status).toBe(201); - const files = await knex('file').where({ document_id: res.body.document_id }); - expect(files.length).toBe(4); - done(); - }, ); + + expect(res.status).toBe(201); + const files = await knex('file').where({ document_id: res.body.document_id }); + expect(files.length).toBe(4); }); describe('Post document authorization test', function () { - test('Worker should not POST documents', async (done) => { + test('Worker should not POST documents', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(3)); await mocks.documentFactory({ promisedFarm: [{ farm_id }] }); - postManagementPlanRequest( + + const res = await postManagementPlanRequest( `/document/farm/${farm_id}`, getFakeDocument(farm_id, 4), { user_id, farm_id, }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, ); + + expect(res.status).toBe(403); }); - test('Owner should POST a document', async (done) => { + test('Owner should POST a document', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); await mocks.documentFactory({ promisedFarm: [{ farm_id }] }); - postManagementPlanRequest( + + const res = await postManagementPlanRequest( `/document/farm/${farm_id}`, getFakeDocument(farm_id, 1), { user_id, farm_id, }, - async (err, res) => { - expect(res.status).toBe(201); - const files = await knex('file').where({ document_id: res.body.document_id }); - expect(files.length).toBe(1); - done(); - }, ); + + expect(res.status).toBe(201); + const files = await knex('file').where({ document_id: res.body.document_id }); + expect(files.length).toBe(1); }); - test('Manager should POST a document', async (done) => { + test('Manager should POST a document', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(2)); await mocks.documentFactory({ promisedFarm: [{ farm_id }] }); - postManagementPlanRequest( + + const res = await postManagementPlanRequest( `/document/farm/${farm_id}`, getFakeDocument(farm_id, 1), { user_id, farm_id, }, - async (err, res) => { - expect(res.status).toBe(201); - const files = await knex('file').where({ document_id: res.body.document_id }); - expect(files.length).toBe(1); - done(); - }, ); + + expect(res.status).toBe(201); + const files = await knex('file').where({ document_id: res.body.document_id }); + expect(files.length).toBe(1); }); - test('EO should POST a document', async (done) => { + test('EO should POST a document', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(5)); await mocks.documentFactory({ promisedFarm: [{ farm_id }] }); - postManagementPlanRequest( + + const res = await postManagementPlanRequest( `/document/farm/${farm_id}`, getFakeDocument(farm_id, 1), { user_id, farm_id, }, - async (err, res) => { - expect(res.status).toBe(201); - const files = await knex('file').where({ document_id: res.body.document_id }); - expect(files.length).toBe(1); - done(); - }, ); + + expect(res.status).toBe(201); + const files = await knex('file').where({ document_id: res.body.document_id }); + expect(files.length).toBe(1); }); }); }); @@ -239,13 +223,15 @@ describe('Document tests', () => { const fakeDate = new Date(0).toISOString().split('T')[0]; - test('Owner should be able to edit a document, add files', async (done) => { + test('Owner should be able to edit a document, add files', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const document = await documentWithFilesFactory(farm_id, 1); const newDocument = getFakeDocument(farm_id, 2); const data = { document_id: document.document_id, ...newDocument }; data.valid_until = fakeDate; - putDocumentRequest(data, { user_id, farm_id }, async (err, res) => { + + { + const res = await putDocumentRequest(data, { user_id, farm_id }); expect(res.status).toBe(201); const document = await knex('document').where({ document_id: res.body.document_id }); expect(document[0].name).toBe(newDocument.name); @@ -254,17 +240,18 @@ describe('Document tests', () => { expect(document[0].valid_until.toISOString().split('T')[0]).toEqual(fakeDate); const files = await knex('file').where({ document_id: res.body.document_id }); expect(files.length).toBe(2); - done(); - }); + } }); - test('Owner should be able to edit a document, delete files', async (done) => { + test('Owner should be able to edit a document, delete files', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const document = await documentWithFilesFactory(farm_id, 3); const newDocument = getFakeDocument(farm_id, 1); const data = { document_id: document.document_id, ...newDocument }; data.valid_until = fakeDate; - putDocumentRequest(data, { user_id, farm_id }, async (err, res) => { + + { + const res = await putDocumentRequest(data, { user_id, farm_id }); expect(res.status).toBe(201); const document = await knex('document').where({ document_id: res.body.document_id }); expect(document[0].name).toBe(newDocument.name); @@ -273,17 +260,18 @@ describe('Document tests', () => { expect(document[0].valid_until.toISOString().split('T')[0]).toEqual(fakeDate); const files = await knex('file').where({ document_id: res.body.document_id }); expect(files.length).toBe(1); - done(); - }); + } }); - test('Manager shoud be able to edit a document', async (done) => { + test('Manager shoud be able to edit a document', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(2)); const document = await documentWithFilesFactory(farm_id, 3); const newDocument = getFakeDocument(farm_id, 1); const data = { document_id: document.document_id, ...newDocument }; data.valid_until = fakeDate; - putDocumentRequest(data, { user_id, farm_id }, async (err, res) => { + + { + const res = await putDocumentRequest(data, { user_id, farm_id }); expect(res.status).toBe(201); const document = await knex('document').where({ document_id: res.body.document_id }); expect(document[0].name).toBe(newDocument.name); @@ -292,17 +280,18 @@ describe('Document tests', () => { expect(document[0].valid_until.toISOString().split('T')[0]).toEqual(fakeDate); const files = await knex('file').where({ document_id: res.body.document_id }); expect(files.length).toBe(1); - done(); - }); + } }); - test('EO shoud be able to edit a document', async (done) => { + test('EO shoud be able to edit a document', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(5)); const document = await documentWithFilesFactory(farm_id, 3); const newDocument = getFakeDocument(farm_id, 1); const data = { document_id: document.document_id, ...newDocument }; data.valid_until = fakeDate; - putDocumentRequest(data, { user_id, farm_id }, async (err, res) => { + + { + const res = await putDocumentRequest(data, { user_id, farm_id }); expect(res.status).toBe(201); const document = await knex('document').where({ document_id: res.body.document_id }); expect(document[0].name).toBe(newDocument.name); @@ -311,111 +300,90 @@ describe('Document tests', () => { expect(document[0].valid_until.toISOString().split('T')[0]).toEqual(fakeDate); const files = await knex('file').where({ document_id: res.body.document_id }); expect(files.length).toBe(1); - done(); - }); + } }); - test('Worker should not be a able to update document', async (done) => { + test('Worker should not be a able to update document', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(3)); const document = await documentWithFilesFactory(farm_id); const newDocument = getFakeDocument(farm_id, 1); const data = { document_id: document.document_id, ...newDocument }; - putDocumentRequest(data, { user_id, farm_id }, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await putDocumentRequest(data, { user_id, farm_id }); + expect(res.status).toBe(403); }); }); }); describe('Archive document tests', () => { - test('User should be able to archive documents', async (done) => { + test('User should be able to archive documents', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(2)); const [{ document_id }] = await mocks.documentFactory({ promisedFarm: [{ farm_id }] }); - patchDocumentArchiveRequest( + const res = await patchDocumentArchiveRequest( document_id, { archived: true }, { user_id, farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - const document = await knex('document').where({ document_id }); - expect(document[0].archived).toBe(true); - done(); - }, ); + expect(res.status).toBe(200); + const document = await knex('document').where({ document_id }); + expect(document[0].archived).toBe(true); }); - test('User should be able to unarchive documents', async (done) => { + test('User should be able to unarchive documents', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(2)); const [{ document_id }] = await mocks.documentFactory( { promisedFarm: [{ farm_id }] }, mocks.fakeDocument({ archived: true }), ); - patchDocumentArchiveRequest( + const res = await patchDocumentArchiveRequest( document_id, { archived: false }, { user_id, farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - const document = await knex('document').where({ document_id }); - expect(document[0].archived).toBe(false); - done(); - }, ); + expect(res.status).toBe(200); + const document = await knex('document').where({ document_id }); + expect(document[0].archived).toBe(false); }); describe('Archive document authorization tests', () => { - test('Owner should be able to archive documents', async (done) => { + test('Owner should be able to archive documents', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const [{ document_id }] = await mocks.documentFactory({ promisedFarm: [{ farm_id }] }); - patchDocumentArchiveRequest( + const res = await patchDocumentArchiveRequest( document_id, { archived: true }, { user_id, farm_id }, - (err, res) => { - expect(res.status).toBe(200); - done(); - }, ); + expect(res.status).toBe(200); }); - test('Manager should be able to archive documents', async (done) => { + test('Manager should be able to archive documents', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(2)); const [{ document_id }] = await mocks.documentFactory({ promisedFarm: [{ farm_id }] }); - patchDocumentArchiveRequest( + const res = await patchDocumentArchiveRequest( document_id, { archived: true }, { user_id, farm_id }, - (err, res) => { - expect(res.status).toBe(200); - done(); - }, ); + expect(res.status).toBe(200); }); - test('EO should be able to archive documents', async (done) => { + test('EO should be able to archive documents', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(5)); const [{ document_id }] = await mocks.documentFactory({ promisedFarm: [{ farm_id }] }); - patchDocumentArchiveRequest( + const res = await patchDocumentArchiveRequest( document_id, { archived: true }, { user_id, farm_id }, - (err, res) => { - expect(res.status).toBe(200); - done(); - }, ); + expect(res.status).toBe(200); }); - test('Worker should NOT be able to archive documents', async (done) => { + test('Worker should NOT be able to archive documents', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(3)); const [{ document_id }] = await mocks.documentFactory({ promisedFarm: [{ farm_id }] }); - patchDocumentArchiveRequest( + const res = await patchDocumentArchiveRequest( document_id, { archived: true }, { user_id, farm_id }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, ); + expect(res.status).toBe(403); }); }); }); diff --git a/packages/api/tests/expense.test.js b/packages/api/tests/expense.test.js index 23424c87b2..4e426882fc 100644 --- a/packages/api/tests/expense.test.js +++ b/packages/api/tests/expense.test.js @@ -44,60 +44,47 @@ describe('Expense Tests', () => { // FUNCTIONS - function postExpenseRequest( - data, - { user_id = newOwner.user_id, farm_id = farm.farm_id }, - callback, - ) { - chai + function postExpenseRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post(`/expense/farm/${farm_id}`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } function fakeUserFarm(role = 1) { return { ...mocks.fakeUserFarm(), role_id: role }; } - function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { - chai + function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .get(`/expense/farm/${farm_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - function deleteRequest( - farm_expense_id, - { user_id = newOwner.user_id, farm_id = farm.farm_id }, - callback, - ) { - chai + function deleteRequest(farm_expense_id, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .delete(`/expense/${farm_expense_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } function patchRequest( data, farm_expense_id, { user_id = newOwner.user_id, farm_id = farm.farm_id }, - callback, ) { - chai + return chai .request(server) .patch(`/expense/${farm_expense_id}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } async function returnUserFarms(role) { @@ -139,85 +126,75 @@ describe('Expense Tests', () => { [newOwner] = await mocks.usersFactory(); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); // POST TESTS describe('Post expense tests', () => { - test('Owner should post expense', async (done) => { + test('Owner should post expense', async () => { const { mainFarm, user } = await returnUserFarms(1); const { expense_type } = await returnExpenseType(mainFarm); const expense = getFakeExpense(expense_type.expense_type_id, mainFarm.farm_id); const expensesArray = []; expensesArray.push(expense); - postExpenseRequest( - expensesArray, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(201); - const expenses = await farmExpenseModel - .query() - .context({ showHidden: true }) - .where('farm_id', mainFarm.farm_id); - expect(expenses.length).toBe(1); - expect(expenses[0].value).toBe(expense.value); - done(); - }, - ); + const res = await postExpenseRequest(expensesArray, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(201); + const expenses = await farmExpenseModel + .query() + .context({ showHidden: true }) + .where('farm_id', mainFarm.farm_id); + expect(expenses.length).toBe(1); + expect(expenses[0].value).toBe(expense.value); }); - test('Manager should post expense', async (done) => { + test('Manager should post expense', async () => { const { mainFarm, user } = await returnUserFarms(2); const { expense_type } = await returnExpenseType(mainFarm); const expense = getFakeExpense(expense_type.expense_type_id, mainFarm.farm_id); const expensesArray = []; expensesArray.push(expense); - postExpenseRequest( - expensesArray, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(201); - const expenses = await farmExpenseModel - .query() - .context({ showHidden: true }) - .where('farm_id', mainFarm.farm_id); - expect(expenses.length).toBe(1); - expect(expenses[0].value).toBe(expense.value); - done(); - }, - ); + const res = await postExpenseRequest(expensesArray, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(201); + const expenses = await farmExpenseModel + .query() + .context({ showHidden: true }) + .where('farm_id', mainFarm.farm_id); + expect(expenses.length).toBe(1); + expect(expenses[0].value).toBe(expense.value); }); - test('Worker should post expense', async (done) => { + test('Worker should post expense', async () => { const { mainFarm, user } = await returnUserFarms(3); const { expense_type } = await returnExpenseType(mainFarm); const expense = getFakeExpense(expense_type.expense_type_id, mainFarm.farm_id); const expensesArray = []; expensesArray.push(expense); - postExpenseRequest( - expensesArray, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(201); - const expenses = await farmExpenseModel - .query() - .context({ showHidden: true }) - .where('farm_id', mainFarm.farm_id); - expect(expenses.length).toBe(1); - expect(expenses[0].value).toBe(expense.value); - done(); - }, - ); + const res = await postExpenseRequest(expensesArray, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(201); + const expenses = await farmExpenseModel + .query() + .context({ showHidden: true }) + .where('farm_id', mainFarm.farm_id); + expect(expenses.length).toBe(1); + expect(expenses[0].value).toBe(expense.value); }); - test('Should return 403 when unauthorized user tries to post expense', async (done) => { + test('Should return 403 when unauthorized user tries to post expense', async () => { const { mainFarm, user } = await returnUserFarms(1); const { expense_type } = await returnExpenseType(mainFarm); const [unAuthorizedUser] = await mocks.usersFactory(); @@ -225,125 +202,107 @@ describe('Expense Tests', () => { const expensesArray = []; expensesArray.push(expense); - postExpenseRequest( - expensesArray, - { - user_id: unAuthorizedUser.user_id, - farm_id: mainFarm.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): add:expenses', - ); - done(); - }, - ); + const res = await postExpenseRequest(expensesArray, { + user_id: unAuthorizedUser.user_id, + farm_id: mainFarm.farm_id, + }); + + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): add:expenses'); }); }); // GET TESTS describe('Get expense tests', () => { - test('Owner should get expense by farm id', async (done) => { + test('Owner should get expense by farm id', async () => { const { mainFarm, user } = await returnUserFarms(1); const { expense } = await returnExpense(user, mainFarm); - getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].farm_id).toBe(expense.farm_id); - done(); - }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + expect(res.status).toBe(200); + expect(res.body[0].farm_id).toBe(expense.farm_id); }); - test('Manager should get expense by farm id', async (done) => { + test('Manager should get expense by farm id', async () => { const { mainFarm, user } = await returnUserFarms(2); const { expense } = await returnExpense(user, mainFarm); - getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].farm_id).toBe(expense.farm_id); - done(); - }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + expect(res.status).toBe(200); + expect(res.body[0].farm_id).toBe(expense.farm_id); }); - test('ManWorkerager should get expense by farm id', async (done) => { + test('ManWorkerager should get expense by farm id', async () => { const { mainFarm, user } = await returnUserFarms(3); const { expense } = await returnExpense(user, mainFarm); - getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].farm_id).toBe(expense.farm_id); - done(); - }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + expect(res.status).toBe(200); + expect(res.body[0].farm_id).toBe(expense.farm_id); }); - test('Should get status 403 if an unauthorizedUser tries to get expense by farm id', async (done) => { + test('Should get status 403 if an unauthorizedUser tries to get expense by farm id', async () => { const { mainFarm, user } = await returnUserFarms(1); const [unAuthorizedUser] = await mocks.usersFactory(); - getRequest({ user_id: unAuthorizedUser.user_id, farm_id: mainFarm.farm_id }, (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('User does not have the following permission(s): get:expenses'); - done(); + const res = await getRequest({ + user_id: unAuthorizedUser.user_id, + farm_id: mainFarm.farm_id, }); + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): get:expenses'); }); }); // DELETE TESTS describe('Delete expense tests', () => { - test('Owner should delete their expense', async (done) => { + test('Owner should delete their expense', async () => { const { mainFarm, user } = await returnUserFarms(1); const { expense } = await returnExpense(user, mainFarm); - deleteRequest( - expense.farm_expense_id, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - const [deletedField] = await farmExpenseModel - .query() - .context({ showHidden: true }) - .where('farm_expense_id', expense.farm_expense_id); - expect(deletedField.deleted).toBe(true); - done(); - }, - ); + const res = await deleteRequest(expense.farm_expense_id, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + + expect(res.status).toBe(200); + const [deletedField] = await farmExpenseModel + .query() + .context({ showHidden: true }) + .where('farm_expense_id', expense.farm_expense_id); + expect(deletedField.deleted).toBe(true); }); - test('Manager should delete their expense', async (done) => { + test('Manager should delete their expense', async () => { const { mainFarm, user } = await returnUserFarms(2); const { expense } = await returnExpense(user, mainFarm); - deleteRequest( - expense.farm_expense_id, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - const [deletedField] = await farmExpenseModel - .query() - .context({ showHidden: true }) - .where('farm_expense_id', expense.farm_expense_id); - expect(deletedField.deleted).toBe(true); - done(); - }, - ); + const res = await deleteRequest(expense.farm_expense_id, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + + expect(res.status).toBe(200); + const [deletedField] = await farmExpenseModel + .query() + .context({ showHidden: true }) + .where('farm_expense_id', expense.farm_expense_id); + expect(deletedField.deleted).toBe(true); }); - test('Worker should delete their own expense', async (done) => { + test('Worker should delete their own expense', async () => { const { mainFarm, user } = await returnUserFarms(3); const { expense } = await returnExpense(user, mainFarm); - deleteRequest( - expense.farm_expense_id, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - const [deletedField] = await farmExpenseModel - .query() - .context({ showHidden: true }) - .where('farm_expense_id', expense.farm_expense_id); - expect(deletedField.deleted).toBe(true); - done(); - }, - ); + const res = await deleteRequest(expense.farm_expense_id, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + + expect(res.status).toBe(200); + const [deletedField] = await farmExpenseModel + .query() + .context({ showHidden: true }) + .where('farm_expense_id', expense.farm_expense_id); + expect(deletedField.deleted).toBe(true); }); - test("Worker should get 403 if they try to delete another user's expense", async (done) => { + test("Worker should get 403 if they try to delete another user's expense", async () => { const { mainFarm, user } = await returnUserFarms(3); const [otherUser] = await mocks.usersFactory(); const [otherUserFarm] = await mocks.userFarmFactory( @@ -355,40 +314,33 @@ describe('Expense Tests', () => { ); const { expense } = await returnExpense(otherUser, mainFarm); - deleteRequest( - expense.farm_expense_id, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('user not authorized to access record they did not create'); - done(); - }, - ); + const res = await deleteRequest(expense.farm_expense_id, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + + expect(res.status).toBe(403); + expect(res.error.text).toBe('user not authorized to access record they did not create'); }); - test('Unauthorized user should get 403 if they try to delete their expense', async (done) => { + test('Unauthorized user should get 403 if they try to delete their expense', async () => { const { mainFarm, user } = await returnUserFarms(1); const [unAuthorizedUser] = await mocks.usersFactory(); const { expense } = await returnExpense(user, mainFarm); - deleteRequest( - expense.farm_expense_id, - { - user_id: unAuthorizedUser.user_id, - farm_id: mainFarm.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): delete:expenses', - ); - done(); - }, + const res = await deleteRequest(expense.farm_expense_id, { + user_id: unAuthorizedUser.user_id, + farm_id: mainFarm.farm_id, + }); + + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): delete:expenses', ); }); }); describe('Patch expense tests', () => { - test('Owner should patch their expense', async (done) => { + test('Owner should patch their expense', async () => { const { mainFarm, user: owner } = await returnUserFarms(1); const { expense } = await returnExpense(owner, mainFarm); @@ -397,26 +349,20 @@ describe('Expense Tests', () => { note: 'patched in note', }; - patchRequest( - patchData, - expense.farm_expense_id, - { - user_id: owner.user_id, - farm_id: mainFarm.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(200); - const [updatedField] = await farmExpenseModel - .query() - .where('farm_expense_id', expense.farm_expense_id); - expect(updatedField.value).toBe(patchData.value); - expect(updatedField.note).toBe(patchData.note); - done(); - }, - ); + const res = await patchRequest(patchData, expense.farm_expense_id, { + user_id: owner.user_id, + farm_id: mainFarm.farm_id, + }); + + expect(res.status).toBe(200); + const [updatedField] = await farmExpenseModel + .query() + .where('farm_expense_id', expense.farm_expense_id); + expect(updatedField.value).toBe(patchData.value); + expect(updatedField.note).toBe(patchData.note); }); - test("Owner should patch another user's expense", async (done) => { + test("Owner should patch another user's expense", async () => { const { mainFarm, user: owner } = await returnUserFarms(1); const [otherUser] = await mocks.usersFactory(); const [otherUserFarm] = await mocks.userFarmFactory( @@ -433,26 +379,20 @@ describe('Expense Tests', () => { note: 'patched in note', }; - patchRequest( - patchData, - expense.farm_expense_id, - { - user_id: owner.user_id, - farm_id: mainFarm.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(200); - const [updatedField] = await farmExpenseModel - .query() - .where('farm_expense_id', expense.farm_expense_id); - expect(updatedField.value).toBe(patchData.value); - expect(updatedField.note).toBe(patchData.note); - done(); - }, - ); + const res = await patchRequest(patchData, expense.farm_expense_id, { + user_id: owner.user_id, + farm_id: mainFarm.farm_id, + }); + + expect(res.status).toBe(200); + const [updatedField] = await farmExpenseModel + .query() + .where('farm_expense_id', expense.farm_expense_id); + expect(updatedField.value).toBe(patchData.value); + expect(updatedField.note).toBe(patchData.note); }); - test('Manager should patch their expense', async (done) => { + test('Manager should patch their expense', async () => { const { mainFarm, user: manager } = await returnUserFarms(2); const { expense } = await returnExpense(manager, mainFarm); @@ -461,26 +401,20 @@ describe('Expense Tests', () => { note: 'patched in note', }; - patchRequest( - patchData, - expense.farm_expense_id, - { - user_id: manager.user_id, - farm_id: mainFarm.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(200); - const [updatedField] = await farmExpenseModel - .query() - .where('farm_expense_id', expense.farm_expense_id); - expect(updatedField.value).toBe(patchData.value); - expect(updatedField.note).toBe(patchData.note); - done(); - }, - ); + const res = await patchRequest(patchData, expense.farm_expense_id, { + user_id: manager.user_id, + farm_id: mainFarm.farm_id, + }); + + expect(res.status).toBe(200); + const [updatedField] = await farmExpenseModel + .query() + .where('farm_expense_id', expense.farm_expense_id); + expect(updatedField.value).toBe(patchData.value); + expect(updatedField.note).toBe(patchData.note); }); - test("Manager should patch another user's expense", async (done) => { + test("Manager should patch another user's expense", async () => { const { mainFarm, user: manager } = await returnUserFarms(2); const [otherUser] = await mocks.usersFactory(); const [otherUserFarm] = await mocks.userFarmFactory( @@ -497,26 +431,20 @@ describe('Expense Tests', () => { note: 'patched in note', }; - patchRequest( - patchData, - expense.farm_expense_id, - { - user_id: manager.user_id, - farm_id: mainFarm.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(200); - const [updatedField] = await farmExpenseModel - .query() - .where('farm_expense_id', expense.farm_expense_id); - expect(updatedField.value).toBe(patchData.value); - expect(updatedField.note).toBe(patchData.note); - done(); - }, - ); + const res = await patchRequest(patchData, expense.farm_expense_id, { + user_id: manager.user_id, + farm_id: mainFarm.farm_id, + }); + + expect(res.status).toBe(200); + const [updatedField] = await farmExpenseModel + .query() + .where('farm_expense_id', expense.farm_expense_id); + expect(updatedField.value).toBe(patchData.value); + expect(updatedField.note).toBe(patchData.note); }); - test('Worker should patch their own expense', async (done) => { + test('Worker should patch their own expense', async () => { const { mainFarm, user: worker } = await returnUserFarms(3); const { expense } = await returnExpense(worker, mainFarm); @@ -525,26 +453,20 @@ describe('Expense Tests', () => { note: 'patched in note', }; - patchRequest( - patchData, - expense.farm_expense_id, - { - user_id: worker.user_id, - farm_id: mainFarm.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(200); - const [updatedField] = await farmExpenseModel - .query() - .where('farm_expense_id', expense.farm_expense_id); - expect(updatedField.value).toBe(patchData.value); - expect(updatedField.note).toBe(patchData.note); - done(); - }, - ); + const res = await patchRequest(patchData, expense.farm_expense_id, { + user_id: worker.user_id, + farm_id: mainFarm.farm_id, + }); + + expect(res.status).toBe(200); + const [updatedField] = await farmExpenseModel + .query() + .where('farm_expense_id', expense.farm_expense_id); + expect(updatedField.value).toBe(patchData.value); + expect(updatedField.note).toBe(patchData.note); }); - test("Worker should get 403 if they try to patch another user's expense", async (done) => { + test("Worker should get 403 if they try to patch another user's expense", async () => { const { mainFarm, user: worker } = await returnUserFarms(3); const [otherUser] = await mocks.usersFactory(); const [otherUserFarm] = await mocks.userFarmFactory( @@ -561,22 +483,16 @@ describe('Expense Tests', () => { note: 'patched in note', }; - patchRequest( - patchData, - expense.farm_expense_id, - { - user_id: worker.user_id, - farm_id: mainFarm.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('user not authorized to access record they did not create'); - done(); - }, - ); + const res = await patchRequest(patchData, expense.farm_expense_id, { + user_id: worker.user_id, + farm_id: mainFarm.farm_id, + }); + + expect(res.status).toBe(403); + expect(res.error.text).toBe('user not authorized to access record they did not create'); }); - test('Unauthorized user should get 403 if they try to patch expense', async (done) => { + test('Unauthorized user should get 403 if they try to patch expense', async () => { const { mainFarm, user: owner } = await returnUserFarms(1); const [unauthorizedUser] = await mocks.usersFactory(); const { expense } = await returnExpense(owner, mainFarm); @@ -586,20 +502,14 @@ describe('Expense Tests', () => { note: 'patched in note', }; - patchRequest( - patchData, - expense.farm_expense_id, - { - user_id: unauthorizedUser.user_id, - farm_id: mainFarm.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): delete:expenses', - ); - done(); - }, + const res = await patchRequest(patchData, expense.farm_expense_id, { + user_id: unauthorizedUser.user_id, + farm_id: mainFarm.farm_id, + }); + + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): delete:expenses', ); }); }); diff --git a/packages/api/tests/expense_type.test.js b/packages/api/tests/expense_type.test.js index 8629f91e95..aab379cc31 100644 --- a/packages/api/tests/expense_type.test.js +++ b/packages/api/tests/expense_type.test.js @@ -45,73 +45,54 @@ describe('Expense Type Tests', () => { // FUNCTIONS - function postExpenseTypeRequest( - data, - { user_id = newOwner.user_id, farm_id = farm.farm_id }, - callback, - ) { - chai + function postExpenseTypeRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post(`/expense_type`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - const postExpenseTypeRequestAsPromise = util.promisify(postExpenseTypeRequest); - - function patchExpenseTypeRequest( - data, - { user_id = newOwner.user_id, farm_id = farm.farm_id }, - callback, - ) { - chai + + function patchExpenseTypeRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .patch(`/expense_type/${data.expense_type_id}`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - const patchExpenseTypeRequestAsPromise = util.promisify(patchExpenseTypeRequest); function fakeUserFarm(role = 1) { return { ...mocks.fakeUserFarm(), role_id: role }; } - function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { - chai + function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .get(`/expense_type/farm/${farm_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - const getRequestAsPromise = util.promisify(getRequest); - function getDefaultRequest({ user_id = newOwner.user_id, farm_id = farm1.farm_id }, callback) { - chai - .request(server) - .get(`/expense_type`) - .set('user_id', user_id) - .set('farm_id', farm_id) + function getDefaultRequest({ user_id = newOwner.user_id, farm_id = farm1.farm_id }) { + return ( // .send(farm_id) - .end(callback); + chai.request(server).get(`/expense_type`).set('user_id', user_id).set('farm_id', farm_id) + ); } - const getDefaultRequestAsPromise = util.promisify(getDefaultRequest); - function deleteRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { + function deleteRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { const { expense_type_id } = data; - chai + + return chai .request(server) .delete(`/expense_type/${expense_type_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - const deleteRequestAsPromise = util.promisify(deleteRequest); async function returnUserFarms(role) { const [mainFarm] = await mocks.farmFactory(); @@ -149,10 +130,9 @@ describe('Expense Type Tests', () => { [newOwner] = await mocks.usersFactory(); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); // POST TESTS @@ -161,7 +141,7 @@ describe('Expense Type Tests', () => { const { mainFarm, user } = await returnUserFarms(1); const expense_type = getFakeExpenseType(mainFarm.farm_id); - const res = await postExpenseTypeRequestAsPromise(expense_type, { + const res = await postExpenseTypeRequest(expense_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -179,7 +159,7 @@ describe('Expense Type Tests', () => { const { mainFarm, user } = await returnUserFarms(2); const expense_type = getFakeExpenseType(mainFarm.farm_id); - const res = await postExpenseTypeRequestAsPromise(expense_type, { + const res = await postExpenseTypeRequest(expense_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -197,7 +177,7 @@ describe('Expense Type Tests', () => { const { mainFarm, user } = await returnUserFarms(3); const expense_type = getFakeExpenseType(mainFarm.farm_id); - const res = await postExpenseTypeRequestAsPromise(expense_type, { + const res = await postExpenseTypeRequest(expense_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -213,7 +193,7 @@ describe('Expense Type Tests', () => { const expense_type = getFakeExpenseType(mainFarm.farm_id); const [unAuthorizedUser] = await mocks.usersFactory(); - const res = await postExpenseTypeRequestAsPromise(expense_type, { + const res = await postExpenseTypeRequest(expense_type, { user_id: unAuthorizedUser.user_id, farm_id: mainFarm.farm_id, }); @@ -231,7 +211,7 @@ describe('Expense Type Tests', () => { const { mainFarm, user } = await returnUserFarms(1); const expense = await returnExpenseType(mainFarm); - const res = await getRequestAsPromise({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); expect(res.status).toBe(200); expect(res.body[0].farm_id).toBe(expense.expense_type.farm_id); }); @@ -240,7 +220,7 @@ describe('Expense Type Tests', () => { const { mainFarm, user } = await returnUserFarms(2); const expense = await returnExpenseType(mainFarm); - const res = await getRequestAsPromise({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); expect(res.status).toBe(200); expect(res.body[0].farm_id).toBe(expense.expense_type.farm_id); }); @@ -249,7 +229,7 @@ describe('Expense Type Tests', () => { const { mainFarm, user } = await returnUserFarms(3); const expense = await returnExpenseType(mainFarm); - const res = await getRequestAsPromise({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); expect(res.status).toBe(200); expect(res.body[0].farm_id).toBe(expense.expense_type.farm_id); }); @@ -259,7 +239,7 @@ describe('Expense Type Tests', () => { const expense = await returnExpenseType(mainFarm); const [unAuthorizedUser] = await mocks.usersFactory(); - const res = await getRequestAsPromise({ + const res = await getRequest({ user_id: unAuthorizedUser.user_id, farm_id: mainFarm.farm_id, }); @@ -276,7 +256,7 @@ describe('Expense Type Tests', () => { const { mainFarm, user } = await returnUserFarms(1); const expense = await returnDefaultExpenseType(); - const res = await getDefaultRequestAsPromise({ + const res = await getDefaultRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -288,7 +268,7 @@ describe('Expense Type Tests', () => { const { mainFarm, user } = await returnUserFarms(2); const expense = await returnDefaultExpenseType(); - const res = await getDefaultRequestAsPromise({ + const res = await getDefaultRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -300,7 +280,7 @@ describe('Expense Type Tests', () => { const { mainFarm, user } = await returnUserFarms(3); const expense = await returnDefaultExpenseType(); - const res = await getDefaultRequestAsPromise({ + const res = await getDefaultRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -314,7 +294,7 @@ describe('Expense Type Tests', () => { test('Owner should get 403 if they try to delete default expense type', async () => { const { mainFarm, user } = await returnUserFarms(1); const expense = await returnDefaultExpenseType(); - const res = await deleteRequestAsPromise(expense.expense_type, { user_id: expense.user_id }); + const res = await deleteRequest(expense.expense_type, { user_id: expense.user_id }); expect(res.status).toBe(403); }); @@ -322,7 +302,7 @@ describe('Expense Type Tests', () => { const { mainFarm, user } = await returnUserFarms(2); const expense = await returnDefaultExpenseType(); - const res = await deleteRequestAsPromise(expense.expense_type, { user_id: user.user_id }); + const res = await deleteRequest(expense.expense_type, { user_id: user.user_id }); expect(res.status).toBe(403); }); @@ -330,7 +310,7 @@ describe('Expense Type Tests', () => { const { mainFarm, user } = await returnUserFarms(3); const expense = await returnDefaultExpenseType(); - const res = await deleteRequestAsPromise(expense.expense_type, { user_id: user.user_id }); + const res = await deleteRequest(expense.expense_type, { user_id: user.user_id }); expect(res.status).toBe(403); }); @@ -339,7 +319,7 @@ describe('Expense Type Tests', () => { const expense = await returnDefaultExpenseType(); const [unAuthorizedUser] = await mocks.usersFactory(); - const res = await deleteRequestAsPromise(expense.expense_type, { + const res = await deleteRequest(expense.expense_type, { user_id: unAuthorizedUser.user_id, }); expect(res.status).toBe(403); @@ -352,7 +332,7 @@ describe('Expense Type Tests', () => { const { mainFarm, user } = await returnUserFarms(1); const expense = await returnExpenseType(mainFarm); - const res = await deleteRequestAsPromise(expense.expense_type, { + const res = await deleteRequest(expense.expense_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -369,7 +349,7 @@ describe('Expense Type Tests', () => { const { mainFarm, user } = await returnUserFarms(2); const expense = await returnExpenseType(mainFarm); - const res = await deleteRequestAsPromise(expense.expense_type, { + const res = await deleteRequest(expense.expense_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -386,7 +366,7 @@ describe('Expense Type Tests', () => { const { mainFarm, user } = await returnUserFarms(3); const expense = await returnExpenseType(mainFarm); - const res = await deleteRequestAsPromise(expense.expense_type, { + const res = await deleteRequest(expense.expense_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -402,7 +382,7 @@ describe('Expense Type Tests', () => { const [unAuthorizedUser] = await mocks.usersFactory(); const expense = await returnExpenseType(mainFarm); - const res = await deleteRequestAsPromise(expense.expense_type, { + const res = await deleteRequest(expense.expense_type, { user_id: unAuthorizedUser.user_id, farm_id: mainFarm.farm_id, }); @@ -431,7 +411,7 @@ describe('Expense Type Tests', () => { associatedExpense, ); - const res = await deleteRequestAsPromise(expense_type, { + const res = await deleteRequest(expense_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -463,7 +443,7 @@ describe('Expense Type Tests', () => { associatedDeletedExpense, ); - const res = await deleteRequestAsPromise(expense_type, { + const res = await deleteRequest(expense_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -486,7 +466,7 @@ describe('Expense Type Tests', () => { const { mainFarm, user } = await returnUserFarms(1); const expense = await returnExpenseType(mainFarm); - const res = await patchExpenseTypeRequestAsPromise(expense.expense_type, { + const res = await patchExpenseTypeRequest(expense.expense_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -504,7 +484,7 @@ describe('Expense Type Tests', () => { const { mainFarm, user } = await returnUserFarms(2); const expense = await returnExpenseType(mainFarm); - const res = await patchExpenseTypeRequestAsPromise(expense.expense_type, { + const res = await patchExpenseTypeRequest(expense.expense_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -522,7 +502,7 @@ describe('Expense Type Tests', () => { const { mainFarm, user } = await returnUserFarms(3); const expense = await returnExpenseType(mainFarm); - const res = await patchExpenseTypeRequestAsPromise(expense.expense_type, { + const res = await patchExpenseTypeRequest(expense.expense_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -538,7 +518,7 @@ describe('Expense Type Tests', () => { const expense = await returnExpenseType(mainFarm); const [unAuthorizedUser] = await mocks.usersFactory(); - const res = await patchExpenseTypeRequestAsPromise(expense.expense_type, { + const res = await patchExpenseTypeRequest(expense.expense_type, { user_id: unAuthorizedUser.user_id, farm_id: mainFarm.farm_id, }); diff --git a/packages/api/tests/farm.test.js b/packages/api/tests/farm.test.js index bfde5c63b2..999e331ab3 100644 --- a/packages/api/tests/farm.test.js +++ b/packages/api/tests/farm.test.js @@ -46,19 +46,17 @@ describe('Farm Tests', () => { [newUser] = await usersFactory(); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('FarmModel test', () => { - test('should fail to patch an address on a created farm', async (done) => { + test('should fail to patch an address on a created farm', async () => { const [farm] = await farmFactory(); const filteredFarm = await farmModel.query().findById(farm.farm_id); expect(filteredFarm.sandbox_farm).toBeUndefined(); - done(); }); }); @@ -80,23 +78,19 @@ describe('Farm Tests', () => { country: 'US', }; - test('should return 400 status if blank farm is posted', (done) => { - postFarmRequest(blankFarm, newUser.user_id, (err, res) => { - expect(res.status).toBe(400); - done(); - }); + test('should return 400 status if blank farm is posted', async () => { + const res = await postFarmRequest(blankFarm, newUser.user_id); + expect(res.status).toBe(400); }); - test('should return 400 status if only farm name is filled', (done) => { - postFarmRequest({ ...blankFarm, farm_name: 'Test Farm' }, newUser.user_id, (err, res) => { - newUser.user_id; - expect(res.status).toBe(400); - done(); - }); + test('should return 400 status if only farm name is filled', async () => { + const res = await postFarmRequest({ ...blankFarm, farm_name: 'Test Farm' }, newUser.user_id); + newUser.user_id; + expect(res.status).toBe(400); }); - test('should return 400 status if name and invalid address are filled', (done) => { - postFarmRequest( + test('should return 400 status if name and invalid address are filled', async () => { + const res = await postFarmRequest( { ...blankFarm, farm_name: 'Test Farm', @@ -105,161 +99,142 @@ describe('Farm Tests', () => { country: 'CA', }, newUser.user_id, - (err, res) => { - expect(res.status).toBe(400); - done(); - }, ); + + expect(res.status).toBe(400); }); - test('should successfully create a farm if valid data is provided', async (done) => { + test('should successfully create a farm if valid data is provided', async () => { const [user] = await usersFactory(); const [farm] = await farmFactory(); await userFarmFactory( { promisedUser: [user], promisedFarm: [farm] }, { role_id: 1, status: 'Active' }, ); - postFarmRequest(validFarm, user.user_id, (err, res) => { + + { + const res = await postFarmRequest(validFarm, user.user_id); expect(res.status).toBe(201); const farm = res.body; expect(farm.units.currency).toBe('USD'); expect(farm.units.measurement).toBe('imperial'); - done(); - }); + } }); - test('should retrieve a recently created farm', async (done) => { + test('should retrieve a recently created farm', async () => { const [user] = await usersFactory(); const [farm] = await farmFactory(); await userFarmFactory( { promisedUser: [user], promisedFarm: [farm] }, { role_id: 1, status: 'Active' }, ); - postFarmRequest(validFarm, user.user_id, (err, res) => { - expect(res.status).toBe(201); - const farmId = res.body.farm_id; - getFarmRequest(farmId, user.user_id, (err, innerRes) => { - expect(innerRes.status).toBe(200); - const [receivedFarm] = innerRes.body; - expect(receivedFarm.farm_id).toBe(farmId); - done(); - }); - }); + const res = await postFarmRequest(validFarm, user.user_id); + expect(res.status).toBe(201); + const farmId = res.body.farm_id; + const innerRes = await getFarmRequest(farmId, user.user_id); + expect(innerRes.status).toBe(200); + const [receivedFarm] = innerRes.body; + expect(receivedFarm.farm_id).toBe(farmId); }); - test('should retrieve a recently created farm with units and currency', async (done) => { + test('should retrieve a recently created farm with units and currency', async () => { const [user] = await usersFactory(); const [farm] = await farmFactory(); await userFarmFactory( { promisedUser: [user], promisedFarm: [farm] }, { role_id: 1, status: 'Active' }, ); - postFarmRequest( + + const res = await postFarmRequest( { ...validFarm, units: { measurement: 'imperial', currency: 'MXN' } }, user.user_id, - (err, res) => { - expect(res.status).toBe(201); - const farmId = res.body.farm_id; - getFarmRequest(farmId, user.user_id, (err, innerRes) => { - expect(innerRes.status).toBe(200); - const [receivedFarm] = innerRes.body; - expect(receivedFarm.farm_id).toBe(farmId); - done(); - }); - }, ); + + expect(res.status).toBe(201); + const farmId = res.body.farm_id; + const innerRes = await getFarmRequest(farmId, user.user_id); + expect(innerRes.status).toBe(200); + const [receivedFarm] = innerRes.body; + expect(receivedFarm.farm_id).toBe(farmId); }); }); describe('Updating a Farm', () => { - test('should fail to patch an address on a created farm', async (done) => { + test('should fail to patch an address on a created farm', async () => { const [farm] = await farmFactory(); await userFarmFactory( { promisedUser: [newUser], promisedFarm: [farm] }, { role_id: 1, status: 'Active' }, ); - putFarmRequest( + const res = await putFarmRequest( { farm_id: farm.farm_id, address: farm.address + '2222' }, newUser.user_id, - (err, res) => { - expect(res.status).toBe(400); - done(); - }, ); + expect(res.status).toBe(400); }); - test('should succeed to change farm name', async (done) => { + test('should succeed to change farm name', async () => { const [farm] = await farmFactory(); await userFarmFactory( { promisedUser: [newUser], promisedFarm: [farm] }, { role_id: 1, status: 'Active' }, ); - putFarmRequest( + const res = await putFarmRequest( { farm_id: farm.farm_id, farm_name: 'OtherTestFarm' }, newUser.user_id, - async (err, res) => { - expect(res.status).toBe(200); - const [receivedFarm] = res.body; - expect(receivedFarm.farm_id).toBe(farm.farm_id); - expect(receivedFarm.farm_name).toBe('OtherTestFarm'); - const [farmQuery] = await knex.select().from('farm').where({ farm_id: farm.farm_id }); - expect(farmQuery.farm_name).toBe('OtherTestFarm'); - done(); - }, ); + expect(res.status).toBe(200); + const [receivedFarm] = res.body; + expect(receivedFarm.farm_id).toBe(farm.farm_id); + expect(receivedFarm.farm_name).toBe('OtherTestFarm'); + const [farmQuery] = await knex.select().from('farm').where({ farm_id: farm.farm_id }); + expect(farmQuery.farm_name).toBe('OtherTestFarm'); }); - test('should fail to update a farm that I dont own or manage', async (done) => { + test('should fail to update a farm that I dont own or manage', async () => { const [user] = await usersFactory(); const [farm] = await farmFactory(); await userFarmFactory( { promisedUser: [user], promisedFarm: [farm] }, { role_id: 3, status: 'Active' }, ); - putFarmRequest( + const res = await putFarmRequest( { farm_id: farm.farm_id, farm_name: 'OtherTestFarm' }, user.user_id, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, ); + expect(res.status).toBe(403); }); }); describe('Delete a Farm', () => { - test('should succeed on deleting a farm that I own or manage', async (done) => { + test('should succeed on deleting a farm that I own or manage', async () => { const [farm] = await farmFactory(); await userFarmFactory( { promisedUser: [newUser], promisedFarm: [farm] }, { role_id: 1, status: 'Active' }, ); - deleteRequest(farm, newUser.user_id, async (err, res) => { - expect(res.status).toBe(200); - const [farmQuery] = await knex.select().from('farm').where({ farm_id: farm.farm_id }); - expect(farmQuery.deleted).toBe(true); - done(); - }); + const res = await deleteRequest(farm, newUser.user_id); + expect(res.status).toBe(200); + const [farmQuery] = await knex.select().from('farm').where({ farm_id: farm.farm_id }); + expect(farmQuery.deleted).toBe(true); }); - test('should fail to delete a farm if I am not an owner or manager', async (done) => { + test('should fail to delete a farm if I am not an owner or manager', async () => { const [user] = await usersFactory(); const [farm] = await farmFactory(); await userFarmFactory( { promisedUser: [user], promisedFarm: [farm] }, { role_id: 3, status: 'Active' }, ); - deleteRequest(farm, user.user_id, async (err, res) => { - expect(res.status).toBe(403); - const farmQuery = await knex.select().from('farm').where({ farm_id: farm.farm_id }); - expect(farmQuery.length).not.toBe(0); - done(); - }); + const res = await deleteRequest(farm, user.user_id); + expect(res.status).toBe(403); + const farmQuery = await knex.select().from('farm').where({ farm_id: farm.farm_id }); + expect(farmQuery.length).not.toBe(0); }); }); describe('Ownership checks', () => { - test('should fail to update a farm Im not a part of', async (done) => { + test('should fail to update a farm Im not a part of', async () => { const [farmImNotPartOf] = await userFarmFactory(); const [farm] = await farmFactory(); await userFarmFactory( @@ -272,11 +247,10 @@ describe('Farm Tests', () => { .send({ farm_id: farmImNotPartOf.farm_id, farm_name: 'OtherTestFarm' }) .end((err, res) => { expect(res.status).toBe(403); - done(); }); }); - test('should fail to delete a farm Im not a part of ', async (done) => { + test('should fail to delete a farm Im not a part of ', async () => { const [farmImNotPartOf] = await userFarmFactory(); const [farm] = await farmFactory(); await userFarmFactory( @@ -288,97 +262,90 @@ describe('Farm Tests', () => { .set('user_id', newUser.user_id) .end((err, res) => { expect(res.status).toBe(403); - done(); }); }); }); describe('Patch default location test', () => { - test('should patch default_initial_location_id', async (done) => { + test('should patch default_initial_location_id', async () => { const [farm] = await farmFactory(); await userFarmFactory( { promisedUser: [newUser], promisedFarm: [farm] }, { role_id: 1, status: 'Active' }, ); const [field] = await mocks.fieldFactory({ promisedFarm: [farm] }); - patchDefaultLocationRequest( + + const res = await patchDefaultLocationRequest( farm.farm_id, { default_initial_location_id: field.location_id }, newUser.user_id, - async (err, res) => { - expect(res.status).toBe(200); - expect(res.body.default_initial_location_id).toBe(field.location_id); - done(); - }, ); + + expect(res.status).toBe(200); + expect(res.body.default_initial_location_id).toBe(field.location_id); }); - test('should fail to update default_initial_location_id when the location is not part of the farm', async (done) => { + test('should fail to update default_initial_location_id when the location is not part of the farm', async () => { const [farm] = await farmFactory(); await userFarmFactory( { promisedUser: [newUser], promisedFarm: [farm] }, { role_id: 1, status: 'Active' }, ); const [field] = await mocks.fieldFactory(); - patchDefaultLocationRequest( + + const res = await patchDefaultLocationRequest( farm.farm_id, { default_initial_location_id: field.location_id }, newUser.user_id, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, ); + + expect(res.status).toBe(403); }); }); }); -function postFarmRequest(data, user, callback) { - chai +function postFarmRequest(data, user) { + return chai .request(server) .post('/farm') .set('Content-Type', 'application/json') .set('user_id', user ?? '') - .send(data) - .end(callback); + .send(data); } -function getFarmRequest(id, user, callback) { - chai.request(server).get(`/farm/${id}`).set('user_id', user).end(callback); +function getFarmRequest(id, user) { + return chai.request(server).get(`/farm/${id}`).set('user_id', user); } -function putFarmRequest(data, user, callback) { - chai +function putFarmRequest(data, user) { + return chai .request(server) .put(`/farm/${data.farm_id}`) .set('farm_id', data.farm_id) .set('user_id', user) - .send(data) - .end(callback); + .send(data); } function minimalPutFarmRequest(farmId) { return chai.request(server).put(`/farm/${farmId}`); } -function deleteRequest(data, user, callback) { - chai +function deleteRequest(data, user) { + return chai .request(server) .delete(`/farm/${data.farm_id}`) .set('farm_id', data.farm_id) - .set('user_id', user) - .end(callback); + .set('user_id', user); } function minimalDeleteRequest(farmId) { return chai.request(server).delete(`/farm/${farmId}`); } -function patchDefaultLocationRequest(farm_id, data, user, callback) { - chai +function patchDefaultLocationRequest(farm_id, data, user) { + return chai .request(server) .patch(`/farm/${farm_id}/default_initial_location`) .set('Content-Type', 'application/json') .set('farm_id', farm_id) .set('user_id', user) - .send(data) - .end(callback); + .send(data); } diff --git a/packages/api/tests/fertilizer.test.js b/packages/api/tests/fertilizer.test.js index de51af5642..f324b85345 100644 --- a/packages/api/tests/fertilizer.test.js +++ b/packages/api/tests/fertilizer.test.js @@ -36,40 +36,30 @@ describe('Fertilizer Tests', () => { let owner; let farm; - function postFertilizerRequest( - data, - { user_id = owner.user_id, farm_id = farm.farm_id }, - callback, - ) { - chai + function postFertilizerRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post(`/fertilizer/farm/${farm_id}`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function getRequest({ user_id = owner.user_id, farm_id = farm.farm_id }, callback) { - chai + function getRequest({ user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .get(`/fertilizer/farm/${farm_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - function deleteRequest( - { user_id = owner.user_id, farm_id = farm.farm_id, fertilizer_id }, - callback, - ) { - chai + function deleteRequest({ user_id = owner.user_id, farm_id = farm.farm_id, fertilizer_id }) { + return chai .request(server) .delete(`/fertilizer/${fertilizer_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } function fakeUserFarm(role = 1) { @@ -91,10 +81,9 @@ describe('Fertilizer Tests', () => { ); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('Get && delete fertilizer', () => { @@ -103,7 +92,7 @@ describe('Fertilizer Tests', () => { [fertilizer] = await mocks.fertilizerFactory({ promisedFarm: [farm] }); }); - test('Should filter out deleted fertilizer', async (done) => { + test('Should filter out deleted fertilizer', async () => { await fertilizerModel .query() .context({ @@ -112,22 +101,18 @@ describe('Fertilizer Tests', () => { }) .findById(fertilizer.fertilizer_id) .delete(); - getRequest({ user_id: owner.user_id }, (err, res) => { - expect(res.status).toBe(404); - done(); - }); + const res = await getRequest({ user_id: owner.user_id }); + expect(res.status).toBe(404); }); - test('should get seeded fertilizer', async (done) => { + test('should get seeded fertilizer', async () => { let [seedFertilizer] = await mocks.fertilizerFactory( { promisedFarm: [{ farm_id: null }] }, mocks.fakeFertilizer(), ); - getRequest({ user_id: owner.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[1].fertilizer_id).toBe(seedFertilizer.fertilizer_id); - done(); - }); + const res = await getRequest({ user_id: owner.user_id }); + expect(res.status).toBe(200); + expect(res.body[1].fertilizer_id).toBe(seedFertilizer.fertilizer_id); }); describe('Get fertilizer authorization tests', () => { @@ -156,48 +141,38 @@ describe('Fertilizer Tests', () => { ); }); - test('Owner should get fertilizer by farm id', async (done) => { - getRequest({ user_id: owner.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].fertilizer_id).toBe(fertilizer.fertilizer_id); - done(); - }); + test('Owner should get fertilizer by farm id', async () => { + const res = await getRequest({ user_id: owner.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].fertilizer_id).toBe(fertilizer.fertilizer_id); }); - test('Manager should get fertilizer by farm id', async (done) => { - getRequest({ user_id: manager.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].fertilizer_id).toBe(fertilizer.fertilizer_id); - done(); - }); + test('Manager should get fertilizer by farm id', async () => { + const res = await getRequest({ user_id: manager.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].fertilizer_id).toBe(fertilizer.fertilizer_id); }); - test('Worker should get fertilizer by farm id', async (done) => { - getRequest({ user_id: worker.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].fertilizer_id).toBe(fertilizer.fertilizer_id); - done(); - }); + test('Worker should get fertilizer by farm id', async () => { + const res = await getRequest({ user_id: worker.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].fertilizer_id).toBe(fertilizer.fertilizer_id); }); - test('Should get status 403 if an unauthorizedUser tries to get fertilizer by farm id', async (done) => { - getRequest({ user_id: unAuthorizedUser.user_id }, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + test('Should get status 403 if an unauthorizedUser tries to get fertilizer by farm id', async () => { + const res = await getRequest({ user_id: unAuthorizedUser.user_id }); + expect(res.status).toBe(403); }); }); describe('Delete fertlizer', function () { - test('should return 403 if user tries to delete a seeded fertilizer', async (done) => { + test('should return 403 if user tries to delete a seeded fertilizer', async () => { let [seedFertilizer] = await mocks.fertilizerFactory( { promisedFarm: [{ farm_id: null }] }, mocks.fakeFertilizer(), ); - deleteRequest({ fertilizer_id: seedFertilizer.fertilizer_id }, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await deleteRequest({ fertilizer_id: seedFertilizer.fertilizer_id }); + expect(res.status).toBe(403); }); describe('Delete fertlizer authorization tests', () => { @@ -226,67 +201,56 @@ describe('Fertilizer Tests', () => { ); }); - test('Owner should delete a fertlizer', async (done) => { - deleteRequest({ fertilizer_id: fertilizer.fertilizer_id }, async (err, res) => { - expect(res.status).toBe(200); - const fertilizerRes = await fertilizerModel - .query() - .context({ showHidden: true }) - .where('fertilizer_id', fertilizer.fertilizer_id); - expect(fertilizerRes.length).toBe(1); - expect(fertilizerRes[0].deleted).toBe(true); - done(); - }); + test('Owner should delete a fertlizer', async () => { + const res = await deleteRequest({ fertilizer_id: fertilizer.fertilizer_id }); + expect(res.status).toBe(200); + const fertilizerRes = await fertilizerModel + .query() + .context({ showHidden: true }) + .where('fertilizer_id', fertilizer.fertilizer_id); + expect(fertilizerRes.length).toBe(1); + expect(fertilizerRes[0].deleted).toBe(true); }); - test('Manager should delete a fertilizer', async (done) => { - deleteRequest( - { user_id: manager.user_id, fertilizer_id: fertilizer.fertilizer_id }, - async (err, res) => { - expect(res.status).toBe(200); - const fertilizerRes = await fertilizerModel - .query() - .context({ showHidden: true }) - .where('fertilizer_id', fertilizer.fertilizer_id); - expect(fertilizerRes.length).toBe(1); - expect(fertilizerRes[0].deleted).toBe(true); - done(); - }, - ); + test('Manager should delete a fertilizer', async () => { + const res = await deleteRequest({ + user_id: manager.user_id, + fertilizer_id: fertilizer.fertilizer_id, + }); + expect(res.status).toBe(200); + const fertilizerRes = await fertilizerModel + .query() + .context({ showHidden: true }) + .where('fertilizer_id', fertilizer.fertilizer_id); + expect(fertilizerRes.length).toBe(1); + expect(fertilizerRes[0].deleted).toBe(true); }); - test('should return 403 if an unauthorized user tries to delete a fertilizer', async (done) => { - deleteRequest( - { user_id: unAuthorizedUser.user_id, fertilizer_id: fertilizer.fertilizer_id }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('should return 403 if an unauthorized user tries to delete a fertilizer', async () => { + const res = await deleteRequest({ + user_id: unAuthorizedUser.user_id, + fertilizer_id: fertilizer.fertilizer_id, + }); + + expect(res.status).toBe(403); }); - test('should return 403 if a worker tries to delete a fertilizer', async (done) => { - deleteRequest( - { user_id: worker.user_id, fertilizer_id: fertilizer.fertilizer_id }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('should return 403 if a worker tries to delete a fertilizer', async () => { + const res = await deleteRequest({ + user_id: worker.user_id, + fertilizer_id: fertilizer.fertilizer_id, + }); + expect(res.status).toBe(403); }); - test('Circumvent authorization by modifying farm_id', async (done) => { - deleteRequest( - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - fertilizer_id: fertilizer.fertilizer_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modifying farm_id', async () => { + const res = await deleteRequest({ + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + fertilizer_id: fertilizer.fertilizer_id, + }); + + expect(res.status).toBe(403); }); }); }); @@ -299,12 +263,10 @@ describe('Fertilizer Tests', () => { fakeFertilizer = getFakeFertilizer(); }); - test('should return 403 status if headers.farm_id is set to null', async (done) => { + test('should return 403 status if headers.farm_id is set to null', async () => { fakeFertilizer.farm_id = null; - postFertilizerRequest(fakeFertilizer, {}, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await postFertilizerRequest(fakeFertilizer, {}); + expect(res.status).toBe(403); }); describe('Post fertilizer authorization tests', () => { @@ -333,65 +295,53 @@ describe('Fertilizer Tests', () => { ); }); - test('Owner should post and get a valid crop', async (done) => { - postFertilizerRequest(fakeFertilizer, {}, async (err, res) => { - expect(res.status).toBe(201); - const fertilizers = await fertilizerModel - .query() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(fertilizers.length).toBe(1); - expect(fertilizers[0].fertilizer_type).toBe(fakeFertilizer.fertilizer_type); - done(); - }); + test('Owner should post and get a valid crop', async () => { + const res = await postFertilizerRequest(fakeFertilizer, {}); + expect(res.status).toBe(201); + const fertilizers = await fertilizerModel + .query() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(fertilizers.length).toBe(1); + expect(fertilizers[0].fertilizer_type).toBe(fakeFertilizer.fertilizer_type); }); - test('Manager should post and get a valid crop', async (done) => { - postFertilizerRequest(fakeFertilizer, { user_id: manager.user_id }, async (err, res) => { - expect(res.status).toBe(201); - const fertilizers = await fertilizerModel - .query() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(fertilizers.length).toBe(1); - expect(fertilizers[0].fertilizer_type).toBe(fakeFertilizer.fertilizer_type); - done(); - }); + test('Manager should post and get a valid crop', async () => { + const res = await postFertilizerRequest(fakeFertilizer, { user_id: manager.user_id }); + expect(res.status).toBe(201); + const fertilizers = await fertilizerModel + .query() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(fertilizers.length).toBe(1); + expect(fertilizers[0].fertilizer_type).toBe(fakeFertilizer.fertilizer_type); }); - test('should return 403 status if fertilizer is posted by worker', async (done) => { - postFertilizerRequest(fakeFertilizer, { user_id: worker.user_id }, async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): add:fertilizers', - ); - done(); - }); + test('should return 403 status if fertilizer is posted by worker', async () => { + const res = await postFertilizerRequest(fakeFertilizer, { user_id: worker.user_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): add:fertilizers', + ); }); - test('should return 403 status if fertilizer is posted by unauthorized user', async (done) => { - postFertilizerRequest( - fakeFertilizer, - { user_id: unAuthorizedUser.user_id }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): add:fertilizers', - ); - done(); - }, + test('should return 403 status if fertilizer is posted by unauthorized user', async () => { + const res = await postFertilizerRequest(fakeFertilizer, { + user_id: unAuthorizedUser.user_id, + }); + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): add:fertilizers', ); }); - test('Circumvent authorization by modify farm_id', async (done) => { - postFertilizerRequest( - fakeFertilizer, - { user_id: unAuthorizedUser.user_id, farm_id: farmunAuthorizedUser.farm_id }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modify farm_id', async () => { + const res = await postFertilizerRequest(fakeFertilizer, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); }); }); }); diff --git a/packages/api/tests/harvestUseType.test.js b/packages/api/tests/harvestUseType.test.js index dd89cbd34b..67b357683c 100644 --- a/packages/api/tests/harvestUseType.test.js +++ b/packages/api/tests/harvestUseType.test.js @@ -39,15 +39,12 @@ describe('harvestUseType Tests', () => { token = global.token; }); - function getHarvestUseTypeByFarmID( - { - user_id = owner.user_id, - farm_id = farm.farm_id, - url = `/log/harvest_use_types/farm/${farm.farm_id}`, - }, - callback, - ) { - chai.request(server).get(url).set('user_id', user_id).set('farm_id', farm_id).end(callback); + function getHarvestUseTypeByFarmID({ + user_id = owner.user_id, + farm_id = farm.farm_id, + url = `/log/harvest_use_types/farm/${farm.farm_id}`, + }) { + return chai.request(server).get(url).set('user_id', user_id).set('farm_id', farm_id); } function addHarvestUseType( @@ -57,15 +54,13 @@ describe('harvestUseType Tests', () => { farm_id = farm.farm_id, url = `/log/harvest_use_types/farm/${farm.farm_id}`, }, - callback, ) { - chai + return chai .request(server) .post(url) .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } function fakeUserFarm(role = 1) { @@ -81,10 +76,9 @@ describe('harvestUseType Tests', () => { ); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('harvestUseType tests', () => { @@ -147,47 +141,39 @@ describe('harvestUseType Tests', () => { [customUseType] = await mocks.harvest_use_typeFactory({ promisedFarm: farm }); }); - test('Owner should get harvestUseType by farm id', async (done) => { - getHarvestUseTypeByFarmID({ user_id: newOwner.user_id }, (err, res) => { - expect(res.status).toBe(200); - for (let item of defaultState) { - expect( - res.body.some((el) => el.harvest_use_type_name === item.harvest_use_type_name), - ).toBe(true); - } - done(); - }); + test('Owner should get harvestUseType by farm id', async () => { + const res = await getHarvestUseTypeByFarmID({ user_id: newOwner.user_id }); + expect(res.status).toBe(200); + for (let item of defaultState) { + expect( + res.body.some((el) => el.harvest_use_type_name === item.harvest_use_type_name), + ).toBe(true); + } }); - test('Manager should get harvestUseType by farm id', async (done) => { - getHarvestUseTypeByFarmID({ user_id: manager.user_id }, (err, res) => { - expect(res.status).toBe(200); - for (let item of defaultState) { - expect( - res.body.some((el) => el.harvest_use_type_name === item.harvest_use_type_name), - ).toBe(true); - } - done(); - }); + test('Manager should get harvestUseType by farm id', async () => { + const res = await getHarvestUseTypeByFarmID({ user_id: manager.user_id }); + expect(res.status).toBe(200); + for (let item of defaultState) { + expect( + res.body.some((el) => el.harvest_use_type_name === item.harvest_use_type_name), + ).toBe(true); + } }); - test('Worker should get harvestUseType by farm id', async (done) => { - getHarvestUseTypeByFarmID({ user_id: worker.user_id }, (err, res) => { - expect(res.status).toBe(200); - for (let item of defaultState) { - expect( - res.body.some((el) => el.harvest_use_type_name === item.harvest_use_type_name), - ).toBe(true); - } - done(); - }); + test('Worker should get harvestUseType by farm id', async () => { + const res = await getHarvestUseTypeByFarmID({ user_id: worker.user_id }); + expect(res.status).toBe(200); + for (let item of defaultState) { + expect( + res.body.some((el) => el.harvest_use_type_name === item.harvest_use_type_name), + ).toBe(true); + } }); - test('Unauthorized user should not get harvestUseType by farm id', async (done) => { - getHarvestUseTypeByFarmID({ user_id: unAuthorizedUser.user_id }, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + test('Unauthorized user should not get harvestUseType by farm id', async () => { + const res = await getHarvestUseTypeByFarmID({ user_id: unAuthorizedUser.user_id }); + expect(res.status).toBe(403); }); }); @@ -225,76 +211,64 @@ describe('harvestUseType Tests', () => { [existingCustomUseType] = await mocks.harvest_use_typeFactory({ promisedFarm: farm }); }); - test('Owner should add harvestUseType', async (done) => { - addHarvestUseType( + test('Owner should add harvestUseType', async () => { + const res = await addHarvestUseType( { name: fakeHarvestUseType.harvest_use_type_name }, { user_id: newOwner.user_id }, - (err, res) => { - expect(res.status).toBe(201); - expect(res.body.harvest_use_type_name).toBe(fakeHarvestUseType.harvest_use_type_name); - expect(res.body.farm_id).toBe(farm.farm_id); - done(); - }, ); + + expect(res.status).toBe(201); + expect(res.body.harvest_use_type_name).toBe(fakeHarvestUseType.harvest_use_type_name); + expect(res.body.farm_id).toBe(farm.farm_id); }); - test('Manager should add harvestUseType', async (done) => { - addHarvestUseType( + test('Manager should add harvestUseType', async () => { + const res = await addHarvestUseType( { name: fakeHarvestUseType.harvest_use_type_name }, { user_id: manager.user_id }, - (err, res) => { - expect(res.status).toBe(201); - expect(res.body.harvest_use_type_name).toBe(fakeHarvestUseType.harvest_use_type_name); - expect(res.body.farm_id).toBe(farm.farm_id); - done(); - }, ); + + expect(res.status).toBe(201); + expect(res.body.harvest_use_type_name).toBe(fakeHarvestUseType.harvest_use_type_name); + expect(res.body.farm_id).toBe(farm.farm_id); }); - test('Worker should add harvestUseType', async (done) => { - addHarvestUseType( + test('Worker should add harvestUseType', async () => { + const res = await addHarvestUseType( { name: fakeHarvestUseType.harvest_use_type_name }, { user_id: worker.user_id }, - (err, res) => { - expect(res.status).toBe(201); - expect(res.body.harvest_use_type_name).toBe(fakeHarvestUseType.harvest_use_type_name); - expect(res.body.farm_id).toBe(farm.farm_id); - done(); - }, ); + + expect(res.status).toBe(201); + expect(res.body.harvest_use_type_name).toBe(fakeHarvestUseType.harvest_use_type_name); + expect(res.body.farm_id).toBe(farm.farm_id); }); - test('Unauthorized user should not add harvestUseType', async (done) => { - addHarvestUseType( + test('Unauthorized user should not add harvestUseType', async () => { + const res = await addHarvestUseType( { name: fakeHarvestUseType.harvest_use_type_name }, { user_id: unAuthorizedUser.user_id }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, ); + + expect(res.status).toBe(403); }); - test('Owner should fail to add duplicate harvestUseType', async (done) => { - addHarvestUseType( + test('Owner should fail to add duplicate harvestUseType', async () => { + const res = await addHarvestUseType( { name: existingCustomUseType.harvest_use_type_name }, { user_id: newOwner.user_id }, - (err, res) => { - expect(res.status).toBe(400); - done(); - }, ); + + expect(res.status).toBe(400); }); - test('Manager should fail to add duplicate harvestUseType', async (done) => { - addHarvestUseType( + test('Manager should fail to add duplicate harvestUseType', async () => { + const res = await addHarvestUseType( { name: existingCustomUseType.harvest_use_type_name }, { user_id: manager.user_id }, - (err, res) => { - expect(res.status).toBe(400); - done(); - }, ); + + expect(res.status).toBe(400); }); }); }); diff --git a/packages/api/tests/insightsAPI.test.js b/packages/api/tests/insightsAPI.test.js index 435736be01..ea428f9b18 100644 --- a/packages/api/tests/insightsAPI.test.js +++ b/packages/api/tests/insightsAPI.test.js @@ -39,90 +39,71 @@ import insigntController from '../src/controllers/insightController'; describe('insights test', () => { const emptyNutrients = { energy: 0, lipid: 0, protein: 0, vitc: 0, vita_rae: 0 }; - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('Soil Om', () => { - test('Should get soil om if Im on my farm as an owner', async (done) => { + test('Should get soil om if Im on my farm as an owner', async () => { const [{ user_id, farm_id }] = await createUserFarm(1); - getInsight(farm_id, user_id, 'soil_om', (err, res) => { - expect(res.status).toBe(200); - done(); - }); + const res = await getInsight(farm_id, user_id, 'soil_om'); + expect(res.status).toBe(200); }); - test('Should get soil om if Im on my farm as a manager', async (done) => { + test('Should get soil om if Im on my farm as a manager', async () => { const [{ user_id, farm_id }] = await createUserFarm(2); - getInsight(farm_id, user_id, 'soil_om', (err, res) => { - expect(res.status).toBe(200); - done(); - }); + const res = await getInsight(farm_id, user_id, 'soil_om'); + expect(res.status).toBe(200); }); - test('Should get soil om if Im on my farm as a worker', async (done) => { + test('Should get soil om if Im on my farm as a worker', async () => { const [{ user_id, farm_id }] = await createUserFarm(3); - getInsight(farm_id, user_id, 'soil_om', (err, res) => { - expect(res.status).toBe(200); - done(); - }); + const res = await getInsight(farm_id, user_id, 'soil_om'); + expect(res.status).toBe(200); }); }); describe('labour happiness', () => { - test('Should get labour happiness if Im on my farm as an owner', async (done) => { + test('Should get labour happiness if Im on my farm as an owner', async () => { const [{ user_id, farm_id }] = await createUserFarm(1); - getInsight(farm_id, user_id, 'labour_happiness', (err, res) => { - expect(res.status).toBe(200); - done(); - }); + const res = await getInsight(farm_id, user_id, 'labour_happiness'); + expect(res.status).toBe(200); }); - test('Should get labour happiness if Im on my farm as a manager', async (done) => { + test('Should get labour happiness if Im on my farm as a manager', async () => { const [{ user_id, farm_id }] = await createUserFarm(2); - getInsight(farm_id, user_id, 'labour_happiness', (err, res) => { - expect(res.status).toBe(200); - done(); - }); + const res = await getInsight(farm_id, user_id, 'labour_happiness'); + expect(res.status).toBe(200); }); - test('Should get labour happiness if Im on my farm as a worker', async (done) => { + test('Should get labour happiness if Im on my farm as a worker', async () => { const [{ user_id, farm_id }] = await createUserFarm(3); - getInsight(farm_id, user_id, 'labour_happiness', (err, res) => { - expect(res.status).toBe(200); - done(); - }); + const res = await getInsight(farm_id, user_id, 'labour_happiness'); + expect(res.status).toBe(200); }); }); describe('biodiversity', () => { - test('Should get biodiversity if Im on my farm as an owner', async (done) => { + test('Should get biodiversity if Im on my farm as an owner', async () => { const [{ user_id, farm_id }] = await createUserFarm(1); - getInsight(farm_id, user_id, 'biodiversity', (err, res) => { - expect(res.status).toBe(200); - done(); - }); + const res = await getInsight(farm_id, user_id, 'biodiversity'); + expect(res.status).toBe(200); }); - test('Should get biodiversity if Im on my farm as a manager', async (done) => { + test('Should get biodiversity if Im on my farm as a manager', async () => { const [{ user_id, farm_id }] = await createUserFarm(2); - getInsight(farm_id, user_id, 'biodiversity', (err, res) => { - expect(res.status).toBe(200); - done(); - }); + const res = await getInsight(farm_id, user_id, 'biodiversity'); + expect(res.status).toBe(200); }); - test('Should get biodiversity if Im on my farm as a worker', async (done) => { + test('Should get biodiversity if Im on my farm as a worker', async () => { const [{ user_id, farm_id }] = await createUserFarm(3); - getInsight(farm_id, user_id, 'biodiversity', (err, res) => { - expect(res.status).toBe(200); - done(); - }); + const res = await getInsight(farm_id, user_id, 'biodiversity'); + expect(res.status).toBe(200); }); }); describe('prices distance', () => { describe('Unit tests', () => { - test('Distance between two coordinate test', async (done) => { + test('Distance between two coordinate test', async () => { expect( insightHelpers.distance(62.990967, -71.463767, 52.990967, -91.463767) - 1612.09, ).toBeLessThan(0.5); @@ -130,10 +111,9 @@ describe('insights test', () => { insightHelpers.distance(-62.990967, 171.463767, -52.990967, 191.463767) - 1612.09, ).toBeLessThan(0.5); expect(insightHelpers.distance(62.990967, -71.463767, 62.990967, -71.463767)).toBe(0); - done(); }); - test('FormatPricesNearByData Test', async (done) => { + test('FormatPricesNearByData Test', async () => { const salesByCropsFarmIdMonth = [ { year_month: '2020-12', @@ -266,13 +246,12 @@ describe('insights test', () => { }; expect(formatted2).toEqual(expected2); - done(); }); // FIXME: these tests are incomplete and skipped, seems a mocks.cropSaleFactory // doesn't exist anywhere in the project, perhaps someone forgot to push // that implementation. - xtest('queryCropSalesNearByStartDateAndFarmId test', async (done) => { + xtest('queryCropSalesNearByStartDateAndFarmId test', async () => { const startdate = moment('2020-12-01').format('YYYY-MM-DD'); const gridPoint0 = { lat: 62.990967, lng: -71.463767 }; const gridPoint5West = { lat: 62.990967, lng: -71.553767 }; @@ -388,29 +367,80 @@ describe('insights test', () => { startdate, }); - getInsightWithQuery(farm_id, user_id, 'prices/distance', getQuery(5), (err, res) => { + const res = await getInsightWithQuery(farm_id, user_id, 'prices/distance', getQuery(5)); + expect(res.status).toBe(200); + const crop0CommonName = crops[0].crop_common_name; + const crop0TotalPrice = + crop0Sales[0].sale_value + crop0Sales[1].sale_value + crop0Sales[7].sale_value; + const crop0TotalQuantity = + crop0Sales[0].quantity + crop0Sales[1].quantity + crop0Sales[7].quantity; + + const crop1CommonName = crops[1].crop_common_name; + const crop1TotalPrice = + crop1Sales[0].sale_value + + crop1Sales[1].sale_value + + crop1Sales[2].sale_value + + crop1Sales[3].sale_value; + const crop1TotalQuantity = + crop1Sales[0].quantity + + crop1Sales[1].quantity + + crop1Sales[2].quantity + + crop1Sales[3].quantity; + + const crop12020CommonName = crops[1].crop_common_name; + const crop12020TotalPrice = crop12020Sales[0].sale_value + crop12020Sales[1].sale_value; + const crop12020TotalQuantity = crop12020Sales[0].quantity + crop12020Sales[1].quantity; + const data = res.body.data; + for (const cropSaleRes of data) { + if (cropSaleRes[crop0CommonName]) { + expect(cropSaleRes[crop0CommonName][0].crop_date).toBe( + moment('2020-12-01').format('YYYY-MM'), + ); + expect( + cropSaleRes[crop0CommonName][0].crop_price - + crop0Sales[0].sale_value / crop0Sales[0].quantity, + ).toBeLessThan(0.01); + expect( + cropSaleRes[crop0CommonName][0].network_price - crop0TotalPrice / crop0TotalQuantity, + ).toBeLessThan(0.01); + } else if (cropSaleRes[crop1CommonName]) { + expect(cropSaleRes[crop1CommonName][0].crop_date).toBe( + moment('2020-12-01').format('YYYY-MM'), + ); + expect( + cropSaleRes[crop1CommonName][0].crop_price - + crop12020Sales[0].sale_value / crop12020Sales[0].quantity, + ).toBeLessThan(0.01); + expect( + cropSaleRes[crop1CommonName][0].network_price - + crop12020TotalPrice / crop12020TotalQuantity, + ).toBeLessThan(0.01); + expect(cropSaleRes[crop1CommonName][1].crop_date).toBe(moment().format('YYYY-MM')); + expect( + cropSaleRes[crop1CommonName][1].crop_price - + (crop1Sales[0].sale_value + crop1Sales[1].sale_value) / + (crop1Sales[0].quantity + crop1Sales[1].quantity), + ).toBeLessThan(0.01); + expect( + cropSaleRes[crop1CommonName][1].network_price - crop1TotalPrice / crop1TotalQuantity, + ).toBeLessThan(0.01); + } + } + + { + const res = await getInsightWithQuery(farm_id, user_id, 'prices/distance', getQuery(10)); expect(res.status).toBe(200); const crop0CommonName = crops[0].crop_common_name; const crop0TotalPrice = - crop0Sales[0].sale_value + crop0Sales[1].sale_value + crop0Sales[7].sale_value; + crop0Sales[0].sale_value + + crop0Sales[1].sale_value + + crop0Sales[2].sale_value + + crop0Sales[7].sale_value; const crop0TotalQuantity = - crop0Sales[0].quantity + crop0Sales[1].quantity + crop0Sales[7].quantity; - - const crop1CommonName = crops[1].crop_common_name; - const crop1TotalPrice = - crop1Sales[0].sale_value + - crop1Sales[1].sale_value + - crop1Sales[2].sale_value + - crop1Sales[3].sale_value; - const crop1TotalQuantity = - crop1Sales[0].quantity + - crop1Sales[1].quantity + - crop1Sales[2].quantity + - crop1Sales[3].quantity; - - const crop12020CommonName = crops[1].crop_common_name; - const crop12020TotalPrice = crop12020Sales[0].sale_value + crop12020Sales[1].sale_value; - const crop12020TotalQuantity = crop12020Sales[0].quantity + crop12020Sales[1].quantity; + crop0Sales[0].quantity + + crop0Sales[1].quantity + + crop0Sales[2].quantity + + crop0Sales[7].quantity; const data = res.body.data; for (const cropSaleRes of data) { if (cropSaleRes[crop0CommonName]) { @@ -425,91 +455,31 @@ describe('insights test', () => { cropSaleRes[crop0CommonName][0].network_price - crop0TotalPrice / crop0TotalQuantity, ).toBeLessThan(0.01); - } else if (cropSaleRes[crop1CommonName]) { - expect(cropSaleRes[crop1CommonName][0].crop_date).toBe( - moment('2020-12-01').format('YYYY-MM'), - ); - expect( - cropSaleRes[crop1CommonName][0].crop_price - - crop12020Sales[0].sale_value / crop12020Sales[0].quantity, - ).toBeLessThan(0.01); - expect( - cropSaleRes[crop1CommonName][0].network_price - - crop12020TotalPrice / crop12020TotalQuantity, - ).toBeLessThan(0.01); - expect(cropSaleRes[crop1CommonName][1].crop_date).toBe(moment().format('YYYY-MM')); - expect( - cropSaleRes[crop1CommonName][1].crop_price - - (crop1Sales[0].sale_value + crop1Sales[1].sale_value) / - (crop1Sales[0].quantity + crop1Sales[1].quantity), - ).toBeLessThan(0.01); - expect( - cropSaleRes[crop1CommonName][1].network_price - - crop1TotalPrice / crop1TotalQuantity, - ).toBeLessThan(0.01); } } - - getInsightWithQuery(farm_id, user_id, 'prices/distance', getQuery(10), (err, res) => { - expect(res.status).toBe(200); - const crop0CommonName = crops[0].crop_common_name; - const crop0TotalPrice = - crop0Sales[0].sale_value + - crop0Sales[1].sale_value + - crop0Sales[2].sale_value + - crop0Sales[7].sale_value; - const crop0TotalQuantity = - crop0Sales[0].quantity + - crop0Sales[1].quantity + - crop0Sales[2].quantity + - crop0Sales[7].quantity; - const data = res.body.data; - for (const cropSaleRes of data) { - if (cropSaleRes[crop0CommonName]) { - expect(cropSaleRes[crop0CommonName][0].crop_date).toBe( - moment('2020-12-01').format('YYYY-MM'), - ); - expect( - cropSaleRes[crop0CommonName][0].crop_price - - crop0Sales[0].sale_value / crop0Sales[0].quantity, - ).toBeLessThan(0.01); - expect( - cropSaleRes[crop0CommonName][0].network_price - - crop0TotalPrice / crop0TotalQuantity, - ).toBeLessThan(0.01); - } - } - done(); - }); - }); + } }); }); - test('Should get prices distance if Im on my farm as an owner', async (done) => { + test('Should get prices distance if Im on my farm as an owner', async () => { const [{ user_id, farm_id }] = await createUserFarm(1); const query = mocks.fakePriceInsightForTests(); - getInsightWithQuery(farm_id, user_id, 'prices/distance', query, (err, res) => { - expect(res.status).toBe(200); - done(); - }); + const res = await getInsightWithQuery(farm_id, user_id, 'prices/distance', query); + expect(res.status).toBe(200); }); - test('Should get prices distance if Im on my farm as a manager', async (done) => { + test('Should get prices distance if Im on my farm as a manager', async () => { const [{ user_id, farm_id }] = await createUserFarm(2); const query = mocks.fakePriceInsightForTests(); - getInsightWithQuery(farm_id, user_id, 'prices/distance', query, (err, res) => { - expect(res.status).toBe(200); - done(); - }); + const res = await getInsightWithQuery(farm_id, user_id, 'prices/distance', query); + expect(res.status).toBe(200); }); - test('Should get prices distance if Im on my farm as a worker', async (done) => { + test('Should get prices distance if Im on my farm as a worker', async () => { const [{ user_id, farm_id }] = await createUserFarm(3); const query = mocks.fakePriceInsightForTests(); - getInsightWithQuery(farm_id, user_id, 'prices/distance', query, (err, res) => { - expect(res.status).toBe(200); - done(); - }); + const res = await getInsightWithQuery(farm_id, user_id, 'prices/distance', query); + expect(res.status).toBe(200); }); }); }); @@ -524,17 +494,16 @@ function createUserFarm(role) { ); } -function getInsight(farmId, userId, route, callback) { - chai +function getInsight(farmId, userId, route) { + return chai .request(server) .get(`/insight/${route}/${farmId}`) .set('farm_id', farmId) - .set('user_id', userId) - .end(callback); + .set('user_id', userId); } -function getInsightWithQuery(farmId, userId, route, query, callback) { - chai +function getInsightWithQuery(farmId, userId, route, query) { + return chai .request(server) .get( `/insight/${route}/${farmId}?distance=${query.distance}&lat=${query.lat}&long=${ @@ -542,6 +511,5 @@ function getInsightWithQuery(farmId, userId, route, query, callback) { }&startdate=${query.startdate || '2020-1-1'}`, ) .set('farm_id', farmId) - .set('user_id', userId) - .end(callback); + .set('user_id', userId); } diff --git a/packages/api/tests/invite.user.test.js b/packages/api/tests/invite.user.test.js index 8bf806ec55..7990ee0acf 100644 --- a/packages/api/tests/invite.user.test.js +++ b/packages/api/tests/invite.user.test.js @@ -24,21 +24,19 @@ import { tableCleanup } from './testEnvironment.js'; describe('Invite user', () => { let axios; - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); - function postCreateUser({ user_id, farm_id }, data, callback) { - chai + function postCreateUser({ user_id, farm_id }, data) { + return chai .request(server) .post('/user/invite') .set('user_id', user_id) .set('farm_id', farm_id) .set('Content-Type', 'application/json') - .send(data) - .end(callback); + .send(data); } function fakeUser(farm_id, role_id) { @@ -75,33 +73,27 @@ describe('Invite user', () => { }); }); - test('Owner should be able to invite a user', async (done) => { - postCreateUser({ user_id: user, farm_id: farm }, fakeUser(farm, 2), (err, res) => { - expect(res.status).toBe(201); - done(); - }); + test('Owner should be able to invite a user', async () => { + const res = await postCreateUser({ user_id: user, farm_id: farm }, fakeUser(farm, 2)); + expect(res.status).toBe(201); }); - test('Manager should be able to invite a user', async (done) => { + test('Manager should be able to invite a user', async () => { let [{ user_id }] = await mocks.userFarmFactory( { promisedFarm: [{ farm_id: farm }] }, { role_id: 2, status: 'Active' }, ); - postCreateUser({ user_id, farm_id: farm }, fakeUser(farm, 2), (err, res) => { - expect(res.status).toBe(201); - done(); - }); + const res = await postCreateUser({ user_id, farm_id: farm }, fakeUser(farm, 2)); + expect(res.status).toBe(201); }); - test('Worker should fail to invite a user', async (done) => { + test('Worker should fail to invite a user', async () => { let [{ user_id }] = await mocks.userFarmFactory( { promisedFarm: [{ farm_id: farm }] }, { role_id: 3, status: 'Active' }, ); - postCreateUser({ user_id, farm_id: farm }, fakeUser(farm, 3), (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await postCreateUser({ user_id, farm_id: farm }, fakeUser(farm, 3)); + expect(res.status).toBe(403); }); }); }); diff --git a/packages/api/tests/jwt.test.js b/packages/api/tests/jwt.test.js index 487e7123cb..5fd605fc4f 100644 --- a/packages/api/tests/jwt.test.js +++ b/packages/api/tests/jwt.test.js @@ -43,48 +43,45 @@ describe('JWT Tests', () => { let newUser; let accessToken; - async function deleteFarmRequest(data, user_id, callback) { + async function deleteFarmRequest(data, user_id) { const token = await getAuthorizationHeader(user_id); - chai + + return chai .request(server) .delete(`/farm/${data.farm_id}`) .set('farm_id', data.farm_id) .set('user_id', user_id) - .set('Authorization', token) - .end(callback); + .set('Authorization', token); } - function deleteFarmRequestWithoutToken(data, user, callback) { - chai + function deleteFarmRequestWithoutToken(data, user) { + return chai .request(server) .delete(`/farm/${data.farm_id}`) .set('farm_id', data.farm_id) .set('user_id', user) - .set('Authorization', 'token') - .end(callback); + .set('Authorization', 'token'); } - function postResetPasswordRequest(email, callback) { - chai.request(server).post(`/password_reset/send_email`).send({ email }).end(callback); + function postResetPasswordRequest(email) { + return chai.request(server).post(`/password_reset/send_email`).send({ email }); } - function getValidateRequest(resetPasswordToken, user_id, callback) { - chai + function getValidateRequest(resetPasswordToken, user_id) { + return chai .request(server) .get(`/password_reset/validate`) .set('user_id', user_id) - .set('Authorization', `Bearer ${resetPasswordToken}`) - .end(callback); + .set('Authorization', `Bearer ${resetPasswordToken}`); } - function putPasswordRequest(resetPasswordToken, user, callback) { - chai + function putPasswordRequest(resetPasswordToken, user) { + return chai .request(server) .put(`/password_reset`) .set('user_id', user.user_id) .set('Authorization', `Bearer ${resetPasswordToken}`) - .send(user) - .end(callback); + .send(user); } async function insertPasswordRow({ @@ -138,46 +135,41 @@ describe('JWT Tests', () => { [newUser] = await usersFactory(); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('Access jwt test', () => { - test('should succeed on deleting a farm with valid token', async (done) => { + test('should succeed on deleting a farm with valid token', async () => { const [farm] = await farmFactory(); await userFarmFactory( { promisedUser: [newUser], promisedFarm: [farm] }, { role_id: 1, status: 'Active' }, ); - deleteFarmRequest(farm, newUser.user_id, async (err, res) => { - expect(res.status).toBe(200); - const [farmQuery] = await knex.select().from('farm').where({ farm_id: farm.farm_id }); - expect(farmQuery.deleted).toBe(true); - done(); - }); + const res = await deleteFarmRequest(farm, newUser.user_id); + expect(res.status).toBe(200); + const [farmQuery] = await knex.select().from('farm').where({ farm_id: farm.farm_id }); + expect(farmQuery.deleted).toBe(true); }); - test('should fail on deleting a farm without valid token', async (done) => { + test('should fail on deleting a farm without valid token', async () => { const [farm] = await farmFactory(); await userFarmFactory( { promisedUser: [newUser], promisedFarm: [farm] }, { role_id: 1, status: 'Active' }, ); - deleteFarmRequestWithoutToken(farm, newUser.user_id, async (err, res) => { - expect(res.status).toBe(401); - const [farmQuery] = await knex.select().from('farm').where({ farm_id: farm.farm_id }); - expect(farmQuery.deleted).toBe(false); - done(); - }); + const res = await deleteFarmRequestWithoutToken(farm, newUser.user_id); + expect(res.status).toBe(401); + const [farmQuery] = await knex.select().from('farm').where({ farm_id: farm.farm_id }); + expect(farmQuery.deleted).toBe(false); }); }); describe('Reset password jwt test', () => { let resetPasswordToken; - beforeEach(async (done) => { + beforeEach(async () => { const { createToken } = require('../src/util/jwt'); createToken.mockImplementation(async (type, user) => { if (user.reset_token_version === undefined) { @@ -193,73 +185,71 @@ describe('JWT Tests', () => { resetPasswordToken = undefined; knex('password').delete(); - done(); }); - test('Validate a valid token', async (done) => { + test('Validate a valid token', async () => { const resetPasswordToken = await createToken('passwordReset', newUser); const user = jsonwebtoken.verify(resetPasswordToken, process.env.JWT_RESET_SECRET); expect(user.user_id).toEqual(newUser.user_id); - done(); }); - test('Should send a valid token through email when reset_token_version === 0', async (done) => { + test('Should send a valid token through email when reset_token_version === 0', async () => { const oldRow = await insertPasswordRow({ reset_token_version: 0, user_id: newUser.user_id }); - postResetPasswordRequest(newUser.email, async (err, res) => { + const res = await postResetPasswordRequest(newUser.email); + expect(res.status).toBe(200); + const user = jsonwebtoken.verify(resetPasswordToken, process.env.JWT_RESET_SECRET); + expect(user.reset_token_version).toBe(0); + const { reset_token_version, created_at } = await knex('password') + .where({ user_id: newUser.user_id }) + .first(); + expect(reset_token_version).toBe(1); + expect(created_at.getTime()).toBeGreaterThanOrEqual(oldRow.created_at.getTime()); + + { + const res = await getValidateRequest(resetPasswordToken, newUser.user_id); expect(res.status).toBe(200); - const user = jsonwebtoken.verify(resetPasswordToken, process.env.JWT_RESET_SECRET); - expect(user.reset_token_version).toBe(0); - const { reset_token_version, created_at } = await knex('password') - .where({ user_id: newUser.user_id }) - .first(); - expect(reset_token_version).toBe(1); - expect(created_at.getTime()).toBeGreaterThanOrEqual(oldRow.created_at.getTime()); - getValidateRequest(resetPasswordToken, newUser.user_id, async (err, res) => { - expect(res.status).toBe(200); - expect(res.body.isValid).toBe(true); - done(); - }); - }); + expect(res.body.isValid).toBe(true); + } }); - test('Should send a valid token through email when reset_token_version === 1', async (done) => { + test('Should send a valid token through email when reset_token_version === 1', async () => { const oldRow = await insertPasswordRow({ reset_token_version: 1, user_id: newUser.user_id }); - postResetPasswordRequest(newUser.email, async (err, res) => { + const res = await postResetPasswordRequest(newUser.email); + expect(res.status).toBe(200); + const user = jsonwebtoken.verify(resetPasswordToken, process.env.JWT_RESET_SECRET); + expect(user.reset_token_version).toBe(1); + const { reset_token_version, created_at } = await knex('password') + .where({ user_id: newUser.user_id }) + .first(); + expect(reset_token_version).toBe(2); + expect(created_at.getTime()).toBe(oldRow.created_at.getTime()); + + { + const res = await getValidateRequest(resetPasswordToken, newUser.user_id); expect(res.status).toBe(200); - const user = jsonwebtoken.verify(resetPasswordToken, process.env.JWT_RESET_SECRET); - expect(user.reset_token_version).toBe(1); - const { reset_token_version, created_at } = await knex('password') - .where({ user_id: newUser.user_id }) - .first(); - expect(reset_token_version).toBe(2); - expect(created_at.getTime()).toBe(oldRow.created_at.getTime()); - getValidateRequest(resetPasswordToken, newUser.user_id, async (err, res) => { - expect(res.status).toBe(200); - expect(res.body.isValid).toBe(true); - done(); - }); - }); + expect(res.body.isValid).toBe(true); + } }); - test('Should send a valid token through email when reset_token_version === 2', async (done) => { + test('Should send a valid token through email when reset_token_version === 2', async () => { const oldRow = await insertPasswordRow({ reset_token_version: 2, user_id: newUser.user_id }); - postResetPasswordRequest(newUser.email, async (err, res) => { - console.log(resetPasswordToken); - const user = jsonwebtoken.verify(resetPasswordToken, process.env.JWT_RESET_SECRET); - expect(user.reset_token_version).toBe(2); - const { reset_token_version, created_at } = await knex('password') - .where({ user_id: newUser.user_id }) - .first(); - expect(reset_token_version).toBe(3); - expect(created_at.getTime()).toBe(oldRow.created_at.getTime()); - getValidateRequest(resetPasswordToken, newUser.user_id, async (err, res) => { - expect(res.status).toBe(200); - expect(res.body.isValid).toBe(true); - done(); - }); - }); + const res = await postResetPasswordRequest(newUser.email); + console.log(resetPasswordToken); + const user = jsonwebtoken.verify(resetPasswordToken, process.env.JWT_RESET_SECRET); + expect(user.reset_token_version).toBe(2); + const { reset_token_version, created_at } = await knex('password') + .where({ user_id: newUser.user_id }) + .first(); + expect(reset_token_version).toBe(3); + expect(created_at.getTime()).toBe(oldRow.created_at.getTime()); + + { + const res = await getValidateRequest(resetPasswordToken, newUser.user_id); + expect(res.status).toBe(200); + expect(res.body.isValid).toBe(true); + } }); - test('Should reject when reset_token_version === 3', async (done) => { + test('Should reject when reset_token_version === 3', async () => { const oldRow = await insertPasswordRow({ reset_token_version: 3, user_id: newUser.user_id }); const tokenPayload = { user_id: newUser.user_id, @@ -269,23 +259,23 @@ describe('JWT Tests', () => { }; const localResetPasswordToken = await createToken('passwordReset', tokenPayload); resetPasswordToken = undefined; - postResetPasswordRequest(newUser.email, async (err, res) => { - expect(res.status).toBe(400); - expect(resetPasswordToken).toBe(undefined); - const { reset_token_version, created_at } = await knex('password') - .where({ user_id: newUser.user_id }) - .first(); - expect(reset_token_version).toBe(oldRow.reset_token_version); - expect(created_at.getTime()).toBe(oldRow.created_at.getTime()); - getValidateRequest(localResetPasswordToken, newUser.user_id, async (err, res) => { - expect(res.status).toBe(200); - expect(res.body.isValid).toBe(true); - done(); - }); - }); + const res = await postResetPasswordRequest(newUser.email); + expect(res.status).toBe(400); + expect(resetPasswordToken).toBe(undefined); + const { reset_token_version, created_at } = await knex('password') + .where({ user_id: newUser.user_id }) + .first(); + expect(reset_token_version).toBe(oldRow.reset_token_version); + expect(created_at.getTime()).toBe(oldRow.created_at.getTime()); + + { + const res = await getValidateRequest(localResetPasswordToken, newUser.user_id); + expect(res.status).toBe(200); + expect(res.body.isValid).toBe(true); + } }); - test('Should reset reset_token_version and created_at when created_at is one day before current date', async (done) => { + test('Should reset reset_token_version and created_at when created_at is one day before current date', async () => { const oneDay = 1000 * 3600 * 24; const oldDate = new Date(new Date().getTime() - oneDay - 1); const oldRow = await insertPasswordRow({ @@ -293,86 +283,76 @@ describe('JWT Tests', () => { user_id: newUser.user_id, created_at: oldDate, }); - postResetPasswordRequest(newUser.email, async (err, res) => { + const res = await postResetPasswordRequest(newUser.email); + expect(res.status).toBe(200); + const user = jsonwebtoken.verify(resetPasswordToken, process.env.JWT_RESET_SECRET); + expect(user.reset_token_version).toBe(0); + const { reset_token_version, created_at } = await knex('password') + .where({ user_id: newUser.user_id }) + .first(); + expect(reset_token_version).toBe(1); + expect(created_at.getTime()).toBeGreaterThan(oldRow.created_at.getTime()); + + { + const res = await getValidateRequest(resetPasswordToken, newUser.user_id); expect(res.status).toBe(200); - const user = jsonwebtoken.verify(resetPasswordToken, process.env.JWT_RESET_SECRET); - expect(user.reset_token_version).toBe(0); - const { reset_token_version, created_at } = await knex('password') - .where({ user_id: newUser.user_id }) - .first(); - expect(reset_token_version).toBe(1); - expect(created_at.getTime()).toBeGreaterThan(oldRow.created_at.getTime()); - getValidateRequest(resetPasswordToken, newUser.user_id, async (err, res) => { - expect(res.status).toBe(200); - expect(res.body.isValid).toBe(true); - done(); - }); - }); + expect(res.body.isValid).toBe(true); + } }); - test('Should reset reset_token_version and created_at when reset token is used', async (done) => { + test('Should reset reset_token_version and created_at when reset token is used', async () => { const newPassword = 'newPassword'; const oldRow = await insertPasswordRow({ reset_token_version: 2, user_id: newUser.user_id }); - postResetPasswordRequest(newUser.email, async (err, res) => { - const verified = jsonwebtoken.verify(resetPasswordToken, process.env.JWT_RESET_SECRET); - expect(verified.user_id).toBe(newUser.user_id); - putPasswordRequest( - resetPasswordToken, - { + const res = await postResetPasswordRequest(newUser.email); + const verified = jsonwebtoken.verify(resetPasswordToken, process.env.JWT_RESET_SECRET); + expect(verified.user_id).toBe(newUser.user_id); + + { + const res = await putPasswordRequest(resetPasswordToken, { + password: newPassword, + user_id: newUser.user_id, + }); + + expect(res.status).toBe(200); + const { reset_token_version, created_at, password_hash } = await knex('password') + .where({ user_id: newUser.user_id }) + .first(); + const isMatch = await bcrypt.compare(newPassword, password_hash); + expect(isMatch).toBeTruthy(); + expect(reset_token_version).toBe(0); + expect(created_at.getTime()).toBeGreaterThan(oldRow.created_at.getTime()); + + { + const res = await putPasswordRequest(resetPasswordToken, { password: newPassword, user_id: newUser.user_id, - }, - async (err, res) => { - expect(res.status).toBe(200); - const { reset_token_version, created_at, password_hash } = await knex('password') - .where({ user_id: newUser.user_id }) - .first(); - const isMatch = await bcrypt.compare(newPassword, password_hash); - expect(isMatch).toBeTruthy(); - expect(reset_token_version).toBe(0); - expect(created_at.getTime()).toBeGreaterThan(oldRow.created_at.getTime()); - putPasswordRequest( - resetPasswordToken, - { - password: newPassword, - user_id: newUser.user_id, - }, - async (err, res) => { - expect(res.status).toBe(401); - done(); - }, - ); - }, - ); - }); + }); + + expect(res.status).toBe(401); + } + } }); - test('Should reject when an invited user tries to get reset password token', async (done) => { + test('Should reject when an invited user tries to get reset password token', async () => { const [invitedUser] = await mocks.usersFactory({ ...mocks.fakeUser(), status_id: 2 }); - postResetPasswordRequest(invitedUser.email, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postResetPasswordRequest(invitedUser.email); + expect(res.status).toBe(400); }); - test('Should reject when a pseudo user tries to get reset password token', async (done) => { + test('Should reject when a pseudo user tries to get reset password token', async () => { const [pseudoUser] = await mocks.usersFactory({ ...mocks.fakeUser(), status_id: 1, email: `${faker.datatype.uuid()}@pseudo.com`, }); - postResetPasswordRequest(pseudoUser.email, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postResetPasswordRequest(pseudoUser.email); + expect(res.status).toBe(400); }); - test('Should reject when an auth0 legacy user tries to get reset password token', async (done) => { + test('Should reject when an auth0 legacy user tries to get reset password token', async () => { const [invitedUser] = await mocks.usersFactory({ ...mocks.fakeUser(), status_id: 3 }); - postResetPasswordRequest(newUser.email, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postResetPasswordRequest(newUser.email); + expect(res.status).toBe(400); }); }); @@ -381,26 +361,25 @@ describe('JWT Tests', () => { let reqBody; let googleUser; - function postAcceptInvitationWithPasswordRequest(invitationToken, callback) { - chai + function postAcceptInvitationWithPasswordRequest(invitationToken) { + return chai .request(server) .post(`/user/accept_invitation`) .set('Authorization', `Bearer ${invitationToken}`) - .send(reqBody) - .end(callback); + .send(reqBody); } - function putAcceptInvitationWithGoogleAccountRequest(invitationToken, callback) { + function putAcceptInvitationWithGoogleAccountRequest(invitationToken) { delete reqBody.password; - chai + + return chai .request(server) .put(`/user/accept_invitation`) - .send({ ...reqBody, invite_token: invitationToken }) - .end(callback); + .send({ ...reqBody, invite_token: invitationToken }); } - function getRequest({ email = user.email }, callback) { - chai.request(server).get(`/login/user/${email}`).set('email', email).end(callback); + function getRequest({ email = user.email }) { + return chai.request(server).get(`/login/user/${email}`).set('email', email); } function fakeGoogleTokenContent() { @@ -425,7 +404,7 @@ describe('JWT Tests', () => { }; } - beforeEach(async (done) => { + beforeEach(async () => { const { createToken } = require('../src/util/jwt'); createToken.mockImplementation(async (type, user) => { const localInvitationToken = sign(user, tokenType[type], { @@ -447,16 +426,14 @@ describe('JWT Tests', () => { // emailMiddleware.sendEmail.mockClear(); invitationToken = undefined; reqBody = fakeReqBody(); - done(); }); - test('Validate a valid token', async (done) => { + test('Validate a valid token', async () => { const resetPasswordToken = await createToken('invite', newUser); const user = jsonwebtoken.verify(resetPasswordToken, tokenType.invite); expect(user.user_id).toEqual(newUser.user_id); - done(); }); - test('Should create password and spotlight when user status is invited', async (done) => { + test('Should create password and spotlight when user status is invited', async () => { const [user] = await mocks.usersFactory({ ...mocks.fakeUser(), status_id: 2 }); const [userFarm] = await mocks.userFarmFactory( { promisedUser: [user] }, @@ -466,28 +443,30 @@ describe('JWT Tests', () => { }, ); const { user_id, farm_id } = userFarm; - getRequest(user, async (err, res) => { - const verified = jsonwebtoken.verify(invitationToken, tokenType.invite); - expect(verified.user_id).toBe(user.user_id); - postAcceptInvitationWithPasswordRequest(invitationToken, async (err, res) => { - const [resUser] = await userModel.query().where({ user_id: user.user_id }); - validate({ ...user, ...reqBody, status_id: 1 }, res, 201, resUser); - const { password_hash } = await knex('password').where({ user_id: user.user_id }).first(); - const isMatch = await bcrypt.compare(reqBody.password, password_hash); - expect(isMatch).toBeTruthy(); - const [resUserFarm] = await knex('userFarm').where({ user_id, farm_id }); - expect(resUserFarm.status).toBe('Active'); - const showedSpotlight = await showedSpotlightModel.query().findById(user_id); - expect(showedSpotlight.user_id).toBe(user_id); - postAcceptInvitationWithPasswordRequest(invitationToken, async (err, res) => { - expect(res.status).toBe(401); - done(); - }); - }); - }); + const res = await getRequest(user); + const verified = jsonwebtoken.verify(invitationToken, tokenType.invite); + expect(verified.user_id).toBe(user.user_id); + + { + const res = await postAcceptInvitationWithPasswordRequest(invitationToken); + const [resUser] = await userModel.query().where({ user_id: user.user_id }); + validate({ ...user, ...reqBody, status_id: 1 }, res, 201, resUser); + const { password_hash } = await knex('password').where({ user_id: user.user_id }).first(); + const isMatch = await bcrypt.compare(reqBody.password, password_hash); + expect(isMatch).toBeTruthy(); + const [resUserFarm] = await knex('userFarm').where({ user_id, farm_id }); + expect(resUserFarm.status).toBe('Active'); + const showedSpotlight = await showedSpotlightModel.query().findById(user_id); + expect(showedSpotlight.user_id).toBe(user_id); + + { + const res = await postAcceptInvitationWithPasswordRequest(invitationToken); + expect(res.status).toBe(401); + } + } }); - test('User should accept invitation when birth year is undefined', async (done) => { + test('User should accept invitation when birth year is undefined', async () => { const [user] = await mocks.usersFactory({ ...mocks.fakeUser(), status_id: 2 }); const [userFarm] = await mocks.userFarmFactory( { promisedUser: [user] }, @@ -496,17 +475,17 @@ describe('JWT Tests', () => { status: 'Invited', }, ); - getRequest(user, async (err, res) => { - delete reqBody.birth_year; - postAcceptInvitationWithPasswordRequest(invitationToken, async (err, res) => { - const [resUser] = await userModel.query().where({ user_id: user.user_id }); - validate({ ...user, ...reqBody, status_id: 1 }, res, 201, resUser); - done(); - }); - }); + const res = await getRequest(user); + delete reqBody.birth_year; + + { + const res = await postAcceptInvitationWithPasswordRequest(invitationToken); + const [resUser] = await userModel.query().where({ user_id: user.user_id }); + validate({ ...user, ...reqBody, status_id: 1 }, res, 201, resUser); + } }); - test('Should return 401 when userFarm status Inactive', async (done) => { + test('Should return 401 when userFarm status Inactive', async () => { const [user] = await mocks.usersFactory({ ...mocks.fakeUser(), status_id: 2 }); const [userFarm] = await mocks.userFarmFactory( { promisedUser: [user] }, @@ -515,18 +494,18 @@ describe('JWT Tests', () => { status: 'Invited', }, ); - getRequest(user, async (err, res) => { - const { farm_id, user_id } = userFarm; - delete reqBody.birth_year; - await userFarmModel.query().findById([user_id, farm_id]).patch({ status: 'Inactive' }); - postAcceptInvitationWithPasswordRequest(invitationToken, async (err, res) => { - expect(res.status).toBe(401); - done(); - }); - }); + const res = await getRequest(user); + const { farm_id, user_id } = userFarm; + delete reqBody.birth_year; + await userFarmModel.query().findById([user_id, farm_id]).patch({ status: 'Inactive' }); + + { + const res = await postAcceptInvitationWithPasswordRequest(invitationToken); + expect(res.status).toBe(401); + } }); - test('Should return 401 when userFarm status Active', async (done) => { + test('Should return 401 when userFarm status Active', async () => { const [user] = await mocks.usersFactory({ ...mocks.fakeUser(), status_id: 2 }); const [userFarm] = await mocks.userFarmFactory( { promisedUser: [user] }, @@ -535,18 +514,18 @@ describe('JWT Tests', () => { status: 'Invited', }, ); - getRequest(user, async (err, res) => { - const { farm_id, user_id } = userFarm; - delete reqBody.birth_year; - await userFarmModel.query().findById([user_id, farm_id]).patch({ status: 'Active' }); - postAcceptInvitationWithPasswordRequest(invitationToken, async (err, res) => { - expect(res.status).toBe(401); - done(); - }); - }); + const res = await getRequest(user); + const { farm_id, user_id } = userFarm; + delete reqBody.birth_year; + await userFarmModel.query().findById([user_id, farm_id]).patch({ status: 'Active' }); + + { + const res = await postAcceptInvitationWithPasswordRequest(invitationToken); + expect(res.status).toBe(401); + } }); - test('Should modify user_id and insert spotlight when login with google and user status is invited', async (done) => { + test('Should modify user_id and insert spotlight when login with google and user status is invited', async () => { const [user] = await mocks.usersFactory({ ...mocks.fakeUser(), status_id: 2, @@ -567,51 +546,51 @@ describe('JWT Tests', () => { }, ); const { user_id, farm_id } = userFarm; - getRequest(user, async (err, res) => { - const verified = await jsonwebtoken.verify(invitationToken, tokenType.invite); - expect(verified.user_id).toBe(user.user_id); - const getUserFarmStatus = (farm_id) => - verified.farm_id === farm_id ? 'Active' : 'Invited'; - putAcceptInvitationWithGoogleAccountRequest(invitationToken, async (err, res) => { - const oldUserRows = await userModel.query().where({ user_id: user.user_id }); - expect(oldUserRows.length).toBe(0); - const [resUser] = await userModel.query().where({ user_id: googleUser.sub }); - validate( - { - ...user, - ...reqBody, - email: googleUser.email, - user_id: googleUser.user_id, - status_id: 1, - }, - res, - 200, - resUser, - ); - const oldUserFarms = await knex('userFarm').where({ user_id }); - expect(oldUserFarms.length).toBe(0); - const [resUserFarm] = await knex('userFarm').where({ user_id: googleUser.sub, farm_id }); - expect(resUserFarm.status).toBe(getUserFarmStatus(farm_id)); - const [resUserFarm1] = await knex('userFarm').where({ - user_id: googleUser.sub, - farm_id: userFarm1.farm_id, - }); - expect(resUserFarm1.status).toBe(getUserFarmStatus(userFarm1.farm_id)); - const emailTokens = await knex('emailToken').where({ user_id: googleUser.sub }); - expect(emailTokens.length).toBe(2); - const oldEmailTokens = await knex('emailToken').where({ user_id }); - expect(oldEmailTokens.length).toBe(0); - expect(resUserFarm1.status).toBe(getUserFarmStatus(userFarm1.farm_id)); - - putAcceptInvitationWithGoogleAccountRequest(invitationToken, async (err, res) => { - expect(res.status).toBe(401); - done(); - }); + const res = await getRequest(user); + const verified = await jsonwebtoken.verify(invitationToken, tokenType.invite); + expect(verified.user_id).toBe(user.user_id); + const getUserFarmStatus = (farm_id) => (verified.farm_id === farm_id ? 'Active' : 'Invited'); + + { + const res = await putAcceptInvitationWithGoogleAccountRequest(invitationToken); + const oldUserRows = await userModel.query().where({ user_id: user.user_id }); + expect(oldUserRows.length).toBe(0); + const [resUser] = await userModel.query().where({ user_id: googleUser.sub }); + validate( + { + ...user, + ...reqBody, + email: googleUser.email, + user_id: googleUser.user_id, + status_id: 1, + }, + res, + 200, + resUser, + ); + const oldUserFarms = await knex('userFarm').where({ user_id }); + expect(oldUserFarms.length).toBe(0); + const [resUserFarm] = await knex('userFarm').where({ user_id: googleUser.sub, farm_id }); + expect(resUserFarm.status).toBe(getUserFarmStatus(farm_id)); + const [resUserFarm1] = await knex('userFarm').where({ + user_id: googleUser.sub, + farm_id: userFarm1.farm_id, }); - }); + expect(resUserFarm1.status).toBe(getUserFarmStatus(userFarm1.farm_id)); + const emailTokens = await knex('emailToken').where({ user_id: googleUser.sub }); + expect(emailTokens.length).toBe(2); + const oldEmailTokens = await knex('emailToken').where({ user_id }); + expect(oldEmailTokens.length).toBe(0); + expect(resUserFarm1.status).toBe(getUserFarmStatus(userFarm1.farm_id)); + + { + const res = await putAcceptInvitationWithGoogleAccountRequest(invitationToken); + expect(res.status).toBe(401); + } + } }); - test('Should modify user_id when pseudo user accept invitation with google account', async (done) => { + test('Should modify user_id when pseudo user accept invitation with google account', async () => { const [user] = await mocks.usersFactory({ ...mocks.fakeUser(), status_id: 2, @@ -632,12 +611,16 @@ describe('JWT Tests', () => { }, ); const { user_id, farm_id } = userFarm1; - getRequest(user, async (err, res) => { + + { + const res = await getRequest(user); const verified = await jsonwebtoken.verify(invitationToken, tokenType.invite); expect(verified.user_id).toBe(user.user_id); const userFarm1 = await userFarmModel.query().where({ user_id, farm_id }).first(); expect(userFarm1.status).toBe('Invited'); - putAcceptInvitationWithGoogleAccountRequest(invitationToken, async (err, res) => { + + { + const res = await putAcceptInvitationWithGoogleAccountRequest(invitationToken); const oldUserRows = await userModel.query().where({ user_id: user.user_id }); expect(oldUserRows.length).toBe(0); const [resUser] = await userModel.query().where({ user_id: googleUser.sub }); @@ -653,12 +636,13 @@ describe('JWT Tests', () => { 200, resUser, ); - putAcceptInvitationWithGoogleAccountRequest(invitationToken, async (err, res) => { + + { + const res = await putAcceptInvitationWithGoogleAccountRequest(invitationToken); expect(res.status).toBe(401); - done(); - }); - }); - }); + } + } + } }); }); }); diff --git a/packages/api/tests/location.test.js b/packages/api/tests/location.test.js index 21d2a70e38..c346b484eb 100644 --- a/packages/api/tests/location.test.js +++ b/packages/api/tests/location.test.js @@ -83,50 +83,45 @@ const assetSpecificMock = { }; describe('Location tests', () => { - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); - function putLocation(data, { user_id, farm_id }, asset, location, callback) { - chai + function putLocation(data, { user_id, farm_id }, asset, location) { + return chai .request(server) .put(`/location/${asset}/${location}`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function postLocation(data, asset, { user_id, farm_id }, callback) { - chai + function postLocation(data, asset, { user_id, farm_id }) { + return chai .request(server) .post(`/location/${asset}`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function getLocationsInFarm({ user_id, farm_id }, farm, callback) { - chai + function getLocationsInFarm({ user_id, farm_id }, farm) { + return chai .request(server) .get(`/location/farm/${farm}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - function deleteLocation({ user_id, farm_id }, location, callback) { - chai + function deleteLocation({ user_id, farm_id }, location) { + return chai .request(server) .delete(`/location/${location}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } function appendFieldToFarm(farm_id, n = 1) { @@ -160,58 +155,53 @@ describe('Location tests', () => { user = user_id; }); - test('should GET 2 fields linked to that farm', async (done) => { + test('should GET 2 fields linked to that farm', async () => { const result = await appendFieldToFarm(farm, 2); console.log(result); - getLocationsInFarm({ user_id: user, farm_id: farm }, farm, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.length).toBe(2); - res.body.map((field) => { - expect(field.figure.type).toBe('field'); - expect(field.figure.area).not.toBe(null); - }); - done(); + const res = await getLocationsInFarm({ user_id: user, farm_id: farm }, farm); + expect(res.status).toBe(200); + expect(res.body.length).toBe(2); + res.body.map((field) => { + expect(field.figure.type).toBe('field'); + expect(field.figure.area).not.toBe(null); }); }); - test('should only get locations linked to that farm', async (done) => { + test('should only get locations linked to that farm', async () => { const [anotherUserFarm] = await mocks.userFarmFactory({ promisedUser: [{ user_id: user }] }); await appendFieldToFarm(farm, 2); await appendFieldToFarm(anotherUserFarm.farm_id, 3); - getLocationsInFarm({ user_id: user, farm_id: farm }, farm, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.length).toBe(2); - done(); - }); + const res = await getLocationsInFarm({ user_id: user, farm_id: farm }, farm); + expect(res.status).toBe(200); + expect(res.body.length).toBe(2); }); - test('should not get locations from farms Im not part of', async (done) => { + test('should not get locations from farms Im not part of', async () => { const [anotherUserFarm] = await mocks.userFarmFactory(); await appendFieldToFarm(farm, 2); await appendFieldToFarm(anotherUserFarm.farm_id, 3); - getLocationsInFarm({ user_id: user, farm_id: farm }, anotherUserFarm.farm_id, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await getLocationsInFarm( + { user_id: user, farm_id: farm }, + anotherUserFarm.farm_id, + ); + expect(res.status).toBe(403); }); - test('should get 2 fields and 1 fence linked to that farm', async (done) => { + test('should get 2 fields and 1 fence linked to that farm', async () => { await appendFieldToFarm(farm, 2); await appendFenceToFarm(farm, 1); - getLocationsInFarm({ user_id: user, farm_id: farm }, farm, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.length).toBe(3); - const typeSum = res.body.reduce( - (types, { figure }) => ({ - [figure.type]: types[figure.type] ? types[figure.type]++ : 1, - ...types, - }), - {}, - ); - expect(typeSum.field).toBe(2); - expect(typeSum.fence).toBe(1); - done(); - }); + const res = await getLocationsInFarm({ user_id: user, farm_id: farm }, farm); + expect(res.status).toBe(200); + expect(res.body.length).toBe(3); + const typeSum = res.body.reduce( + (types, { figure }) => ({ + [figure.type]: types[figure.type] ? types[figure.type]++ : 1, + ...types, + }), + {}, + ); + expect(typeSum.field).toBe(2); + expect(typeSum.fence).toBe(1); }); }); @@ -281,23 +271,21 @@ describe('Location tests', () => { ); }; - test('should delete field', async (done) => { + test('should delete field', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 1 }, ); const [[field1], [field2]] = await appendFieldToFarm(farm_id, 2); - deleteLocation({ user_id, farm_id }, field1.location_id, async (err, res) => { - expect(res.status).toBe(200); - const location = await knex('location').where({ location_id: field1.location_id }).first(); - const location2 = await knex('location').where({ location_id: field2.location_id }).first(); - expect(location.deleted).toBeTruthy(); - expect(location2.deleted).toBeFalsy(); - done(); - }); + const res = await deleteLocation({ user_id, farm_id }, field1.location_id); + expect(res.status).toBe(200); + const location = await knex('location').where({ location_id: field1.location_id }).first(); + const location2 = await knex('location').where({ location_id: field2.location_id }).first(); + expect(location.deleted).toBeTruthy(); + expect(location2.deleted).toBeFalsy(); }); - test('Delete should return 400 when field is referenced by managementPlan (incomplete plant task)', async (done) => { + test('Delete should return 400 when field is referenced by managementPlan (incomplete plant task)', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 1 }, @@ -313,13 +301,11 @@ describe('Location tests', () => { }); await createPlantTask(user_id, planting_management_plan_id); - deleteLocation({ user_id, farm_id }, field1.location_id, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await deleteLocation({ user_id, farm_id }, field1.location_id); + expect(res.status).toBe(400); }); - test('Delete should return 400 when field is referenced by managementPlan (wild crop location)', async (done) => { + test('Delete should return 400 when field is referenced by managementPlan (wild crop location)', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 1 }, @@ -334,13 +320,11 @@ describe('Location tests', () => { promisedField: [field1], }); - deleteLocation({ user_id, farm_id }, field1.location_id, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await deleteLocation({ user_id, farm_id }, field1.location_id); + expect(res.status).toBe(400); }); - test('Delete should return 400 when field is referenced by managementPlan (completed transplant task)', async (done) => { + test('Delete should return 400 when field is referenced by managementPlan (completed transplant task)', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 1 }, @@ -364,13 +348,11 @@ describe('Location tests', () => { complete_date: '2022-02-24', }); - deleteLocation({ user_id, farm_id }, field1.location_id, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await deleteLocation({ user_id, farm_id }, field1.location_id); + expect(res.status).toBe(400); }); - test('should delete field when crop is transplanted to different field', async (done) => { + test('should delete field when crop is transplanted to different field', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 1 }, @@ -393,13 +375,11 @@ describe('Location tests', () => { complete_date: '2022-02-24', }); - deleteLocation({ user_id, farm_id }, field1.location_id, async (err, res) => { - expect(res.status).toBe(200); - done(); - }); + const res = await deleteLocation({ user_id, farm_id }, field1.location_id); + expect(res.status).toBe(200); }); - test('should delete field when all tasks are completed or abandoned and crop is transplanted to different field', async (done) => { + test('should delete field when all tasks are completed or abandoned and crop is transplanted to different field', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 1 }, @@ -427,13 +407,11 @@ describe('Location tests', () => { }); await createLocationTask(user_id, field1.location_id, { complete_date: '2022-02-22' }); - deleteLocation({ user_id, farm_id }, field1.location_id, async (err, res) => { - expect(res.status).toBe(200); - done(); - }); + const res = await deleteLocation({ user_id, farm_id }, field1.location_id); + expect(res.status).toBe(200); }); - test('should return 400 when field is referenced by incomplete plant task', async (done) => { + test('should return 400 when field is referenced by incomplete plant task', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 1 }, @@ -449,13 +427,11 @@ describe('Location tests', () => { }); await createPlantTask(user_id, planting_management_plan_id); - deleteLocation({ user_id, farm_id }, field1.location_id, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await deleteLocation({ user_id, farm_id }, field1.location_id); + expect(res.status).toBe(400); }); - test('should return 400 when field is referenced by incomplete transplant task', async (done) => { + test('should return 400 when field is referenced by incomplete transplant task', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 1 }, @@ -472,13 +448,11 @@ describe('Location tests', () => { await createPlantTask(user_id, planting_management_plan_id); await createTransplantTask(user_id, farm_id, field1.location_id, management_plan_id); - deleteLocation({ user_id, farm_id }, field1.location_id, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await deleteLocation({ user_id, farm_id }, field1.location_id); + expect(res.status).toBe(400); }); - test('should return 400 when field is referenced by incomplete location task', async (done) => { + test('should return 400 when field is referenced by incomplete location task', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 1 }, @@ -496,13 +470,11 @@ describe('Location tests', () => { await createLocationTask(user_id, field1.location_id); - deleteLocation({ user_id, farm_id }, field1.location_id, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await deleteLocation({ user_id, farm_id }, field1.location_id); + expect(res.status).toBe(400); }); - test('should return 400 when field is referenced by incomplete management task', async (done) => { + test('should return 400 when field is referenced by incomplete management task', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 1 }, @@ -523,10 +495,8 @@ describe('Location tests', () => { await createManagementTask(user_id, planting_management_plan_id); - deleteLocation({ user_id, farm_id }, field1.location_id, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await deleteLocation({ user_id, farm_id }, field1.location_id); + expect(res.status).toBe(400); }); }); @@ -562,211 +532,186 @@ describe('Location tests', () => { describe('Authorization', () => { Object.keys(figureMapping).map((asset) => { - test(`should allow owner to create a ${asset}`, async (done) => { + test(`should allow owner to create a ${asset}`, async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 1 }, ); const data = locationData(asset); - postLocation({ ...data, farm_id }, asset, { user_id, farm_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.name).toBe(data.name); - expect(res.body.figure.type).toBe(asset); - expect(res.body[asset]).toBeDefined(); - done(); - }); + const res = await postLocation({ ...data, farm_id }, asset, { user_id, farm_id }); + expect(res.status).toBe(200); + expect(res.body.name).toBe(data.name); + expect(res.body.figure.type).toBe(asset); + expect(res.body[asset]).toBeDefined(); }); - test(`should allow manager to create a ${asset}`, async (done) => { + test(`should allow manager to create a ${asset}`, async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 2 }, ); const data = locationData(asset); - postLocation({ ...data, farm_id }, asset, { user_id, farm_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.name).toBe(data.name); - expect(res.body.figure.type).toBe(asset); - expect(res.body[asset]).toBeDefined(); - done(); - }); + const res = await postLocation({ ...data, farm_id }, asset, { user_id, farm_id }); + expect(res.status).toBe(200); + expect(res.body.name).toBe(data.name); + expect(res.body.figure.type).toBe(asset); + expect(res.body[asset]).toBeDefined(); }); - test(`should allow EO to create a ${asset}`, async (done) => { + test(`should allow EO to create a ${asset}`, async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 5 }, ); const data = locationData(asset); - postLocation({ ...data, farm_id }, asset, { user_id, farm_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.name).toBe(data.name); - expect(res.body.figure.type).toBe(asset); - expect(res.body[asset]).toBeDefined(); - done(); - }); + const res = await postLocation({ ...data, farm_id }, asset, { user_id, farm_id }); + expect(res.status).toBe(200); + expect(res.body.name).toBe(data.name); + expect(res.body.figure.type).toBe(asset); + expect(res.body[asset]).toBeDefined(); }); - test(`should NOT allow worker to create a ${asset}`, async (done) => { + test(`should NOT allow worker to create a ${asset}`, async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory( {}, { status: 'Active', role_id: 3 }, ); const data = locationData(asset); - postLocation({ ...data, farm_id }, asset, { user_id, farm_id }, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await postLocation({ ...data, farm_id }, asset, { user_id, farm_id }); + expect(res.status).toBe(403); }); }); }); - test('should create a location', (done) => { + test('should create a location', async () => { const data = locationData(locations.BARN); - postLocation( - { ...data, farm_id: farm }, - locations.BARN, - { user_id: user, farm_id: farm }, - (err, res) => { - expect(res.status).toBe(200); - done(); - }, - ); + + const res = await postLocation({ ...data, farm_id: farm }, locations.BARN, { + user_id: user, + farm_id: farm, + }); + + expect(res.status).toBe(200); }); - test('should fail to create a barn if I send data for a field as well', (done) => { + test('should fail to create a barn if I send data for a field as well', async () => { const validData = locationData(locations.BARN); const data = { ...validData, field: mocks.fakeField() }; - postLocation( - { ...data, farm_id: farm }, - locations.BARN, - { user_id: user, farm_id: farm }, - (err, res) => { - expect(res.status).toBe(400); - done(); - }, - ); + + const res = await postLocation({ ...data, farm_id: farm }, locations.BARN, { + user_id: user, + farm_id: farm, + }); + + expect(res.status).toBe(400); }); - test('should fail to create a barn if I send a point instead of area', (done) => { + test('should fail to create a barn if I send a point instead of area', async () => { const validData = locationData(locations.BARN); const pointFigure = locationData(locations.GATE); const data = { ...validData, figure: pointFigure.figure }; - postLocation( - { ...data, farm_id: farm }, - locations.BARN, - { user_id: user, farm_id: farm }, - (err, res) => { - expect(res.status).toBe(400); - done(); - }, - ); + + const res = await postLocation({ ...data, farm_id: farm }, locations.BARN, { + user_id: user, + farm_id: farm, + }); + + expect(res.status).toBe(400); }); - test('should fail to create a barn without area', (done) => { + test('should fail to create a barn without area', async () => { const validData = locationData(locations.BARN); delete validData.figure.area; - postLocation( - { ...validData, farm_id: farm }, - locations.BARN, - { user_id: user, farm_id: farm }, - (err, res) => { - expect(res.status).toBe(400); - done(); - }, - ); + + const res = await postLocation({ ...validData, farm_id: farm }, locations.BARN, { + user_id: user, + farm_id: farm, + }); + + expect(res.status).toBe(400); }); - test('should fail to create a field without a name', (done) => { + test('should fail to create a field without a name', async () => { const validData = locationData(locations.FIELD); validData.name = ''; - postLocation( - { ...validData, farm_id: farm }, - locations.FIELD, - { user_id: user, farm_id: farm }, - (err, res) => { - expect(res.status).toBe(400); - done(); - }, - ); + + const res = await postLocation({ ...validData, farm_id: farm }, locations.FIELD, { + user_id: user, + farm_id: farm, + }); + + expect(res.status).toBe(400); }); - test('should fail to create a field without grid_points', (done) => { + test('should fail to create a field without grid_points', async () => { const validData = locationData(locations.FIELD); validData.figure.area.grid_points = [{}]; - postLocation( - { ...validData, farm_id: farm }, - locations.FIELD, - { user_id: user, farm_id: farm }, - (err, res) => { - expect(res.status).toBe(400); - done(); - }, - ); + + const res = await postLocation({ ...validData, farm_id: farm }, locations.FIELD, { + user_id: user, + farm_id: farm, + }); + + expect(res.status).toBe(400); }); - test('should fail to create a field with only 2 grid_points', (done) => { + test('should fail to create a field with only 2 grid_points', async () => { const validData = locationData(locations.FIELD); validData.figure.area.grid_points.pop(); - postLocation( - { ...validData, farm_id: farm }, - locations.FIELD, - { user_id: user, farm_id: farm }, - (err, res) => { - expect(res.status).toBe(400); - done(); - }, - ); + + const res = await postLocation({ ...validData, farm_id: farm }, locations.FIELD, { + user_id: user, + farm_id: farm, + }); + + expect(res.status).toBe(400); }); - test('should fail to create a location without asset', (done) => { + test('should fail to create a location without asset', async () => { const validData = locationData(locations.BARN); delete validData.barn; - postLocation( - { ...validData, farm_id: farm }, - locations.BARN, - { user_id: user, farm_id: farm }, - (err, res) => { - expect(res.status).toBe(400); - done(); - }, - ); + + const res = await postLocation({ ...validData, farm_id: farm }, locations.BARN, { + user_id: user, + farm_id: farm, + }); + + expect(res.status).toBe(400); }); - test('should fail to create a location without figure or asset', (done) => { + test('should fail to create a location without figure or asset', async () => { const validData = locationData(locations.BARN); delete validData.barn; delete validData.figure; - postLocation( - { ...validData, farm_id: farm }, - locations.BARN, - { user_id: user, farm_id: farm }, - (err, res) => { - expect(res.status).toBe(500); - done(); - }, - ); + + const res = await postLocation({ ...validData, farm_id: farm }, locations.BARN, { + user_id: user, + farm_id: farm, + }); + + expect(res.status).toBe(500); }); - test('should fail to add a user through the location graph', (done) => { + test('should fail to add a user through the location graph', async () => { const validData = locationData(locations.BARN); const data = { ...validData, createdByUser: { first_name: 'Hacker', last_name: '1', email: 'maso@alas.com' }, }; - postLocation( - { ...data, farm_id: farm }, - locations.BARN, - { user_id: user, farm_id: farm }, - async (err, res) => { - const user = await knex('users').where({ email: data.createdByUser.email }).first(); - expect(user).toBeUndefined(); - done(); - }, - ); + + { + const res = await postLocation({ ...data, farm_id: farm }, locations.BARN, { + user_id: user, + farm_id: farm, + }); + + expect( + await knex('users').where({ email: data.createdByUser.email }).first(), + ).toBeUndefined(); + } }); - test('should fail to modify a user through the location graph', (done) => { + test('should fail to modify a user through the location graph', async () => { const validData = locationData(locations.BARN); const data = { ...validData, @@ -777,32 +722,26 @@ describe('Location tests', () => { email: 'maso@alas.com', }, }; - postLocation( - { ...data, farm_id: farm }, - locations.BARN, - { user_id: user, farm_id: farm }, - async (err, res) => { - expect(res.status).toBe(400); - done(); - }, - ); + + const res = await postLocation({ ...data, farm_id: farm }, locations.BARN, { + user_id: user, + farm_id: farm, + }); + + expect(res.status).toBe(400); }); Object.keys(figureMapping).map((asset) => { - test(`should create a ${asset}`, (done) => { + test(`should create a ${asset}`, async () => { const data = locationData(asset); - postLocation( - { ...data, farm_id: farm }, - asset, - { user_id: user, farm_id: farm }, - (err, res) => { - expect(res.status).toBe(200); - expect(res.body.name).toBe(data.name); - expect(res.body.figure.type).toBe(asset); - expect(res.body[asset]).toBeDefined(); - done(); - }, - ); + const res = await postLocation({ ...data, farm_id: farm }, asset, { + user_id: user, + farm_id: farm, + }); + expect(res.status).toBe(200); + expect(res.body.name).toBe(data.name); + expect(res.body.figure.type).toBe(asset); + expect(res.body[asset]).toBeDefined(); }); }); }); @@ -822,7 +761,7 @@ describe('Location tests', () => { Object.keys(figureMapping) .filter((a) => !['field', 'garden'].includes(a)) .map((asset) => { - test(`should modify a ${asset}`, async (done) => { + test(`should modify a ${asset}`, async () => { const location = await mocks.locationFactory({ promisedFarm: [{ farm_id: farm }] }); const typeOfFigure = figureMapping[asset]; const figure = await mocks[`${typeOfFigure}Factory`]({ promisedLocation: location }); @@ -858,21 +797,18 @@ describe('Location tests', () => { }, }; - putLocation( + const res = await putLocation( data, { user_id: user, farm_id: farm }, asset, location[0].location_id, - (err, res) => { - expect(res.status).toBe(200); - expect(res.body.name).toBe('Test Name323'); - done(); - }, ); + expect(res.status).toBe(200); + expect(res.body.name).toBe('Test Name323'); }); }); - test('should update a field', async (done) => { + test('should update a field', async () => { const location = await mocks.locationFactory({ promisedFarm: [{ farm_id: farm }] }); const area = await mocks.areaFactory({ promisedLocation: location }); const field = await mocks.fieldFactory({ promisedLocation: location, promisedArea: area }); @@ -901,22 +837,21 @@ describe('Location tests', () => { organic_status: 'Non-Organic', }, }; - putLocation( + + const res = await putLocation( data, { user_id: user, farm_id: farm }, locations.FIELD, location[0].location_id, - (err, res) => { - expect(res.status).toBe(200); - expect(res.body.name).toBe('Test Name323'); - expect(res.body.figure.type).toBe(locations.FIELD); - expect(res.body.field.organic_status).toBe('Non-Organic'); - done(); - }, ); + + expect(res.status).toBe(200); + expect(res.body.name).toBe('Test Name323'); + expect(res.body.figure.type).toBe(locations.FIELD); + expect(res.body.field.organic_status).toBe('Non-Organic'); }); - test('should update a garden', async (done) => { + test('should update a garden', async () => { const location = await mocks.locationFactory({ promisedFarm: [{ farm_id: farm }] }); const area = await mocks.areaFactory({ promisedLocation: location }); const garden = await mocks.gardenFactory({ promisedLocation: location, promisedArea: area }); @@ -945,20 +880,19 @@ describe('Location tests', () => { organic_status: 'Non-Organic', }, }; - putLocation( + + const res = await putLocation( data, { user_id: user, farm_id: farm }, locations.GARDEN, location[0].location_id, - (err, res) => { - console.log(data); - expect(res.status).toBe(200); - expect(res.body.name).toBe('Test Name323'); - expect(res.body.figure.type).toBe(locations.GARDEN); - expect(res.body.garden.organic_status).toBe('Non-Organic'); - done(); - }, ); + + console.log(data); + expect(res.status).toBe(200); + expect(res.body.name).toBe('Test Name323'); + expect(res.body.figure.type).toBe(locations.GARDEN); + expect(res.body.garden.organic_status).toBe('Non-Organic'); }); }); }); diff --git a/packages/api/tests/login.test.js b/packages/api/tests/login.test.js index ffabdda092..c94f4d7cc4 100644 --- a/packages/api/tests/login.test.js +++ b/packages/api/tests/login.test.js @@ -50,8 +50,8 @@ describe('Sign Up Tests', () => { // FUNCTIONS - function getRequest({ email = newOwner.email }, callback) { - chai.request(server).get(`/login/user/${email}`).set('email', email).end(callback); + function getRequest({ email = newOwner.email }) { + return chai.request(server).get(`/login/user/${email}`).set('email', email); } beforeEach(async () => { @@ -61,41 +61,36 @@ describe('Sign Up Tests', () => { emailMiddleware.sendEmail.mockClear(); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); // GET TESTS describe('Sign up tests', () => { - test('Get status of user from email address should return 200 and SSO false', async (done) => { + test('Get status of user from email address should return 200 and SSO false', async () => { const [user] = await mocks.usersFactory(); const name = user.first_name; - getRequest({ email: user.email }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.exists).toBe(true); - expect(res.body.sso).toBe(false); - expect(res.body.first_name).toBe(name); - expect(res.body.language).toBe('en'); // Default language - done(); - }); + const res = await getRequest({ email: user.email }); + expect(res.status).toBe(200); + expect(res.body.exists).toBe(true); + expect(res.body.sso).toBe(false); + expect(res.body.first_name).toBe(name); + expect(res.body.language).toBe('en'); // Default language }); - test('Get status of user from email address should return 200 and SSO true', async (done) => { + test('Get status of user from email address should return 200 and SSO true', async () => { const [user] = await mocks.usersFactory(mocks.fakeSSOUser()); const name = user.first_name; - getRequest({ email: user.email }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.exists).toBe(true); - expect(res.body.sso).toBe(true); - expect(res.body.first_name).toBe(name); - done(); - }); + const res = await getRequest({ email: user.email }); + expect(res.status).toBe(200); + expect(res.body.exists).toBe(true); + expect(res.body.sso).toBe(true); + expect(res.body.first_name).toBe(name); }); - test('Get status of user from email address should return 200 and sso false because user does not exist', async (done) => { + test('Get status of user from email address should return 200 and sso false because user does not exist', async () => { const user = { first_name: 'Bobby', last_name: 'McBobson', @@ -104,32 +99,28 @@ describe('Sign Up Tests', () => { phone_number: '899-903-2343', }; - getRequest({ email: user.email }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.exists).toBe(false); - expect(res.body.sso).toBe(false); - done(); - }); + const res = await getRequest({ email: user.email }); + expect(res.status).toBe(200); + expect(res.body.exists).toBe(false); + expect(res.body.sso).toBe(false); }); }); describe('Exists', () => { - test('should send missing invitation to user if checks existance and has no farms', async (done) => { + test('should send missing invitation to user if checks existance and has no farms', async () => { const [user] = await mocks.usersFactory({ ...mocks.fakeUser(), status_id: 2 }); const [userFarm] = await mocks.userFarmFactory( { promisedUser: [user] }, { status: 'Invited' }, ); - getRequest({ email: user.email }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.exists).toBe(false); - expect(res.body.invited).toBe(true); - expect(emailMiddleware.sendEmail).toHaveBeenCalled(); - done(); - }); + const res = await getRequest({ email: user.email }); + expect(res.status).toBe(200); + expect(res.body.exists).toBe(false); + expect(res.body.invited).toBe(true); + expect(emailMiddleware.sendEmail).toHaveBeenCalled(); }); - test('should send missing invitation(s) to user if checks existance and has no farms but many invites', async (done) => { + test('should send missing invitation(s) to user if checks existance and has no farms but many invites', async () => { const [user] = await mocks.usersFactory({ ...mocks.fakeUser(), status_id: 2 }); const [userFarm1] = await mocks.userFarmFactory( { promisedUser: [user] }, @@ -147,83 +138,78 @@ describe('Sign Up Tests', () => { { promisedUser: [user] }, { status: 'Invited' }, ); - getRequest({ email: user.email }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.exists).toBe(false); - expect(res.body.invited).toBe(true); - expect(emailMiddleware.sendEmail).toHaveBeenCalledTimes(4); - done(); - }); + const res = await getRequest({ email: user.email }); + expect(res.status).toBe(200); + expect(res.body.exists).toBe(false); + expect(res.body.invited).toBe(true); + expect(emailMiddleware.sendEmail).toHaveBeenCalledTimes(4); }); - test('should send a password reset email to user if he was legacy ', async (done) => { + test('should send a password reset email to user if he was legacy ', async () => { const [user] = await mocks.usersFactory({ ...mocks.fakeUser(), status_id: 3 }); const [userFarm1] = await mocks.userFarmFactory({ promisedUser: [user] }); - getRequest({ email: user.email }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.exists).toBe(false); - expect(res.body.expired).toBe(true); - expect(emailMiddleware.sendEmail).toHaveBeenCalledTimes(1); - done(); - }); + const res = await getRequest({ email: user.email }); + expect(res.status).toBe(200); + expect(res.body.exists).toBe(false); + expect(res.body.expired).toBe(true); + expect(emailMiddleware.sendEmail).toHaveBeenCalledTimes(1); }); - test('should resend a password reset email to user if he was legacy ', async (done) => { + test('should resend a password reset email to user if he was legacy ', async () => { const [user] = await mocks.usersFactory({ ...mocks.fakeUser(), status_id: 3 }); const [userFarm1] = await mocks.userFarmFactory({ promisedUser: [user] }); - getRequest({ email: user.email }, (err, res) => { - getRequest({ email: user.email }, (err2, res2) => { - expect(res2.status).toBe(200); - expect(res2.body.exists).toBe(false); - expect(res2.body.expired).toBe(true); - expect(emailMiddleware.sendEmail).toHaveBeenCalledTimes(2); - done(); - }); - }); + const res = await getRequest({ email: user.email }); + const res2 = await getRequest({ email: user.email }); + expect(res2.status).toBe(200); + expect(res2.body.exists).toBe(false); + expect(res2.body.expired).toBe(true); + expect(emailMiddleware.sendEmail).toHaveBeenCalledTimes(2); }); - test('should reject when a pseudo user tries to login', async (done) => { + test('should reject when a pseudo user tries to login', async () => { const [user] = await mocks.usersFactory({ ...mocks.fakeUser(), status_id: 1, email: `${faker.datatype.uuid()}@pseudo.com`, }); const [userFarm1] = await mocks.userFarmFactory({ promisedUser: [user] }); - getRequest({ email: user.email }, (err, res) => { - expect(res.status).toBe(400); - expect(emailMiddleware.sendEmail).toHaveBeenCalledTimes(0); - done(); - }); + const res = await getRequest({ email: user.email }); + expect(res.status).toBe(400); + expect(emailMiddleware.sendEmail).toHaveBeenCalledTimes(0); }); - test('should fail at the 4th request of a user who had a pending invitation', async (done) => { + test('should fail at the 4th request of a user who had a pending invitation', async () => { const [user] = await mocks.usersFactory({ ...mocks.fakeUser(), status_id: 2 }); const [userFarm] = await mocks.userFarmFactory( { promisedUser: [user] }, { status: 'Invited' }, ); const { user_id, farm_id } = userFarm; - getRequest({ email: user.email }, async () => { + await getRequest({ email: user.email }); + const [emailTokenRow] = await knex('emailToken').where({ user_id, farm_id }); + expect(emailTokenRow.times_sent).toBe(1); + + { + await getRequest({ email: user.email }); const [emailTokenRow] = await knex('emailToken').where({ user_id, farm_id }); - expect(emailTokenRow.times_sent).toBe(1); - getRequest({ email: user.email }, async () => { + expect(emailTokenRow.times_sent).toBe(2); + + { + await getRequest({ email: user.email }); const [emailTokenRow] = await knex('emailToken').where({ user_id, farm_id }); - expect(emailTokenRow.times_sent).toBe(2); - getRequest({ email: user.email }, async () => { + expect(emailTokenRow.times_sent).toBe(3); + + { + const res = await getRequest({ email: user.email }); + expect(res.status).toBe(200); const [emailTokenRow] = await knex('emailToken').where({ user_id, farm_id }); expect(emailTokenRow.times_sent).toBe(3); - getRequest({ email: user.email }, async (err, res) => { - expect(res.status).toBe(200); - const [emailTokenRow] = await knex('emailToken').where({ user_id, farm_id }); - expect(emailTokenRow.times_sent).toBe(3); - expect(res.body.exists).toBe(false); - expect(res.body.invited).toBe(true); - expect(emailMiddleware.sendEmail).toHaveBeenCalledTimes(3); - done(); - }); - }); - }); - }); + expect(res.body.exists).toBe(false); + expect(res.body.invited).toBe(true); + expect(emailMiddleware.sendEmail).toHaveBeenCalledTimes(3); + } + } + } }); }); }); diff --git a/packages/api/tests/managementPlan.test.js b/packages/api/tests/managementPlan.test.js index 5a0f835613..7fbbb778f0 100644 --- a/packages/api/tests/managementPlan.test.js +++ b/packages/api/tests/managementPlan.test.js @@ -58,87 +58,71 @@ describe('ManagementPlan Tests', () => { await mocks.populateFieldWorkTaskTypes(); }); - function postManagementPlanRequest( - data, - { user_id = owner.user_id, farm_id = farm.farm_id }, - callback, - ) { - chai + function postManagementPlanRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post(`/management_plan`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } async function postRepeatManagementPlanRequest( data, { user_id = owner.user_id, farm_id = farm.farm_id }, - callback, ) { - chai + return chai .request(server) .post(`/management_plan/repeat_plan`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(await callback); + .send(data); } - function getRequest(url, { user_id = owner.user_id, farm_id = farm.farm_id }, callback) { - chai.request(server).get(url).set('user_id', user_id).set('farm_id', farm_id).end(callback); + function getRequest(url, { user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai.request(server).get(url).set('user_id', user_id).set('farm_id', farm_id); } - function patchManagementPlanRequest( - data, - { user_id = owner.user_id, farm_id = farm.farm_id }, - callback, - ) { + function patchManagementPlanRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }) { const { management_plan_id } = data; - chai + + return chai .request(server) .patch(`/management_plan/${management_plan_id}`) .set('farm_id', farm_id) .set('user_id', user_id) - .send(data) - .end(callback); + .send(data); } - function deleteRequest(url, { user_id = owner.user_id, farm_id = farm.farm_id }, callback) { - chai.request(server).delete(url).set('user_id', user_id).set('farm_id', farm_id).end(callback); + function deleteRequest(url, { user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai.request(server).delete(url).set('user_id', user_id).set('farm_id', farm_id); } function completeManagementPlanRequest( data, { user_id = owner.user_id, farm_id = farm.farm_id }, - callback, ) { const { management_plan_id } = data; - chai + + return chai .request(server) .patch(`/management_plan/${management_plan_id}/complete`) .set('farm_id', farm_id) .set('user_id', user_id) - .send(data) - .end(callback); + .send(data); } - function abandonManagementPlanRequest( - data, - { user_id = owner.user_id, farm_id = farm.farm_id }, - callback, - ) { + function abandonManagementPlanRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }) { const { management_plan_id } = data; - chai + + return chai .request(server) .patch(`/management_plan/${management_plan_id}/abandon`) .set('farm_id', farm_id) .set('user_id', user_id) - .send(data) - .end(callback); + .send(data); } function fakeUserFarm(role = 1) { @@ -167,10 +151,9 @@ describe('ManagementPlan Tests', () => { figure.[area], field]`); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('Get && delete && put managementPlan', () => { @@ -260,41 +243,33 @@ describe('ManagementPlan Tests', () => { } } }; - test('Workers should get managementPlan by farm id', async (done) => { - getRequest( - `/management_plan/farm/${farm.farm_id}`, - { user_id: worker.user_id }, - (err, res) => { - expect(res.status).toBe(200); - assetManagementPlans(res, 2); - done(); - }, - ); + test('Workers should get managementPlan by farm id', async () => { + const res = await getRequest(`/management_plan/farm/${farm.farm_id}`, { + user_id: worker.user_id, + }); + expect(res.status).toBe(200); + assetManagementPlans(res, 2); }); - test('Workers should get managementPlan by date', async (done) => { - getRequest( + test('Workers should get managementPlan by date', async () => { + const res = await getRequest( `/management_plan/farm/date/${farm.farm_id}/${moment().format('YYYY-MM-DD')}`, { user_id: worker.user_id }, - (err, res) => { - expect(res.status).toBe(200); - assetManagementPlans(res, 2); - done(); - }, ); + + expect(res.status).toBe(200); + assetManagementPlans(res, 2); }); - test('Workers should get managementPlan by id', async (done) => { - getRequest( + test('Workers should get managementPlan by id', async () => { + const res = await getRequest( `/management_plan/${transplantManagementPlan.management_plan_id}`, { user_id: worker.user_id }, - (err, res) => { - expect(res.status).toBe(200); - expect( - res.body.crop_management_plan.planting_management_plans[1].management_plan_id, - ).toBe(transplantManagementPlan.management_plan_id); - done(); - }, + ); + + expect(res.status).toBe(200); + expect(res.body.crop_management_plan.planting_management_plans[1].management_plan_id).toBe( + transplantManagementPlan.management_plan_id, ); }); @@ -333,58 +308,42 @@ describe('ManagementPlan Tests', () => { ); }); - test('Owner should get managementPlan by farm id', async (done) => { - getRequest( - `/management_plan/farm/${farm.farm_id}`, - { user_id: owner.user_id }, - (err, res) => { - expect(res.status).toBe(200); - assetManagementPlans(res, 2); - done(); - }, - ); + test('Owner should get managementPlan by farm id', async () => { + const res = await getRequest(`/management_plan/farm/${farm.farm_id}`, { + user_id: owner.user_id, + }); + expect(res.status).toBe(200); + assetManagementPlans(res, 2); }); - test('Manager should get managementPlan by farm id', async (done) => { - getRequest( - `/management_plan/farm/${farm.farm_id}`, - { user_id: manager.user_id }, - (err, res) => { - expect(res.status).toBe(200); - assetManagementPlans(res, 2); - done(); - }, - ); + test('Manager should get managementPlan by farm id', async () => { + const res = await getRequest(`/management_plan/farm/${farm.farm_id}`, { + user_id: manager.user_id, + }); + expect(res.status).toBe(200); + assetManagementPlans(res, 2); }); - test('Should get status 403 if an unauthorizedUser tries to get managementPlan by farm id', async (done) => { - getRequest( - `/management_plan/farm/${farm.farm_id}`, - { user_id: unAuthorizedUser.user_id }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Should get status 403 if an unauthorizedUser tries to get managementPlan by farm id', async () => { + const res = await getRequest(`/management_plan/farm/${farm.farm_id}`, { + user_id: unAuthorizedUser.user_id, + }); + + expect(res.status).toBe(403); }); - test('Circumvent authorization by modifying farm_id', async (done) => { - getRequest( - `/management_plan/farm/${farm.farm_id}`, - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modifying farm_id', async () => { + const res = await getRequest(`/management_plan/farm/${farm.farm_id}`, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); }); }); describe('Get harvested to date', () => { - test('should get all the harvested quantities that come from completed harvest_tasks in the management_plan', async (done) => { + test('should get all the harvested quantities that come from completed harvest_tasks in the management_plan', async () => { const [harvestedCrop] = await mocks.cropFactory( { promisedFarm: [farm] }, { @@ -446,19 +405,15 @@ describe('ManagementPlan Tests', () => { promisedPlantingManagementPlan: [harvestedPlantingManagementPlan], }); - getRequest( - `/management_plan/farm/${farm.farm_id}`, - { user_id: owner.user_id }, - (err, res) => { - expect(res.status).toBe(200); - const mp = res.body.find( - (mp) => mp.management_plan_id === harvestedManagementPlan.management_plan_id, - ); - expect(mp).toBeDefined(); - expect(mp.harvested_to_date).toBe(1011); - done(); - }, + const res = await getRequest(`/management_plan/farm/${farm.farm_id}`, { + user_id: owner.user_id, + }); + expect(res.status).toBe(200); + const mp = res.body.find( + (mp) => mp.management_plan_id === harvestedManagementPlan.management_plan_id, ); + expect(mp).toBeDefined(); + expect(mp.harvested_to_date).toBe(1011); }); }); }); @@ -507,91 +462,78 @@ describe('ManagementPlan Tests', () => { ); }); - test('should delete a managementPlan by owner', async (done) => { - deleteRequest( + test('should delete a managementPlan by owner', async () => { + const res = await deleteRequest( `/management_plan/${transplantManagementPlan.management_plan_id}`, {}, - async (err, res) => { - expect(res.status).toBe(200); - const managementPlanRes = await managementPlanModel - .query() - .context({ showHidden: true }) - .where('management_plan_id', transplantManagementPlan.management_plan_id); - expect(managementPlanRes.length).toBe(1); - expect(managementPlanRes[0].deleted).toBe(true); - done(); - }, ); + expect(res.status).toBe(200); + const managementPlanRes = await managementPlanModel + .query() + .context({ showHidden: true }) + .where('management_plan_id', transplantManagementPlan.management_plan_id); + expect(managementPlanRes.length).toBe(1); + expect(managementPlanRes[0].deleted).toBe(true); }); - test('should delete a managementPlan by manager', async (done) => { - deleteRequest( + test('should delete a managementPlan by manager', async () => { + const res = await deleteRequest( `/management_plan/${transplantManagementPlan.management_plan_id}`, { user_id: manager.user_id }, - async (err, res) => { - expect(res.status).toBe(200); - const managementPlanRes = await managementPlanModel - .query() - .context({ showHidden: true }) - .where('management_plan_id', transplantManagementPlan.management_plan_id); - expect(managementPlanRes.length).toBe(1); - expect(managementPlanRes[0].deleted).toBe(true); - done(); - }, ); + + expect(res.status).toBe(200); + const managementPlanRes = await managementPlanModel + .query() + .context({ showHidden: true }) + .where('management_plan_id', transplantManagementPlan.management_plan_id); + expect(managementPlanRes.length).toBe(1); + expect(managementPlanRes[0].deleted).toBe(true); }); - test('should delete a managementPlan by extension officer', async (done) => { - deleteRequest( + test('should delete a managementPlan by extension officer', async () => { + const res = await deleteRequest( `/management_plan/${transplantManagementPlan.management_plan_id}`, { user_id: extensionOfficer.user_id }, - async (err, res) => { - expect(res.status).toBe(200); - const managementPlanRes = await managementPlanModel - .query() - .context({ showHidden: true }) - .where('management_plan_id', transplantManagementPlan.management_plan_id); - expect(managementPlanRes.length).toBe(1); - expect(managementPlanRes[0].deleted).toBe(true); - done(); - }, ); + + expect(res.status).toBe(200); + const managementPlanRes = await managementPlanModel + .query() + .context({ showHidden: true }) + .where('management_plan_id', transplantManagementPlan.management_plan_id); + expect(managementPlanRes.length).toBe(1); + expect(managementPlanRes[0].deleted).toBe(true); }); - test('should return 403 if an unauthorized user tries to delete a managementPlan', async (done) => { - deleteRequest( + test('should return 403 if an unauthorized user tries to delete a managementPlan', async () => { + const res = await deleteRequest( `/management_plan/${transplantManagementPlan.management_plan_id}`, { user_id: unAuthorizedUser.user_id }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, ); + + expect(res.status).toBe(403); }); - test('should return 403 if a worker tries to delete a managementPlan', async (done) => { - deleteRequest( + test('should return 403 if a worker tries to delete a managementPlan', async () => { + const res = await deleteRequest( `/management_plan/${transplantManagementPlan.management_plan_id}`, { user_id: worker.user_id }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, ); + + expect(res.status).toBe(403); }); - test('Circumvent authorization by modifying farm_id', async (done) => { - deleteRequest( + test('Circumvent authorization by modifying farm_id', async () => { + const res = await deleteRequest( `/management_plan/${transplantManagementPlan.management_plan_id}`, { user_id: unAuthorizedUser.user_id, farm_id: farmunAuthorizedUser.farm_id, }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, ); + + expect(res.status).toBe(403); }); }); @@ -626,12 +568,10 @@ describe('ManagementPlan Tests', () => { ); } - xtest('should be able to edit management plan', async (done) => { + xtest('should be able to edit management plan', async () => { const reqBody = getFakeManagementPlan(); - patchManagementPlanRequest(reqBody, {}, async (err, res) => { - await expectManagementPlanPatched(res, reqBody); - done(); - }); + const res = await patchManagementPlanRequest(reqBody, {}); + await expectManagementPlanPatched(res, reqBody); }); describe('patch managementPlan authorization tests', () => { @@ -669,43 +609,35 @@ describe('ManagementPlan Tests', () => { ); }); //TODO: Owner test - test('should edit and the area_used field by manager', async (done) => { + test('should edit and the area_used field by manager', async () => { const reqBody = getFakeManagementPlan(); - patchManagementPlanRequest(reqBody, { user_id: manager.user_id }, async (err, res) => { - await expectManagementPlanPatched(res, reqBody); - done(); - }); + const res = await patchManagementPlanRequest(reqBody, { user_id: manager.user_id }); + await expectManagementPlanPatched(res, reqBody); }); - test('should return 403 when unauthorized user tries to edit managementPlan', async (done) => { + test('should return 403 when unauthorized user tries to edit managementPlan', async () => { const reqBody = getFakeManagementPlan(); - patchManagementPlanRequest(reqBody, { user_id: unAuthorizedUser.user_id }, (err, res) => { - expect(res.status).toBe(403); - done(); + const res = await patchManagementPlanRequest(reqBody, { + user_id: unAuthorizedUser.user_id, }); + expect(res.status).toBe(403); }); - test('should return 403 when a worker tries to edit managementPlan', async (done) => { + test('should return 403 when a worker tries to edit managementPlan', async () => { const reqBody = getFakeManagementPlan(); - patchManagementPlanRequest(reqBody, { user_id: worker.user_id }, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await patchManagementPlanRequest(reqBody, { user_id: worker.user_id }); + expect(res.status).toBe(403); }); - test('Circumvent authorization by modifying farm_id', async (done) => { + test('Circumvent authorization by modifying farm_id', async () => { const reqBody = getFakeManagementPlan(); - patchManagementPlanRequest( - reqBody, - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + + const res = await patchManagementPlanRequest(reqBody, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); }); }); }); @@ -729,36 +661,32 @@ describe('ManagementPlan Tests', () => { }); } - test('Abandon management plan', async (done) => { + test('Abandon management plan', async () => { const reqBody = getCompleteReqBody(true); - abandonManagementPlanRequest(reqBody, {}, async (err, res) => { - expect(res.status).toBe(200); - const newManagementPlan = await managementPlanModel - .query() - .context({ showHidden: true }) - .where('management_plan_id', transplantManagementPlan.management_plan_id) - .first(); - expect(newManagementPlan.complete_notes).toBe(reqBody.complete_notes); - expect(newManagementPlan.abandon_reason).toBe(reqBody.abandon_reason); - done(); - }); + const res = await abandonManagementPlanRequest(reqBody, {}); + expect(res.status).toBe(200); + const newManagementPlan = await managementPlanModel + .query() + .context({ showHidden: true }) + .where('management_plan_id', transplantManagementPlan.management_plan_id) + .first(); + expect(newManagementPlan.complete_notes).toBe(reqBody.complete_notes); + expect(newManagementPlan.abandon_reason).toBe(reqBody.abandon_reason); }); - test('Complete management plan', async (done) => { + test('Complete management plan', async () => { const reqBody = getCompleteReqBody(); - completeManagementPlanRequest(reqBody, {}, async (err, res) => { - expect(res.status).toBe(200); - const newManagementPlan = await managementPlanModel - .query() - .context({ showHidden: true }) - .where('management_plan_id', transplantManagementPlan.management_plan_id) - .first(); - expect(newManagementPlan.complete_notes).toBe(reqBody.complete_notes); - done(); - }); + const res = await completeManagementPlanRequest(reqBody, {}); + expect(res.status).toBe(200); + const newManagementPlan = await managementPlanModel + .query() + .context({ showHidden: true }) + .where('management_plan_id', transplantManagementPlan.management_plan_id) + .first(); + expect(newManagementPlan.complete_notes).toBe(reqBody.complete_notes); }); - test('Complete management plan with completed and abandoned tasks', async (done) => { + test('Complete management plan with completed and abandoned tasks', async () => { const reqBody = getCompleteReqBody(); const abandonedTask = await mocks.management_tasksFactory({ promisedManagementPlan: [transplantManagementPlan], @@ -775,19 +703,17 @@ describe('ManagementPlan Tests', () => { ), }); - completeManagementPlanRequest(reqBody, {}, async (err, res) => { - expect(res.status).toBe(200); - const newManagementPlan = await managementPlanModel - .query() - .context({ showHidden: true }) - .where('management_plan_id', transplantManagementPlan.management_plan_id) - .first(); - expect(newManagementPlan.complete_notes).toBe(reqBody.complete_notes); - done(); - }); + const res = await completeManagementPlanRequest(reqBody, {}); + expect(res.status).toBe(200); + const newManagementPlan = await managementPlanModel + .query() + .context({ showHidden: true }) + .where('management_plan_id', transplantManagementPlan.management_plan_id) + .first(); + expect(newManagementPlan.complete_notes).toBe(reqBody.complete_notes); }); - test('Complete management plan with deleted and completed tasks', async (done) => { + test('Complete management plan with deleted and completed tasks', async () => { const reqBody = getCompleteReqBody(); const deletedTask = await mocks.management_tasksFactory({ promisedManagementPlan: [transplantManagementPlan], @@ -804,21 +730,19 @@ describe('ManagementPlan Tests', () => { ), }); - completeManagementPlanRequest(reqBody, {}, async (err, res) => { - expect(res.status).toBe(200); - const newManagementPlan = await managementPlanModel - .query() - .context({ showHidden: true }) - .where('management_plan_id', transplantManagementPlan.management_plan_id) - .first(); - expect(newManagementPlan.complete_notes).toBe(reqBody.complete_notes); - done(); - }); + const res = await completeManagementPlanRequest(reqBody, {}); + expect(res.status).toBe(200); + const newManagementPlan = await managementPlanModel + .query() + .context({ showHidden: true }) + .where('management_plan_id', transplantManagementPlan.management_plan_id) + .first(); + expect(newManagementPlan.complete_notes).toBe(reqBody.complete_notes); }); const getDateInputFormat = (date) => moment(date).format('YYYY-MM-DD'); - test('Abandon management plan with one pending task that reference this management plan and another management_plan', async (done) => { + test('Abandon management plan with one pending task that reference this management plan and another management_plan', async () => { const reqBody = getCompleteReqBody(); const [plantingManagementPlan] = await getFinalPlantingManagementPlan( transplantManagementPlan, @@ -841,31 +765,29 @@ describe('ManagementPlan Tests', () => { }), }); - abandonManagementPlanRequest(reqBody, {}, async (err, res) => { - expect(res.status).toBe(200); - const newManagementPlan = await managementPlanModel - .query() - .context({ showHidden: true }) - .where('management_plan_id', transplantManagementPlan.management_plan_id) - .first(); - expect(newManagementPlan.complete_notes).toBe(reqBody.complete_notes); - const deletedManagementPlan = await knex('management_tasks') - .where(_pick(managementTaskToBeDeleted, ['planting_management_plan_id', 'task_id'])) - .first(); - expect(deletedManagementPlan).toBeUndefined(); - const keptManagementTask0 = await knex('management_tasks') - .where(_pick(managementTaskToKeep, ['planting_management_plan_id', 'task_id'])) - .first(); - expect(keptManagementTask0).toBeDefined(); - const keptManagementTask1 = await knex('management_tasks') - .where(_pick(anotherManagementTask, ['planting_management_plan_id', 'task_id'])) - .first(); - expect(keptManagementTask1).toBeDefined(); - done(); - }); + const res = await abandonManagementPlanRequest(reqBody, {}); + expect(res.status).toBe(200); + const newManagementPlan = await managementPlanModel + .query() + .context({ showHidden: true }) + .where('management_plan_id', transplantManagementPlan.management_plan_id) + .first(); + expect(newManagementPlan.complete_notes).toBe(reqBody.complete_notes); + const deletedManagementPlan = await knex('management_tasks') + .where(_pick(managementTaskToBeDeleted, ['planting_management_plan_id', 'task_id'])) + .first(); + expect(deletedManagementPlan).toBeUndefined(); + const keptManagementTask0 = await knex('management_tasks') + .where(_pick(managementTaskToKeep, ['planting_management_plan_id', 'task_id'])) + .first(); + expect(keptManagementTask0).toBeDefined(); + const keptManagementTask1 = await knex('management_tasks') + .where(_pick(anotherManagementTask, ['planting_management_plan_id', 'task_id'])) + .first(); + expect(keptManagementTask1).toBeDefined(); }); - test('Abandon management plan with two pending task that reference this management plan and another management_plan', async (done) => { + test('Abandon management plan with two pending task that reference this management plan and another management_plan', async () => { const reqBody = getCompleteReqBody(true); const [plantingManagementPlan] = await getFinalPlantingManagementPlan( transplantManagementPlan, @@ -889,39 +811,37 @@ describe('ManagementPlan Tests', () => { promisedManagementPlan: mocks.crop_management_planFactory({ promisedFarm: [farm] }), }); - abandonManagementPlanRequest(reqBody, {}, async (err, res) => { - expect(res.status).toBe(200); - const newManagementPlan = await managementPlanModel - .query() - .context({ showHidden: true }) - .where('management_plan_id', transplantManagementPlan.management_plan_id) - .first(); - expect(newManagementPlan.complete_notes).toBe(reqBody.complete_notes); - const deletedManagementPlan = await knex('management_tasks') - .where(_pick(managementTaskToBeDeleted, ['planting_management_plan_id', 'task_id'])) - .first(); - expect(deletedManagementPlan).toBeUndefined(); - const keptManagementTask0 = await knex('management_tasks') - .where(_pick(managementTaskToKeep, ['planting_management_plan_id', 'task_id'])) - .first(); - expect(keptManagementTask0).toBeDefined(); - const keptManagementTask1 = await knex('management_tasks') - .where(_pick(anotherManagementTask, ['planting_management_plan_id', 'task_id'])) - .first(); - expect(keptManagementTask1).toBeDefined(); - const keptManagementTask2 = await knex('management_tasks') - .where(_pick(taskToAbandon, ['planting_management_plan_id', 'task_id'])) - .first(); - expect(keptManagementTask2).toBeDefined(); - const abandonedTask = await knex('task') - .where(_pick(taskToAbandon, ['task_id'])) - .first(); - expect(getDateInputFormat(abandonedTask.abandon_date)).toBe(reqBody.abandon_date); - done(); - }); + const res = await abandonManagementPlanRequest(reqBody, {}); + expect(res.status).toBe(200); + const newManagementPlan = await managementPlanModel + .query() + .context({ showHidden: true }) + .where('management_plan_id', transplantManagementPlan.management_plan_id) + .first(); + expect(newManagementPlan.complete_notes).toBe(reqBody.complete_notes); + const deletedManagementPlan = await knex('management_tasks') + .where(_pick(managementTaskToBeDeleted, ['planting_management_plan_id', 'task_id'])) + .first(); + expect(deletedManagementPlan).toBeUndefined(); + const keptManagementTask0 = await knex('management_tasks') + .where(_pick(managementTaskToKeep, ['planting_management_plan_id', 'task_id'])) + .first(); + expect(keptManagementTask0).toBeDefined(); + const keptManagementTask1 = await knex('management_tasks') + .where(_pick(anotherManagementTask, ['planting_management_plan_id', 'task_id'])) + .first(); + expect(keptManagementTask1).toBeDefined(); + const keptManagementTask2 = await knex('management_tasks') + .where(_pick(taskToAbandon, ['planting_management_plan_id', 'task_id'])) + .first(); + expect(keptManagementTask2).toBeDefined(); + const abandonedTask = await knex('task') + .where(_pick(taskToAbandon, ['task_id'])) + .first(); + expect(getDateInputFormat(abandonedTask.abandon_date)).toBe(reqBody.abandon_date); }); - test('Abandon management plan with one pending task that reference this management plan and no location', async (done) => { + test('Abandon management plan with one pending task that reference this management plan and no location', async () => { const reqBody = getCompleteReqBody(true); const [plantingManagementPlan] = await getFinalPlantingManagementPlan( transplantManagementPlan, @@ -930,22 +850,19 @@ describe('ManagementPlan Tests', () => { promisedPlantingManagementPlan: [plantingManagementPlan], promisedTask: mocks.taskFactory({ promisedUser: [owner] }, { ...mocks.fakeTask() }), }); - abandonManagementPlanRequest(reqBody, {}, async (err, res) => { - expect(res.status).toBe(200); - const newManagementPlan = await managementPlanModel - .query() - .context({ showHidden: true }) - .where('management_plan_id', transplantManagementPlan.management_plan_id) - .first(); - expect(newManagementPlan.complete_notes).toBe(reqBody.complete_notes); - const newTask = await knex('task').where('task_id', task.task_id).first(); - expect(getDateInputFormat(newTask.abandon_date)).toBe(reqBody.abandon_date); - // expect(newTask.abandon_reason).toBe('Crop management plan abandoned'); - done(); - }); + const res = await abandonManagementPlanRequest(reqBody, {}); + expect(res.status).toBe(200); + const newManagementPlan = await managementPlanModel + .query() + .context({ showHidden: true }) + .where('management_plan_id', transplantManagementPlan.management_plan_id) + .first(); + expect(newManagementPlan.complete_notes).toBe(reqBody.complete_notes); + const newTask = await knex('task').where('task_id', task.task_id).first(); + expect(getDateInputFormat(newTask.abandon_date)).toBe(reqBody.abandon_date); }); - test('Should return 400 when complete management plan with pending tasks', async (done) => { + test('Should return 400 when complete management plan with pending tasks', async () => { const reqBody = getCompleteReqBody(); const [plantingManagementPlan] = await getFinalPlantingManagementPlan( transplantManagementPlan, @@ -954,10 +871,8 @@ describe('ManagementPlan Tests', () => { promisedPlantingManagementPlan: [plantingManagementPlan], }); - completeManagementPlanRequest(reqBody, {}, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await completeManagementPlanRequest(reqBody, {}); + expect(res.status).toBe(400); }); }); }); @@ -1155,32 +1070,28 @@ describe('ManagementPlan Tests', () => { }); } - test('should create a broadcast management plan with required data', async (done) => { - postManagementPlanRequest(getBody('broadcast_method'), userFarm, async (err, res) => { - await expectPlantingMethodPosted(res, 'broadcast_method'); - done(); - }); + test('should create a broadcast management plan with required data', async () => { + const res = await postManagementPlanRequest(getBody('broadcast_method'), userFarm); + await expectPlantingMethodPosted(res, 'broadcast_method'); }); - test('should create a broadcast management plan with required data and assigned to an assignee', async (done) => { + test('should create a broadcast management plan with required data and assigned to an assignee', async () => { const request_body = getBody('broadcast_method'); request_body.assignee_user_id = owner.user_id; - postManagementPlanRequest(request_body, userFarm, async (err, res) => { - await expectPlantingMethodPosted(res, 'broadcast_method'); - const { planting_management_plan_id } = await knex('planting_management_plan') - .where({ - management_plan_id: res.body.management_plan.management_plan_id, - planting_task_type: 'PLANT_TASK', - }) - .first(); - const plant_task = await knex('plant_task').where({ planting_management_plan_id }).first(); - const task = await knex('task').where({ task_id: plant_task.task_id }).first(); - expect(task.assignee_user_id).toBe(owner.user_id); - done(); - }); + const res = await postManagementPlanRequest(request_body, userFarm); + await expectPlantingMethodPosted(res, 'broadcast_method'); + const { planting_management_plan_id } = await knex('planting_management_plan') + .where({ + management_plan_id: res.body.management_plan.management_plan_id, + planting_task_type: 'PLANT_TASK', + }) + .first(); + const plant_task = await knex('plant_task').where({ planting_management_plan_id }).first(); + const task = await knex('task').where({ task_id: plant_task.task_id }).first(); + expect(task.assignee_user_id).toBe(owner.user_id); }); - test('should create a broadcast management plan with 100% planted', async (done) => { + test('should create a broadcast management plan with 100% planted', async () => { const broadcastData = getBody('broadcast_method'); const { total_area } = await knex('location') .join('figure', 'figure.location_id', 'location.location_id') @@ -1189,50 +1100,38 @@ describe('ManagementPlan Tests', () => { .first(); broadcastData.crop_management_plan.planting_management_plans[0].broadcast_method.percentage_planted = 100; broadcastData.crop_management_plan.planting_management_plans[0].broadcast_method.area_used = total_area; - postManagementPlanRequest(broadcastData, userFarm, async (err, res) => { - await expectPlantingMethodPosted(res, 'broadcast_method'); - done(); - }); + const res = await postManagementPlanRequest(broadcastData, userFarm); + await expectPlantingMethodPosted(res, 'broadcast_method'); }); - test('should create a broadcast management plan with transplant', async (done) => { - postManagementPlanRequest( + test('should create a broadcast management plan with transplant', async () => { + const res = await postManagementPlanRequest( getBody('broadcast_method', 'container_method'), userFarm, - async (err, res) => { - await expectPlantingMethodPosted(res, 'broadcast_method', 'container_method'); - done(); - }, ); + await expectPlantingMethodPosted(res, 'broadcast_method', 'container_method'); }); - test('should create a container management plan with required data', async (done) => { - postManagementPlanRequest(getBody('container_method'), userFarm, async (err, res) => { - await expectPlantingMethodPosted(res, 'container_method'); - done(); - }); + test('should create a container management plan with required data', async () => { + const res = await postManagementPlanRequest(getBody('container_method'), userFarm); + await expectPlantingMethodPosted(res, 'container_method'); }); - test('should create a container management plan with transplant', async (done) => { - postManagementPlanRequest( + test('should create a container management plan with transplant', async () => { + const res = await postManagementPlanRequest( getBody('container_method', 'container_method'), userFarm, - async (err, res) => { - await expectPlantingMethodPosted(res, 'container_method', 'container_method'); - done(); - }, ); + await expectPlantingMethodPosted(res, 'container_method', 'container_method'); }); - test('should create a rows management plan', async (done) => { - postManagementPlanRequest(getBody('row_method'), userFarm, async (err, res) => { - await expectPlantingMethodPosted(res, 'row_method'); - done(); - }); + test('should create a rows management plan', async () => { + const res = await postManagementPlanRequest(getBody('row_method'), userFarm); + await expectPlantingMethodPosted(res, 'row_method'); }); // //TODO: post management plan middle ware that checks there are maximum 1 plant_task and 1 transplant_task - xtest('should not allow multiple types of plantation', async (done) => { + xtest('should not allow multiple types of plantation', async () => { const managementPlantWith4plantingManagementPlan = getBody( 'broadcast_method', 'container_method', @@ -1243,17 +1142,14 @@ describe('ManagementPlan Tests', () => { ...managementPlantWith4plantingManagementPlan.crop_management_plan .planting_management_plans, ]; - postManagementPlanRequest( + const res = await postManagementPlanRequest( managementPlantWith4plantingManagementPlan, userFarm, - async (err, res) => { - expect(res.status).toBe(400); - done(); - }, ); + expect(res.status).toBe(400); }); - test('should copy an existing management plan with transplant', async (done) => { + test('should copy an existing management plan with transplant', async () => { const oneWeekLater = new Date(); const twoWeeksLater = new Date(); oneWeekLater.setDate(oneWeekLater.getDate() + 7); @@ -1262,26 +1158,19 @@ describe('ManagementPlan Tests', () => { const repeat_details = { crop_plan_name: 'Copied Plan', }; - //create management plan then repeat that plan - postManagementPlanRequest( + const res = await postManagementPlanRequest( getBody('container_method', 'container_method'), userFarm, - async (err, res) => { - if (err) { - throw err; - } - expect(res.status).toBe(201); - const { management_plan_id } = res.body.management_plan; - const repeatBody = getRepeatBody(management_plan_id, start_dates, repeat_details); - await postRepeatManagementPlanRequest(repeatBody, userFarm, async (err, res) => { - if (err) { - throw err; - } - await expectManagementGroupPosted(res, repeatBody); - done(); - }); - }, ); + expect(res.status).toBe(201); + const { management_plan_id } = res.body.management_plan; + const repeatBody = getRepeatBody(management_plan_id, start_dates, repeat_details); + await await (async function () { + { + const res = await postRepeatManagementPlanRequest(repeatBody, userFarm); + return await expectManagementGroupPosted(res, repeatBody); + } + })(); }); }); }); diff --git a/packages/api/tests/mock.factories.test.js b/packages/api/tests/mock.factories.test.js index 7703857bc2..713ff0ee64 100644 --- a/packages/api/tests/mock.factories.test.js +++ b/packages/api/tests/mock.factories.test.js @@ -7,7 +7,7 @@ describe('Factories tests', () => { const tableNames = factories.map((factoryName) => factoryName.replace('Factory', '')); tableNames.map((tableName, i) => { - test(`should create one row of ${tableName} using its factory`, async (done) => { + test(`should create one row of ${tableName} using its factory`, async () => { const [result] = await mocks[factories[i]](); // factories[i] will be the table name factory as defined in the mock.factories expect(result).toBeDefined(); const ids = Object.keys(result).reduce( @@ -16,15 +16,13 @@ describe('Factories tests', () => { ); const checker = await knex(tableName).where(ids); expect(checker.length).toBe(1); - done(); }); }); - afterAll(async (done) => { + afterAll(async () => { try { await tableCleanup(knex); await knex.destroy(); - done(); } catch (e) { console.log(e); console.log('Failed cleanup'); diff --git a/packages/api/tests/notificationUser.test.js b/packages/api/tests/notificationUser.test.js index 32be7675ec..39c0b92a7e 100644 --- a/packages/api/tests/notificationUser.test.js +++ b/packages/api/tests/notificationUser.test.js @@ -31,8 +31,8 @@ jest.mock('../src/middleware/acl/checkJwt.js', () => import mocks from './mock.factories.js'; describe('Notification tests', () => { - function getRequest(url, { user_id = user.user_id, farm_id = farm.farm_id }, callback) { - chai.request(server).get(url).set('user_id', user_id).set('farm_id', farm_id).end(callback); + function getRequest(url, { user_id = user.user_id, farm_id = farm.farm_id }) { + return chai.request(server).get(url).set('user_id', user_id).set('farm_id', farm_id); } let user; @@ -45,42 +45,35 @@ describe('Notification tests', () => { [userFarm] = await mocks.userFarmFactory({ promisedUser: [user], promisedFarm: [farm] }); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('GET user notifications', () => { - test('Users should get their notifications scoped for all farms', async (done) => { + test('Users should get their notifications scoped for all farms', async () => { const [notification] = await mocks.notification_userFactory({ promisedUserFarm: [userFarm], }); - getRequest('/notification_user', {}, (err, res) => { - expect(err).toBe(null); - expect(res.status).toBe(200); - expect(res.body.length).toBe(1); - expect(res.body[0].user_id).toBe(user.user_id); - expect(res.body[0].notification_id).toBe(notification.notification_id); - done(); - }); + const res = await getRequest('/notification_user', {}); + expect(res.status).toBe(200); + expect(res.body.length).toBe(1); + expect(res.body[0].user_id).toBe(user.user_id); + expect(res.body[0].notification_id).toBe(notification.notification_id); }); - test('Users should get their notifications scoped for their current farm', async (done) => { + test('Users should get their notifications scoped for their current farm', async () => { const [notification] = await mocks.notification_userFactory({ promisedUserFarm: [userFarm], }); - getRequest('/notification_user', {}, (err, res) => { - expect(err).toBe(null); - expect(res.status).toBe(200); - expect(res.body.length).toBe(1); - expect(res.body[0].user_id).toBe(user.user_id); - expect(res.body[0].notification_id).toBe(notification.notification_id); - done(); - }); + const res = await getRequest('/notification_user', {}); + expect(res.status).toBe(200); + expect(res.body.length).toBe(1); + expect(res.body[0].user_id).toBe(user.user_id); + expect(res.body[0].notification_id).toBe(notification.notification_id); }); - test('Users should not get their notifications scoped for farms other than their current farm', async (done) => { + test('Users should not get their notifications scoped for farms other than their current farm', async () => { const [otherFarm] = await mocks.farmFactory(); const [otherUserFarm] = await mocks.userFarmFactory({ promisedUser: [user], @@ -89,15 +82,12 @@ describe('Notification tests', () => { await mocks.notification_userFactory({ promisedUserFarm: [otherUserFarm], }); - getRequest('/notification_user', {}, (err, res) => { - expect(err).toBe(null); - expect(res.status).toBe(200); - expect(res.body.length).toBe(0); - done(); - }); + const res = await getRequest('/notification_user', {}); + expect(res.status).toBe(200); + expect(res.body.length).toBe(0); }); - test('Users are not authorized to get "their" notifications for farms where they are not active', async (done) => { + test('Users are not authorized to get "their" notifications for farms where they are not active', async () => { const [inactiveFarm] = await mocks.farmFactory(); const [inactiveUserFarm] = await mocks.userFarmFactory( { promisedUser: [user], promisedFarm: [inactiveFarm] }, @@ -106,72 +96,62 @@ describe('Notification tests', () => { await mocks.notification_userFactory({ promisedUserFarm: [inactiveUserFarm], }); - getRequest('/notification_user', { farm_id: inactiveFarm.farm_id }, (err, res) => { - expect(err).toBe(null); - expect(res.status).toBe(403); - done(); - }); + const res = await getRequest('/notification_user', { farm_id: inactiveFarm.farm_id }); + expect(res.status).toBe(403); }); }); describe('PATCH user notifications', () => { - function clearAlerts( - notificationIds, - { user_id = user.user_id, farm_id = farm.farm_id }, - callback, - ) { - chai + function clearAlerts(notificationIds, { user_id = user.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .patch('/notification_user/clear_alerts') .set('user_id', user_id) .set('farm_id', farm_id) - .send(notificationIds) - .end(callback); + .send(notificationIds); } - function setStatus(body, { user_id = user.user_id, farm_id = farm.farm_id }, callback) { - chai + function setStatus(body, { user_id = user.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .patch('/notification_user') .set('user_id', user_id) .set('farm_id', farm_id) - .send(body) - .end(callback); + .send(body); } - test('Users can clear alert flag on a set of their notifications', async (done) => { + test('Users can clear alert flag on a set of their notifications', async () => { const [notification] = await mocks.notification_userFactory({ promisedUserFarm: [userFarm], }); expect(notification.alert).toBe(true); - clearAlerts({ notification_ids: [notification.notification_id] }, {}, (err, res) => { - expect(err).toBe(null); - expect(res.status).toBe(200); - getRequest('/notification_user', {}, (_, res) => { - expect(res.body[0].alert).toBe(false); - done(); - }); - }); + const res = await clearAlerts({ notification_ids: [notification.notification_id] }, {}); + expect(res.status).toBe(200); + + { + const res = await getRequest('/notification_user', {}); + expect(res.body[0].alert).toBe(false); + } }); - test('Users can modify the status for a set of their notifications', async (done) => { + test('Users can modify the status for a set of their notifications', async () => { const [notification] = await mocks.notification_userFactory({ promisedUserFarm: [userFarm], }); expect(notification.status).toBe('Unread'); const newStatus = 'Read'; - setStatus( + + const res = await setStatus( { notification_ids: [notification.notification_id], status: newStatus }, {}, - (err, res) => { - expect(err).toBe(null); - expect(res.status).toBe(200); - getRequest('/notification_user', {}, (_, res) => { - expect(res.body[0].status).toBe(newStatus); - done(); - }); - }, ); + + expect(res.status).toBe(200); + + { + const res = await getRequest('/notification_user', {}); + expect(res.body[0].status).toBe(newStatus); + } }); }); }); diff --git a/packages/api/tests/organicCertifierSurvey.test.js b/packages/api/tests/organicCertifierSurvey.test.js index 07a406bf36..6c9917ec3d 100644 --- a/packages/api/tests/organicCertifierSurvey.test.js +++ b/packages/api/tests/organicCertifierSurvey.test.js @@ -51,66 +51,57 @@ describe('organic certification Tests', () => { emailTemplate.sendEmail.mockClear(); }); - function postRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }, callback) { - chai + function postRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post(`/organic_certifier_survey`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function putRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }, callback) { - chai + function putRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .put(`/organic_certifier_survey`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function getExportRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }, callback) { - chai + function getExportRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post(`/organic_certifier_survey/request_export`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function getAllSupportedCertificationsRequest({ farm_id = farm.farm_id }, callback) { - chai + function getAllSupportedCertificationsRequest({ farm_id = farm.farm_id }) { + return chai .request(server) .get(`/organic_certifier_survey/${farm_id}/supported_certifications`) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - function getAllSupportedCertifiersRequest( - { user_id = owner.user_id, farm_id = farm.farm_id }, - callback, - ) { - chai + function getAllSupportedCertifiersRequest({ user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .get(`/organic_certifier_survey/${farm_id}/supported_certifiers`) .set('farm_id', farm_id) - .set('user_id', user_id) - .end(callback); + .set('user_id', user_id); } - function deleteRequest({ user_id = owner.user_id, farm_id = farm.farm_id, survey_id }, callback) { - chai + function deleteRequest({ user_id = owner.user_id, farm_id = farm.farm_id, survey_id }) { + return chai .request(server) .delete(`/organic_certifier_survey/${survey_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } function fakeUserFarm(role = 1) { @@ -128,10 +119,9 @@ describe('organic certification Tests', () => { }; } - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('organicCertifierSurvey Tests', () => { @@ -166,31 +156,25 @@ describe('organic certification Tests', () => { ); }); - test('User should get all supported certifiers', async (done) => { - getAllSupportedCertifiersRequest( - { - user_id: manager.user_id, - }, - (err, res) => { - expect(res.status).toBe(200); - done(); - }, - ); + test('User should get all supported certifiers', async () => { + const res = await getAllSupportedCertifiersRequest({ + user_id: manager.user_id, + }); + + expect(res.status).toBe(200); }); }); describe('Get all supported certifications', () => { - test('User should get all supported certifications', async (done) => { - getAllSupportedCertificationsRequest({}, (err, res) => { - const thirdPartyOrganic = res.body.find( - (cert) => cert.certification_translation_key === 'THIRD_PARTY_ORGANIC', - ); - const pgs = res.body.find((cert) => cert.certification_translation_key === 'PGS'); - expect(res.status).toBe(200); - expect(thirdPartyOrganic.certification_type).toBe('Third-party Organic'); - expect(pgs.certification_type).toBe('Participatory Guarantee System'); - done(); - }); + test('User should get all supported certifications', async () => { + const res = await getAllSupportedCertificationsRequest({}); + const thirdPartyOrganic = res.body.find( + (cert) => cert.certification_translation_key === 'THIRD_PARTY_ORGANIC', + ); + const pgs = res.body.find((cert) => cert.certification_translation_key === 'PGS'); + expect(res.status).toBe(200); + expect(thirdPartyOrganic.certification_type).toBe('Third-party Organic'); + expect(pgs.certification_type).toBe('Participatory Guarantee System'); }); }); }); @@ -327,70 +311,56 @@ describe('organic certification Tests', () => { ); }); - test('Owner should delete a certifier survey', async (done) => { - deleteRequest({ survey_id: organicCertifierSurvey.survey_id }, async (err, res) => { - expect(res.status).toBe(200); - const SurveyRes = await organicCertifierSurveyModel - .query() - .context({ showHidden: true }) - .where('survey_id', organicCertifierSurvey.survey_id); - expect(SurveyRes.length).toBe(1); - expect(SurveyRes[0].deleted).toBe(true); - done(); - }); + test('Owner should delete a certifier survey', async () => { + const res = await deleteRequest({ survey_id: organicCertifierSurvey.survey_id }); + expect(res.status).toBe(200); + const SurveyRes = await organicCertifierSurveyModel + .query() + .context({ showHidden: true }) + .where('survey_id', organicCertifierSurvey.survey_id); + expect(SurveyRes.length).toBe(1); + expect(SurveyRes[0].deleted).toBe(true); }); - test('Manager should delete a certifier survey', async (done) => { - deleteRequest( - { user_id: manager.user_id, survey_id: organicCertifierSurvey.survey_id }, - async (err, res) => { - expect(res.status).toBe(200); - const SurveyRes = await organicCertifierSurveyModel - .query() - .context({ showHidden: true }) - .where('survey_id', organicCertifierSurvey.survey_id); - expect(SurveyRes.length).toBe(1); - expect(SurveyRes[0].deleted).toBe(true); - done(); - }, - ); + test('Manager should delete a certifier survey', async () => { + const res = await deleteRequest({ + user_id: manager.user_id, + survey_id: organicCertifierSurvey.survey_id, + }); + expect(res.status).toBe(200); + const SurveyRes = await organicCertifierSurveyModel + .query() + .context({ showHidden: true }) + .where('survey_id', organicCertifierSurvey.survey_id); + expect(SurveyRes.length).toBe(1); + expect(SurveyRes[0].deleted).toBe(true); }); - test('should return 403 if an unauthorized user tries to delete a certifier survey', async (done) => { - deleteRequest( - { - user_id: unAuthorizedUser.user_id, - survey_id: organicCertifierSurvey.survey_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('should return 403 if an unauthorized user tries to delete a certifier survey', async () => { + const res = await deleteRequest({ + user_id: unAuthorizedUser.user_id, + survey_id: organicCertifierSurvey.survey_id, + }); + + expect(res.status).toBe(403); }); - test('should return 403 if a worker tries to delete a certifier survey', async (done) => { - deleteRequest( - { user_id: worker.user_id, survey_id: organicCertifierSurvey.survey_id }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('should return 403 if a worker tries to delete a certifier survey', async () => { + const res = await deleteRequest({ + user_id: worker.user_id, + survey_id: organicCertifierSurvey.survey_id, + }); + expect(res.status).toBe(403); }); - test('Circumvent authorization by modifying farm_id', async (done) => { - deleteRequest( - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - survey_id: organicCertifierSurvey.survey_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modifying farm_id', async () => { + const res = await deleteRequest({ + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + survey_id: organicCertifierSurvey.survey_id, + }); + + expect(res.status).toBe(403); }); }); }); @@ -402,48 +372,38 @@ describe('organic certification Tests', () => { fakeOrganicCertifierSurvey = getFakeOrganicCertifierSurvey(); }); - test('should return 403 status if headers.farm_id is set to null', async (done) => { + test('should return 403 status if headers.farm_id is set to null', async () => { fakeOrganicCertifierSurvey.farm_id = null; - postRequest(fakeOrganicCertifierSurvey, {}, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await postRequest(fakeOrganicCertifierSurvey, {}); + expect(res.status).toBe(403); }); - test('should return 400 if certification_id and requested_certification are null', async (done) => { + test('should return 400 if certification_id and requested_certification are null', async () => { delete fakeOrganicCertifierSurvey.certification_id; delete fakeOrganicCertifierSurvey.requested_certification; - postRequest(fakeOrganicCertifierSurvey, {}, (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postRequest(fakeOrganicCertifierSurvey, {}); + expect(res.status).toBe(400); }); - test('should return 400 if certification_id and requested_certification are not null', async (done) => { + test('should return 400 if certification_id and requested_certification are not null', async () => { fakeOrganicCertifierSurvey.certification_id = 1; fakeOrganicCertifierSurvey.requested_certification = 'requested'; - postRequest(fakeOrganicCertifierSurvey, {}, (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postRequest(fakeOrganicCertifierSurvey, {}); + expect(res.status).toBe(400); }); - test('should return 400 if certifier_id and requested_certifier are null', async (done) => { + test('should return 400 if certifier_id and requested_certifier are null', async () => { delete fakeOrganicCertifierSurvey.certifier_id; delete fakeOrganicCertifierSurvey.requested_certifier; - postRequest(fakeOrganicCertifierSurvey, {}, (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postRequest(fakeOrganicCertifierSurvey, {}); + expect(res.status).toBe(400); }); - test('should return 400 if certifier_id and requested_certifier are not null', async (done) => { + test('should return 400 if certifier_id and requested_certifier are not null', async () => { fakeOrganicCertifierSurvey.certifier_id = 1; fakeOrganicCertifierSurvey.requested_certifier = 'requested'; - postRequest(fakeOrganicCertifierSurvey, {}, (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postRequest(fakeOrganicCertifierSurvey, {}); + expect(res.status).toBe(400); }); describe('Post organicCertifierSurvey authorization tests', () => { @@ -490,99 +450,76 @@ describe('organic certification Tests', () => { ); }); - test('Owner post certifiers', async (done) => { - postRequest(fakeOrganicCertifierSurvey, {}, async (err, res) => { - expect(res.status).toBe(201); - const organicCertifierSurveys = await organicCertifierSurveyModel - .query() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(organicCertifierSurveys.length).toBe(1); - expect(organicCertifierSurveys[0].created_by_user_id).toBe(owner.user_id); - expect(organicCertifierSurveys[0].certifiers).toEqual( - fakeOrganicCertifierSurvey.certifiers, - ); - done(); - }); - }); - - test('Manager post certifiers', async (done) => { - postRequest( - fakeOrganicCertifierSurvey, - { user_id: manager.user_id }, - async (err, res) => { - expect(res.status).toBe(201); - const organicCertifierSurveys = await organicCertifierSurveyModel - .query() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(organicCertifierSurveys.length).toBe(1); - expect(organicCertifierSurveys[0].created_by_user_id).toBe(manager.user_id); - expect(organicCertifierSurveys[0].certifiers).toEqual( - fakeOrganicCertifierSurvey.certifiers, - ); - done(); - }, + test('Owner post certifiers', async () => { + const res = await postRequest(fakeOrganicCertifierSurvey, {}); + expect(res.status).toBe(201); + const organicCertifierSurveys = await organicCertifierSurveyModel + .query() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(organicCertifierSurveys.length).toBe(1); + expect(organicCertifierSurveys[0].created_by_user_id).toBe(owner.user_id); + expect(organicCertifierSurveys[0].certifiers).toEqual( + fakeOrganicCertifierSurvey.certifiers, ); }); - test('Extension officer post certifiers', async (done) => { - postRequest( - fakeOrganicCertifierSurvey, - { user_id: extensionOfficer.user_id }, - async (err, res) => { - expect(res.status).toBe(201); - const organicCertifierSurveys = await organicCertifierSurveyModel - .query() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(organicCertifierSurveys.length).toBe(1); - expect(organicCertifierSurveys[0].created_by_user_id).toBe(extensionOfficer.user_id); - expect(organicCertifierSurveys[0].certifiers).toEqual( - fakeOrganicCertifierSurvey.certifiers, - ); - done(); - }, + test('Manager post certifiers', async () => { + const res = await postRequest(fakeOrganicCertifierSurvey, { user_id: manager.user_id }); + expect(res.status).toBe(201); + const organicCertifierSurveys = await organicCertifierSurveyModel + .query() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(organicCertifierSurveys.length).toBe(1); + expect(organicCertifierSurveys[0].created_by_user_id).toBe(manager.user_id); + expect(organicCertifierSurveys[0].certifiers).toEqual( + fakeOrganicCertifierSurvey.certifiers, ); }); - test('should return 403 status if organicCertifierSurvey is posted by worker', async (done) => { - postRequest(fakeOrganicCertifierSurvey, { user_id: worker.user_id }, async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): add:organic_certifier_survey', - ); - done(); + test('Extension officer post certifiers', async () => { + const res = await postRequest(fakeOrganicCertifierSurvey, { + user_id: extensionOfficer.user_id, }); + expect(res.status).toBe(201); + const organicCertifierSurveys = await organicCertifierSurveyModel + .query() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(organicCertifierSurveys.length).toBe(1); + expect(organicCertifierSurveys[0].created_by_user_id).toBe(extensionOfficer.user_id); + expect(organicCertifierSurveys[0].certifiers).toEqual( + fakeOrganicCertifierSurvey.certifiers, + ); }); - test('should return 403 status if organicCertifierSurvey is posted by unauthorized user', async (done) => { - postRequest( - fakeOrganicCertifierSurvey, - { user_id: unAuthorizedUser.user_id }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): add:organic_certifier_survey', - ); - done(); - }, + test('should return 403 status if organicCertifierSurvey is posted by worker', async () => { + const res = await postRequest(fakeOrganicCertifierSurvey, { user_id: worker.user_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): add:organic_certifier_survey', ); }); - test('Circumvent authorization by modify farm_id', async (done) => { - postRequest( - fakeOrganicCertifierSurvey, - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, + test('should return 403 status if organicCertifierSurvey is posted by unauthorized user', async () => { + const res = await postRequest(fakeOrganicCertifierSurvey, { + user_id: unAuthorizedUser.user_id, + }); + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): add:organic_certifier_survey', ); }); + + test('Circumvent authorization by modify farm_id', async () => { + const res = await postRequest(fakeOrganicCertifierSurvey, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); + }); }); describe('Put organic certifier survey', () => { let fakeOrganicCertifierSurvey; @@ -598,48 +535,38 @@ describe('organic certification Tests', () => { }; }); - test('should return 403 status if headers.farm_id is set to null', async (done) => { + test('should return 403 status if headers.farm_id is set to null', async () => { fakeOrganicCertifierSurvey.farm_id = null; - putRequest(fakeOrganicCertifierSurvey, {}, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await putRequest(fakeOrganicCertifierSurvey, {}); + expect(res.status).toBe(403); }); - test('should return 400 if certification_id and requested_certification are null', async (done) => { + test('should return 400 if certification_id and requested_certification are null', async () => { delete fakeOrganicCertifierSurvey.certification_id; delete fakeOrganicCertifierSurvey.requested_certification; - putRequest(fakeOrganicCertifierSurvey, {}, (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await putRequest(fakeOrganicCertifierSurvey, {}); + expect(res.status).toBe(400); }); - test('should return 400 if certification_id and requested_certification are not null', async (done) => { + test('should return 400 if certification_id and requested_certification are not null', async () => { fakeOrganicCertifierSurvey.certification_id = 1; fakeOrganicCertifierSurvey.requested_certification = 'requested'; - putRequest(fakeOrganicCertifierSurvey, {}, (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await putRequest(fakeOrganicCertifierSurvey, {}); + expect(res.status).toBe(400); }); - test('should return 400 if certifier_id and requested_certifier are null', async (done) => { + test('should return 400 if certifier_id and requested_certifier are null', async () => { delete fakeOrganicCertifierSurvey.certifier_id; delete fakeOrganicCertifierSurvey.requested_certifier; - putRequest(fakeOrganicCertifierSurvey, {}, (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await putRequest(fakeOrganicCertifierSurvey, {}); + expect(res.status).toBe(400); }); - test('should return 400 if certifier_id and requested_certifier are not null', async (done) => { + test('should return 400 if certifier_id and requested_certifier are not null', async () => { fakeOrganicCertifierSurvey.certifier_id = 1; fakeOrganicCertifierSurvey.requested_certifier = 'requested'; - putRequest(fakeOrganicCertifierSurvey, {}, (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await putRequest(fakeOrganicCertifierSurvey, {}); + expect(res.status).toBe(400); }); describe('Put organicCertifierSurvey authorization tests', () => { @@ -686,100 +613,73 @@ describe('organic certification Tests', () => { ); }); - test('Owner put certifiers', async (done) => { - putRequest(fakeOrganicCertifierSurvey, {}, async (err, res) => { - expect(res.status).toBe(200); - const organicCertifierSurveys = await organicCertifierSurveyModel - .query() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(organicCertifierSurveys.length).toBe(1); - expect(organicCertifierSurveys[0].created_by_user_id).toBe(owner.user_id); - expect(organicCertifierSurveys[0].certifiers).toEqual( - fakeOrganicCertifierSurvey.certifiers, - ); - done(); - }); + test('Owner put certifiers', async () => { + const res = await putRequest(fakeOrganicCertifierSurvey, {}); + expect(res.status).toBe(200); + const organicCertifierSurveys = await organicCertifierSurveyModel + .query() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(organicCertifierSurveys.length).toBe(1); + expect(organicCertifierSurveys[0].created_by_user_id).toBe(owner.user_id); + expect(organicCertifierSurveys[0].certifiers).toEqual( + fakeOrganicCertifierSurvey.certifiers, + ); }); - test('Manager put certifiers', async (done) => { - putRequest( - fakeOrganicCertifierSurvey, - { user_id: manager.user_id }, - async (err, res) => { - expect(res.status).toBe(200); - const organicCertifierSurveys = await organicCertifierSurveyModel - .query() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(organicCertifierSurveys.length).toBe(1); - expect(organicCertifierSurveys[0].certifiers).toEqual( - fakeOrganicCertifierSurvey.certifiers, - ); - done(); - }, + test('Manager put certifiers', async () => { + const res = await putRequest(fakeOrganicCertifierSurvey, { user_id: manager.user_id }); + expect(res.status).toBe(200); + const organicCertifierSurveys = await organicCertifierSurveyModel + .query() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(organicCertifierSurveys.length).toBe(1); + expect(organicCertifierSurveys[0].certifiers).toEqual( + fakeOrganicCertifierSurvey.certifiers, ); }); - test('Extension officer put certifiers', async (done) => { - putRequest( - fakeOrganicCertifierSurvey, - { user_id: extensionOfficer.user_id }, - async (err, res) => { - expect(res.status).toBe(200); - const organicCertifierSurveys = await organicCertifierSurveyModel - .query() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(organicCertifierSurveys.length).toBe(1); - expect(organicCertifierSurveys[0].certifiers).toEqual( - fakeOrganicCertifierSurvey.certifiers, - ); - done(); - }, + test('Extension officer put certifiers', async () => { + const res = await putRequest(fakeOrganicCertifierSurvey, { + user_id: extensionOfficer.user_id, + }); + expect(res.status).toBe(200); + const organicCertifierSurveys = await organicCertifierSurveyModel + .query() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(organicCertifierSurveys.length).toBe(1); + expect(organicCertifierSurveys[0].certifiers).toEqual( + fakeOrganicCertifierSurvey.certifiers, ); }); - test('should return 403 status if organicCertifierSurvey is puted by worker', async (done) => { - putRequest( - fakeOrganicCertifierSurvey, - { user_id: worker.user_id }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): edit:organic_certifier_survey', - ); - done(); - }, + test('should return 403 status if organicCertifierSurvey is puted by worker', async () => { + const res = await putRequest(fakeOrganicCertifierSurvey, { user_id: worker.user_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): edit:organic_certifier_survey', ); }); - test('should return 403 status if organicCertifierSurvey is puted by unauthorized user', async (done) => { - putRequest( - fakeOrganicCertifierSurvey, - { user_id: unAuthorizedUser.user_id }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): edit:organic_certifier_survey', - ); - done(); - }, + test('should return 403 status if organicCertifierSurvey is puted by unauthorized user', async () => { + const res = await putRequest(fakeOrganicCertifierSurvey, { + user_id: unAuthorizedUser.user_id, + }); + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): edit:organic_certifier_survey', ); }); - test('Circumvent authorization by modify farm_id', async (done) => { - putRequest( - fakeOrganicCertifierSurvey, - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modify farm_id', async () => { + const res = await putRequest(fakeOrganicCertifierSurvey, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); }); }); }); @@ -997,7 +897,7 @@ describe('organic certification Tests', () => { const include = scenario.include.transplant_task.transplant_task; test(`getExportRequest transplant task with previous plant_task: should ${ include ? '' : 'not ' - }include crops from transplant tasks ${scenario.title}`, async (done) => { + }include crops from transplant tasks ${scenario.title}`, async () => { await createPlantTask({ due_date: MAY30 }); await createTransplantTask(scenario.options); @@ -1009,22 +909,17 @@ describe('organic certification Tests', () => { promisedField: [location], }); - getExportRequest(exportOptions, exportIds, (err, res) => { - expect(err).toBeNull(); - expect(res.status).toBe(200); - expect(res.body.recordD).toHaveLength(1); - expect(res.body.recordA).toHaveLength(2); - for (const record of res.body.recordA) { - if (record.location_id === location.location_id) { - expect(record.crops.length).toBe( - scenario.include.transplant_task.plant_task ? 1 : 0, - ); - } else { - expect(record.crops.length).toBe(include ? 1 : 0); - } + const res = await getExportRequest(exportOptions, exportIds); + expect(res.status).toBe(200); + expect(res.body.recordD).toHaveLength(1); + expect(res.body.recordA).toHaveLength(2); + for (const record of res.body.recordA) { + if (record.location_id === location.location_id) { + expect(record.crops.length).toBe(scenario.include.transplant_task.plant_task ? 1 : 0); + } else { + expect(record.crops.length).toBe(include ? 1 : 0); } - done(); - }); + } }); } @@ -1032,14 +927,13 @@ describe('organic certification Tests', () => { const include = scenario.include.plant_task; test(`Plant task location: should ${include ? '' : 'not '}include crops from plant tasks ${ scenario.title - }`, async (done) => { + }`, async () => { await createPlantTask(scenario.options); await createManagementTaskWithinReportingPeriod(); const recordA = await getRecordAWithManagementPlans(JUNE30, JUNE01, farm_id); expect(recordA).toHaveLength(1); expect(recordA[0].crops).toHaveLength(include ? 1 : 0); if (include) expect(recordA[0].crops[0]).toEqual(EXPECTED_CROP); - done(); }); } @@ -1047,13 +941,12 @@ describe('organic certification Tests', () => { const include = scenario.include.in_ground; test(`In ground management plan location: should ${ include ? '' : 'not ' - }include crops from in ground management plan location ${scenario.title}`, async (done) => { + }include crops from in ground management plan location ${scenario.title}`, async () => { await createManagementTaskWithinReportingPeriod(); const recordA = await getRecordAWithManagementPlans(JUNE30, JUNE01, farm_id); expect(recordA).toHaveLength(1); expect(recordA[0].crops).toHaveLength(include ? 1 : 0); if (include) expect(recordA[0].crops[0]).toEqual(EXPECTED_CROP); - done(); }); } @@ -1061,18 +954,17 @@ describe('organic certification Tests', () => { const include = scenario.include.no_active_task; test(`No active task: should ${ include ? '' : 'not ' - }include crops from plant task location ${scenario.title}`, async (done) => { + }include crops from plant task location ${scenario.title}`, async () => { await createPlantTask(scenario.options); const recordA = await getRecordAWithManagementPlans(JUNE30, JUNE01, farm_id); expect(recordA).toHaveLength(1); expect(recordA[0].crops).toHaveLength(include ? 1 : 0); if (include) expect(recordA[0].crops[0]).toEqual(EXPECTED_CROP); - done(); }); } for (const scenario of testScenarios) { - test(`Abandoned transplant tasks: should not include crops from abandoned transplant tasks ${scenario.title}`, async (done) => { + test(`Abandoned transplant tasks: should not include crops from abandoned transplant tasks ${scenario.title}`, async () => { await createTransplantTask({ ...scenario.options, abandon_date: `'${JULY01}${START_OF_DAY}'`, @@ -1088,7 +980,6 @@ describe('organic certification Tests', () => { expect(record.crops.length).toBe(0); } } - done(); }); } @@ -1096,7 +987,7 @@ describe('organic certification Tests', () => { const include = scenario.include.transplant_task.transplant_task; test(`Transplant task with previous plant_task: should ${ include ? '' : 'not ' - }include crops from transplant tasks ${scenario.title}`, async (done) => { + }include crops from transplant tasks ${scenario.title}`, async () => { await createPlantTask({ due_date: MAY30 }); await createTransplantTask(scenario.options); @@ -1110,7 +1001,6 @@ describe('organic certification Tests', () => { expect(record.crops.length).toBe(include ? 1 : 0); } } - done(); }); } @@ -1118,7 +1008,7 @@ describe('organic certification Tests', () => { const include = scenario.include.transplant_task.transplant_task; test(`Transplant task with in ground management plan: should ${ include ? '' : 'not ' - }include crops from transplant tasks ${scenario.title}`, async (done) => { + }include crops from transplant tasks ${scenario.title}`, async () => { await createTransplantTask(scenario.options); await createManagementTaskWithinReportingPeriod(); @@ -1131,12 +1021,11 @@ describe('organic certification Tests', () => { expect(record.crops.length).toBe(include ? 1 : 0); } } - done(); }); } for (const scenario of testScenarios) { - test(`should not include crops from abandoned management tasks ${scenario.title}`, async (done) => { + test(`should not include crops from abandoned management tasks ${scenario.title}`, async () => { await createManagementTask({ due_date: JUNE01, abandon_date: `'${JULY01}${START_OF_DAY}'`, @@ -1144,11 +1033,10 @@ describe('organic certification Tests', () => { const recordA = await getRecordAWithManagementPlans(JUNE30, JUNE01, farm_id); expect(recordA).toHaveLength(1); expect(recordA[0].crops).toHaveLength(0); - done(); }); } - test(`should not include crops from in ground management plan pin location`, async (done) => { + test(`should not include crops from in ground management plan pin location`, async () => { await createManagementTaskWithinReportingPeriod(); await knex('planting_management_plan') .where({ planting_management_plan_id }) @@ -1163,52 +1051,46 @@ describe('organic certification Tests', () => { expect(record.name).toBe('45, 45'); } } - done(); }); - test(`No active task: should not include crops from in ground management plan location`, async (done) => { + test(`No active task: should not include crops from in ground management plan location`, async () => { const recordA = await getRecordAWithManagementPlans(JUNE30, JUNE01, farm_id); expect(recordA).toHaveLength(1); expect(recordA[0].crops).toHaveLength(0); - done(); }); - test(`Task before reporting period: should not include crops from in ground management plan location`, async (done) => { + test(`Task before reporting period: should not include crops from in ground management plan location`, async () => { await createTask({ due_date: MAY31 }); const recordA = await getRecordAWithManagementPlans(JUNE30, JUNE01, farm_id); expect(recordA).toHaveLength(1); expect(recordA[0].crops).toHaveLength(0); - done(); }); - test(`Task after reporting period: should not include crops from in ground management plan location`, async (done) => { + test(`Task after reporting period: should not include crops from in ground management plan location`, async () => { await createTask({ complete_date: `'${JULY01}${START_OF_DAY}'` }); const recordA = await getRecordAWithManagementPlans(JUNE30, JUNE01, farm_id); expect(recordA).toHaveLength(1); expect(recordA[0].crops).toHaveLength(0); - done(); }); - test(`Reporting period between two tasks: should include crops from in ground management plan location`, async (done) => { + test(`Reporting period between two tasks: should include crops from in ground management plan location`, async () => { await createManagementTask({ complete_date: `'${MAY31}${START_OF_DAY}'` }); await createManagementTask({ due_date: JULY01 }); const recordA = await getRecordAWithManagementPlans(JUNE30, JUNE01, farm_id); expect(recordA).toHaveLength(1); expect(recordA[0].crops).toHaveLength(1); - done(); }); - test('should not include wild crops for management plan completed before reporting period', async (done) => { + test('should not include wild crops for management plan completed before reporting period', async () => { await knex('management_plan') .where({ management_plan_id }) .update({ complete_date: MAY31 }); const recordA = await getRecordAWithManagementPlans(JUNE30, JUNE01, farm_id); expect(recordA).toHaveLength(1); expect(recordA[0].crops).toHaveLength(0); - done(); }); - test('should include in ground management plan location/transplant task location for management plan completed after the start of reporting period', async (done) => { + test('should include in ground management plan location/transplant task location for management plan completed after the start of reporting period', async () => { await knex('management_plan') .where({ management_plan_id }) .update({ complete_date: JUNE02 }); @@ -1218,10 +1100,9 @@ describe('organic certification Tests', () => { for (const record of recordA) { expect(record.crops).toHaveLength(1); } - done(); }); - test('should include plant_task/transplant_task location for management plan completed after the start of reporting period', async (done) => { + test('should include plant_task/transplant_task location for management plan completed after the start of reporting period', async () => { await knex('management_plan') .where({ management_plan_id }) .update({ complete_date: JUNE02 }); @@ -1232,10 +1113,9 @@ describe('organic certification Tests', () => { for (const record of recordA) { expect(record.crops).toHaveLength(1); } - done(); }); - test('should exclude plant location when there are transplant tasks before start date', async (done) => { + test('should exclude plant location when there are transplant tasks before start date', async () => { await createPlantTask({ due_date: JUNE01 }); await createTransplantTask({ due_date: MAY31 }); await createTransplantTask({ complete_date: JUNE01 }); @@ -1249,10 +1129,9 @@ describe('organic certification Tests', () => { expect(record.crops).toHaveLength(1); } } - done(); }); - test('should not include wild crops for abandoned management plan', async (done) => { + test('should not include wild crops for abandoned management plan', async () => { const [{ management_plan_id }] = await mocks.management_planFactory( { promisedFarm: [{ farm_id }], @@ -1276,10 +1155,9 @@ describe('organic certification Tests', () => { for (const record of recordA) { expect(record.crops).toHaveLength(0); } - done(); }); - test('should not include transplanted crops for abandoned management plan', async (done) => { + test('should not include transplanted crops for abandoned management plan', async () => { const [{ management_plan_id }] = await mocks.management_planFactory( { promisedFarm: [{ farm_id }], @@ -1310,10 +1188,9 @@ describe('organic certification Tests', () => { for (const record of recordA) { expect(record.crops).toHaveLength(0); } - done(); }); - test('should exclude gate, water valve, farm site boundary, fence, surface water, and watercourse locations', async (done) => { + test('should exclude gate, water valve, farm site boundary, fence, surface water, and watercourse locations', async () => { await mocks.farm_site_boundaryFactory({ promisedFarm: [{ farm_id }] }); await mocks.surface_waterFactory({ promisedFarm: [{ farm_id }] }); await mocks.watercourseFactory({ promisedFarm: [{ farm_id }] }); @@ -1322,7 +1199,6 @@ describe('organic certification Tests', () => { await mocks.fenceFactory({ promisedFarm: [{ farm_id }] }); const recordA = await getRecordAWithManagementPlans(JUNE30, JUNE01, farm_id); expect(recordA).toHaveLength(1); - done(); }); const bufferZoneScenarios = [ @@ -1331,7 +1207,7 @@ describe('organic certification Tests', () => { ]; for (const scenario of bufferZoneScenarios) { - test(`should categorize buffer zones ${scenario.title} crops as ${scenario.category}`, async (done) => { + test(`should categorize buffer zones ${scenario.title} crops as ${scenario.category}`, async () => { const [buffer] = await mocks.buffer_zoneFactory({ promisedFarm: [{ farm_id }] }); if (scenario.hasCrops) { @@ -1361,7 +1237,6 @@ describe('organic certification Tests', () => { expect(location.isTransitional).toBeFalsy(); } } - done(); }); } @@ -1484,7 +1359,7 @@ describe('organic certification Tests', () => { ]; for (const { organicHistories, description, organic_status } of organicStatusScenarios) { - test(`${description} => ${organic_status}`, async (done) => { + test(`${description} => ${organic_status}`, async () => { for (const organicHistory of organicHistories) { await mocks.organic_historyFactory( { promisedLocation: [location], promisedField: [location], promisedArea: null }, @@ -1495,12 +1370,11 @@ describe('organic certification Tests', () => { const recordA = await getRecordAWithManagementPlans(JUNE30, JUNE01, farm_id); expect(recordA).toHaveLength(1); expectOrganicStatus(recordA[0], organic_status); - done(); }); } for (const { organicHistories, description, organic_status } of organicStatusScenarios) { - test(`No management plan: ${description} => ${organic_status}`, async (done) => { + test(`No management plan: ${description} => ${organic_status}`, async () => { await knex('planting_management_plan') .where({ planting_management_plan_id }) .update({ location_id: null, pin_coordinate: { lat: 45, lng: 45 } }); @@ -1513,7 +1387,6 @@ describe('organic certification Tests', () => { const recordA = await getRecordAWithManagementPlans(JUNE30, JUNE01, farm_id); expect(recordA).toHaveLength(1); expectOrganicStatus(recordA[0], organic_status); - done(); }); } }); diff --git a/packages/api/tests/organicHistory.test.js b/packages/api/tests/organicHistory.test.js index 4887f335e8..db6a25b898 100644 --- a/packages/api/tests/organicHistory.test.js +++ b/packages/api/tests/organicHistory.test.js @@ -32,15 +32,14 @@ import mocks from './mock.factories.js'; import locationModel from '../src/models/locationModel'; describe('Location organic history tests', () => { - function postRequest(data, farm_id, user_id, callback) { - chai + function postRequest(data, farm_id, user_id) { + return chai .request(server) .post(`/location/organic_history`) .set('Content-Type', 'application/json') .set('farm_id', farm_id) .set('user_id', user_id) - .send(data) - .end(callback); + .send(data); } function fakeUserFarm(role = 1) { @@ -64,44 +63,39 @@ describe('Location organic history tests', () => { [location] = await mocks.locationFactory({ promisedFarm: [farm] }); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('POST to create a new organic history entry', () => { ['field', 'garden', 'greenhouse'].map((type) => { - test(`works for ${type}`, async (done) => { + test(`works for ${type}`, async () => { const something = await mocks[`${type}Factory`]({ promisedLocation: [location], }); const organicHistoryReqBody = mocks.fakeOrganicHistory({ location_id: location.location_id, }); - postRequest(organicHistoryReqBody, farm.farm_id, owner.user_id, async (err, res) => { - expect(res.status).toBe(201); - const organicHistory = await knex('organic_history') - .where({ location_id: location.location_id }) - .first(); - expect(organicHistory.organic_status).toBe(organicHistoryReqBody.organic_status); - done(); - }); + const res = await postRequest(organicHistoryReqBody, farm.farm_id, owner.user_id); + expect(res.status).toBe(201); + const organicHistory = await knex('organic_history') + .where({ location_id: location.location_id }) + .first(); + expect(organicHistory.organic_status).toBe(organicHistoryReqBody.organic_status); }); }); ['buffer_zone', 'gate', 'barn'].map((type) => { - test(`works for ${type}`, async (done) => { + test(`works for ${type}`, async () => { const something = await mocks[`${type}Factory`]({ promisedLocation: [location], }); const organicHistoryReqBody = mocks.fakeOrganicHistory({ location_id: location.location_id, }); - postRequest(organicHistoryReqBody, farm.farm_id, owner.user_id, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postRequest(organicHistoryReqBody, farm.farm_id, owner.user_id); + expect(res.status).toBe(400); }); }); }); diff --git a/packages/api/tests/pesticides.test.js b/packages/api/tests/pesticides.test.js index e5fc444820..670c5ac554 100644 --- a/packages/api/tests/pesticides.test.js +++ b/packages/api/tests/pesticides.test.js @@ -41,39 +41,34 @@ describe('Pesticide Tests', () => { token = global.token; }); - function postRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }, callback) { - chai + function postRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post(`/pesticide`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function getRequest( - { user_id = owner.user_id, farm_id = farm.farm_id, header_farm_id = farm.farm_id }, - callback, - ) { - chai + function getRequest({ + user_id = owner.user_id, + farm_id = farm.farm_id, + header_farm_id = farm.farm_id, + }) { + return chai .request(server) .get(`/pesticide/farm/${header_farm_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - function deleteRequest( - { user_id = owner.user_id, farm_id = farm.farm_id, pesticide_id }, - callback, - ) { - chai + function deleteRequest({ user_id = owner.user_id, farm_id = farm.farm_id, pesticide_id }) { + return chai .request(server) .delete(`/pesticide/${pesticide_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } function fakeUserFarm(role = 1) { @@ -95,10 +90,9 @@ describe('Pesticide Tests', () => { ); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('Get && delete pesticide', () => { @@ -107,7 +101,7 @@ describe('Pesticide Tests', () => { [pesticide] = await mocks.pesticideFactory({ promisedFarm: [farm] }); }); - test('Should filter out deleted pesticides', async (done) => { + test('Should filter out deleted pesticides', async () => { await pesiticideModel .query() .context({ @@ -116,23 +110,19 @@ describe('Pesticide Tests', () => { }) .findById(pesticide.pesticide_id) .delete(); - getRequest({ user_id: owner.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.length).toBe(0); - done(); - }); + const res = await getRequest({ user_id: owner.user_id }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(0); }); - test('Workers should get seeded pesticide', async (done) => { + test('Workers should get seeded pesticide', async () => { let [seedPesticide] = await mocks.pesticideFactory( { promisedFarm: [{ farm_id: null }] }, mocks.fakePesticide(), ); - getRequest({ user_id: owner.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[1].pesticide_id).toBe(seedPesticide.pesticide_id); - done(); - }); + const res = await getRequest({ user_id: owner.user_id }); + expect(res.status).toBe(200); + expect(res.body[1].pesticide_id).toBe(seedPesticide.pesticide_id); }); describe('Get pesticide authorization tests', () => { @@ -161,58 +151,47 @@ describe('Pesticide Tests', () => { ); }); - test('Owner should get pesticide by farm id', async (done) => { - getRequest({ user_id: owner.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].pesticide_id).toBe(pesticide.pesticide_id); - done(); - }); + test('Owner should get pesticide by farm id', async () => { + const res = await getRequest({ user_id: owner.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].pesticide_id).toBe(pesticide.pesticide_id); }); - test('Manager should get pesticide by farm id', async (done) => { - getRequest({ user_id: manager.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].pesticide_id).toBe(pesticide.pesticide_id); - done(); - }); + test('Manager should get pesticide by farm id', async () => { + const res = await getRequest({ user_id: manager.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].pesticide_id).toBe(pesticide.pesticide_id); }); - test('Worker should get pesticide by farm id', async (done) => { - getRequest({ user_id: worker.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].pesticide_id).toBe(pesticide.pesticide_id); - done(); - }); + test('Worker should get pesticide by farm id', async () => { + const res = await getRequest({ user_id: worker.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].pesticide_id).toBe(pesticide.pesticide_id); }); - test('Should get status 403 if an unauthorizedUser tries to get pesticide by farm id', async (done) => { - getRequest({ user_id: unAuthorizedUser.user_id }, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + test('Should get status 403 if an unauthorizedUser tries to get pesticide by farm id', async () => { + const res = await getRequest({ user_id: unAuthorizedUser.user_id }); + expect(res.status).toBe(403); }); - test('Circumvent authorization by modifying farm_id', async (done) => { - getRequest( - { user_id: unAuthorizedUser.user_id, header_farm_id: farmunAuthorizedUser.farm_id }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modifying farm_id', async () => { + const res = await getRequest({ + user_id: unAuthorizedUser.user_id, + header_farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); }); }); describe('Delete fertlizer', function () { - test('should return 403 if user tries to delete a seeded pesticide', async (done) => { + test('should return 403 if user tries to delete a seeded pesticide', async () => { let [seedPesticide] = await mocks.pesticideFactory( { promisedFarm: [{ farm_id: null }] }, mocks.fakePesticide(), ); - deleteRequest({ pesticide_id: seedPesticide.pesticide_id }, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await deleteRequest({ pesticide_id: seedPesticide.pesticide_id }); + expect(res.status).toBe(403); }); describe('Delete fertlizer authorization tests', () => { @@ -241,67 +220,56 @@ describe('Pesticide Tests', () => { ); }); - test('Owner should delete a fertlizer', async (done) => { - deleteRequest({ pesticide_id: pesticide.pesticide_id }, async (err, res) => { - expect(res.status).toBe(200); - const pesticideRes = await pesiticideModel - .query() - .context({ showHidden: true }) - .where('pesticide_id', pesticide.pesticide_id); - expect(pesticideRes.length).toBe(1); - expect(pesticideRes[0].deleted).toBe(true); - done(); - }); + test('Owner should delete a fertlizer', async () => { + const res = await deleteRequest({ pesticide_id: pesticide.pesticide_id }); + expect(res.status).toBe(200); + const pesticideRes = await pesiticideModel + .query() + .context({ showHidden: true }) + .where('pesticide_id', pesticide.pesticide_id); + expect(pesticideRes.length).toBe(1); + expect(pesticideRes[0].deleted).toBe(true); }); - test('Manager should delete a pesticide', async (done) => { - deleteRequest( - { user_id: manager.user_id, pesticide_id: pesticide.pesticide_id }, - async (err, res) => { - expect(res.status).toBe(200); - const pesticideRes = await pesiticideModel - .query() - .context({ showHidden: true }) - .where('pesticide_id', pesticide.pesticide_id); - expect(pesticideRes.length).toBe(1); - expect(pesticideRes[0].deleted).toBe(true); - done(); - }, - ); + test('Manager should delete a pesticide', async () => { + const res = await deleteRequest({ + user_id: manager.user_id, + pesticide_id: pesticide.pesticide_id, + }); + expect(res.status).toBe(200); + const pesticideRes = await pesiticideModel + .query() + .context({ showHidden: true }) + .where('pesticide_id', pesticide.pesticide_id); + expect(pesticideRes.length).toBe(1); + expect(pesticideRes[0].deleted).toBe(true); }); - test('should return 403 if an unauthorized user tries to delete a pesticide', async (done) => { - deleteRequest( - { user_id: unAuthorizedUser.user_id, pesticide_id: pesticide.pesticide_id }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('should return 403 if an unauthorized user tries to delete a pesticide', async () => { + const res = await deleteRequest({ + user_id: unAuthorizedUser.user_id, + pesticide_id: pesticide.pesticide_id, + }); + + expect(res.status).toBe(403); }); - test('should return 403 if a worker tries to delete a pesticide', async (done) => { - deleteRequest( - { user_id: worker.user_id, pesticide_id: pesticide.pesticide_id }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('should return 403 if a worker tries to delete a pesticide', async () => { + const res = await deleteRequest({ + user_id: worker.user_id, + pesticide_id: pesticide.pesticide_id, + }); + expect(res.status).toBe(403); }); - test('Circumvent authorization by modifying farm_id', async (done) => { - deleteRequest( - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - pesticide_id: pesticide.pesticide_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modifying farm_id', async () => { + const res = await deleteRequest({ + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + pesticide_id: pesticide.pesticide_id, + }); + + expect(res.status).toBe(403); }); }); }); @@ -314,12 +282,10 @@ describe('Pesticide Tests', () => { fakePesticide = getfakePesticide(); }); - test('should return 403 status if headers.farm_id is set to null', async (done) => { + test('should return 403 status if headers.farm_id is set to null', async () => { fakePesticide.farm_id = null; - postRequest(fakePesticide, {}, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await postRequest(fakePesticide, {}); + expect(res.status).toBe(403); }); describe('Post pesticide authorization tests', () => { @@ -348,61 +314,51 @@ describe('Pesticide Tests', () => { ); }); - test('Owner should post and get a valid pesticide', async (done) => { - postRequest(fakePesticide, {}, async (err, res) => { - expect(res.status).toBe(201); - const pesticides = await pesiticideModel - .query() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(pesticides.length).toBe(1); - expect(pesticides[0].pesticide_name).toBe(fakePesticide.pesticide_name); - done(); - }); + test('Owner should post and get a valid pesticide', async () => { + const res = await postRequest(fakePesticide, {}); + expect(res.status).toBe(201); + const pesticides = await pesiticideModel + .query() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(pesticides.length).toBe(1); + expect(pesticides[0].pesticide_name).toBe(fakePesticide.pesticide_name); }); - test('Manager should post and get a valid pesticide', async (done) => { - postRequest(fakePesticide, { user_id: manager.user_id }, async (err, res) => { - expect(res.status).toBe(201); - const pesticides = await pesiticideModel - .query() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(pesticides.length).toBe(1); - expect(pesticides[0].pesticide_name).toBe(fakePesticide.pesticide_name); - done(); - }); + test('Manager should post and get a valid pesticide', async () => { + const res = await postRequest(fakePesticide, { user_id: manager.user_id }); + expect(res.status).toBe(201); + const pesticides = await pesiticideModel + .query() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(pesticides.length).toBe(1); + expect(pesticides[0].pesticide_name).toBe(fakePesticide.pesticide_name); }); - test('should return 403 status if pesticide is posted by worker', async (done) => { - postRequest(fakePesticide, { user_id: worker.user_id }, async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): add:pesticides', - ); - done(); - }); + test('should return 403 status if pesticide is posted by worker', async () => { + const res = await postRequest(fakePesticide, { user_id: worker.user_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): add:pesticides', + ); }); - test('should return 403 status if pesticide is posted by unauthorized user', async (done) => { - postRequest(fakePesticide, { user_id: unAuthorizedUser.user_id }, async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): add:pesticides', - ); - done(); - }); + test('should return 403 status if pesticide is posted by unauthorized user', async () => { + const res = await postRequest(fakePesticide, { user_id: unAuthorizedUser.user_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): add:pesticides', + ); }); - test('Circumvent authorization by modify farm_id', async (done) => { - postRequest( - fakePesticide, - { user_id: unAuthorizedUser.user_id, farm_id: farmunAuthorizedUser.farm_id }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modify farm_id', async () => { + const res = await postRequest(fakePesticide, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); }); }); }); diff --git a/packages/api/tests/price.test.js b/packages/api/tests/price.test.js index e88cf13d89..1e0195a7b8 100644 --- a/packages/api/tests/price.test.js +++ b/packages/api/tests/price.test.js @@ -43,49 +43,43 @@ describe('Price Tests', () => { token = global.token; }); - function postPriceRequest( - data, - { user_id = newOwner.user_id, farm_id = farm.farm_id }, - callback, - ) { - chai + function postPriceRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post('/price') .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function putPriceRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { + function putPriceRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { const { price_id } = data; - chai + + return chai .request(server) .put(`/price/${price_id}`) .set('farm_id', farm_id) .set('user_id', user_id) - .send(data) - .end(callback); + .send(data); } - function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { - chai + function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .get(`/price/farm/${farm_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - function deleteRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { + function deleteRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { const { price_id } = data; - chai + + return chai .request(server) .delete(`/price/${price_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } function fakeUserFarm(role = 1) { @@ -127,269 +121,211 @@ describe('Price Tests', () => { [crop] = await mocks.cropFactory({ promisedFarm: [farm] }); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); // POST TESTS describe('Post price tests', () => { - test('Owner should post price', async (done) => { + test('Owner should post price', async () => { const { mainFarm, user } = await returnUserFarms(1); const { crop } = await returnCrop(mainFarm); const price = getFakePrice(crop.crop_id, mainFarm.farm_id); - postPriceRequest( - price, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(201); - const prices = await priceModel.query().where('farm_id', mainFarm.farm_id); - expect(prices.length).toBe(1); - expect(prices[0].price_id).toBe(price.price_id); - done(); - }, - ); + const res = await postPriceRequest(price, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(201); + const prices = await priceModel.query().where('farm_id', mainFarm.farm_id); + expect(prices.length).toBe(1); + expect(prices[0].price_id).toBe(price.price_id); }); - test('Manager should post price', async (done) => { + test('Manager should post price', async () => { const { mainFarm, user } = await returnUserFarms(2); const { crop } = await returnCrop(mainFarm); const price = getFakePrice(crop.crop_id, mainFarm.farm_id); - postPriceRequest( - price, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(201); - const prices = await priceModel.query().where('farm_id', mainFarm.farm_id); - expect(prices.length).toBe(1); - expect(prices[0].price_id).toBe(price.price_id); - done(); - }, - ); + const res = await postPriceRequest(price, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(201); + const prices = await priceModel.query().where('farm_id', mainFarm.farm_id); + expect(prices.length).toBe(1); + expect(prices[0].price_id).toBe(price.price_id); }); - test('Should return 403 when worker tries to post price', async (done) => { + test('Should return 403 when worker tries to post price', async () => { const { mainFarm, user } = await returnUserFarms(3); const { crop } = await returnCrop(mainFarm); const price = getFakePrice(crop.crop_id, mainFarm.farm_id); - postPriceRequest( - price, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('User does not have the following permission(s): add:prices'); - done(); - }, - ); + const res = await postPriceRequest(price, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): add:prices'); }); - test('Should return 403 when unauthorized user tries to post price', async (done) => { + test('Should return 403 when unauthorized user tries to post price', async () => { const { mainFarm, user } = await returnUserFarms(1); const { price } = await returnPrice(mainFarm); const [unAuthorizedUser] = await mocks.usersFactory(); - postPriceRequest( - price, - { user_id: unAuthorizedUser.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('User does not have the following permission(s): add:prices'); - done(); - }, - ); + const res = await postPriceRequest(price, { + user_id: unAuthorizedUser.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): add:prices'); }); }); // PUT TESTS describe('Put price tests', () => { - test('Owner should update value_$/kg', async (done) => { + test('Owner should update value_$/kg', async () => { const { mainFarm, user } = await returnUserFarms(1); const { price } = await returnPrice(mainFarm); price['value_$/kg'] = 8; - putPriceRequest( - price, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0]['value_$/kg']).toBe(8); - done(); - }, - ); + const res = await putPriceRequest(price, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(200); + expect(res.body[0]['value_$/kg']).toBe(8); }); - test('Manager should update value_$/kg', async (done) => { + test('Manager should update value_$/kg', async () => { const { mainFarm, user } = await returnUserFarms(2); const { price } = await returnPrice(mainFarm); price['value_$/kg'] = 22; - putPriceRequest( - price, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0]['value_$/kg']).toBe(22); - done(); - }, - ); + const res = await putPriceRequest(price, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(200); + expect(res.body[0]['value_$/kg']).toBe(22); }); - test('Should return 403 when a worker tries to edit value_$/kg', async (done) => { + test('Should return 403 when a worker tries to edit value_$/kg', async () => { const { mainFarm, user } = await returnUserFarms(3); const { price } = await returnPrice(mainFarm); price['value_$/kg'] = 100; - putPriceRequest( - price, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): edit:prices', - ); - done(); - }, - ); + const res = await putPriceRequest(price, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): edit:prices'); }); - test('Should return 403 when a unauthorized user tries to edit value_$/kg', async (done) => { + test('Should return 403 when a unauthorized user tries to edit value_$/kg', async () => { const { mainFarm, user } = await returnUserFarms(1); const { price } = await returnPrice(mainFarm); const [unAuthorizedUser] = await mocks.usersFactory(); price['quantity_kg/m2'] = 4; - putPriceRequest(price, { user_id: unAuthorizedUser.user_id }, async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('user not authorized to access farm'); - done(); - }); + const res = await putPriceRequest(price, { user_id: unAuthorizedUser.user_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe('user not authorized to access farm'); }); }); // GET TESTS describe('Get price tests', () => { - test('Owner should get price by farm id', async (done) => { + test('Owner should get price by farm id', async () => { const { mainFarm, user } = await returnUserFarms(1); const { price } = await returnPrice(mainFarm); - getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].farm_id).toBe(price.farm_id); - done(); - }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + expect(res.status).toBe(200); + expect(res.body[0].farm_id).toBe(price.farm_id); }); - test('Manager should get price by farm id', async (done) => { + test('Manager should get price by farm id', async () => { const { mainFarm, user } = await returnUserFarms(2); const { price } = await returnPrice(mainFarm); - getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].farm_id).toBe(price.farm_id); - done(); - }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + expect(res.status).toBe(200); + expect(res.body[0].farm_id).toBe(price.farm_id); }); - test('Worker should get price by farm id', async (done) => { + test('Worker should get price by farm id', async () => { const { mainFarm, user } = await returnUserFarms(3); const { price } = await returnPrice(mainFarm); - getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].farm_id).toBe(price.farm_id); - done(); - }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + expect(res.status).toBe(200); + expect(res.body[0].farm_id).toBe(price.farm_id); }); - test('Should get status 403 if an unauthorizedUser tries to get price by farm id', async (done) => { + test('Should get status 403 if an unauthorizedUser tries to get price by farm id', async () => { const { mainFarm, user } = await returnUserFarms(1); const [unAuthorizedUser] = await mocks.usersFactory(); - getRequest({ user_id: unAuthorizedUser.user_id, farm_id: mainFarm.farm_id }, (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('User does not have the following permission(s): get:prices'); - done(); + const res = await getRequest({ + user_id: unAuthorizedUser.user_id, + farm_id: mainFarm.farm_id, }); + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): get:prices'); }); }); // DELETE TESTS describe('Delete price tests', () => { - test('Owner should delete their price', async (done) => { + test('Owner should delete their price', async () => { const { mainFarm, user } = await returnUserFarms(1); const { price } = await returnPrice(mainFarm); - deleteRequest( - price, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - const [deletedPrice] = await priceModel.query().where('price_id', price.price_id); - expect(deletedPrice.deleted).toBe(true); - done(); - }, - ); + const res = await deleteRequest(price, { user_id: user.user_id, farm_id: mainFarm.farm_id }); + expect(res.status).toBe(200); + const [deletedPrice] = await priceModel.query().where('price_id', price.price_id); + expect(deletedPrice.deleted).toBe(true); }); - test('Manager should delete their price', async (done) => { + test('Manager should delete their price', async () => { const { mainFarm, user } = await returnUserFarms(2); const { price } = await returnPrice(mainFarm); - deleteRequest( - price, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - const [deletedPrice] = await priceModel.query().where('price_id', price.price_id); - expect(deletedPrice.deleted).toBe(true); - done(); - }, - ); + const res = await deleteRequest(price, { user_id: user.user_id, farm_id: mainFarm.farm_id }); + expect(res.status).toBe(200); + const [deletedPrice] = await priceModel.query().where('price_id', price.price_id); + expect(deletedPrice.deleted).toBe(true); }); - test('Should return 403 if a worker tries to delete a price', async (done) => { + test('Should return 403 if a worker tries to delete a price', async () => { const { mainFarm, user } = await returnUserFarms(3); const { price } = await returnPrice(mainFarm); - deleteRequest( - price, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): delete:prices', - ); - done(); - }, - ); + const res = await deleteRequest(price, { user_id: user.user_id, farm_id: mainFarm.farm_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): delete:prices'); }); - test('Should get status 403 if an unauthorizedUser tries to delete price', async (done) => { + test('Should get status 403 if an unauthorizedUser tries to delete price', async () => { const { mainFarm, user } = await returnUserFarms(1); const { price } = await returnPrice(mainFarm); const [unAuthorizedUser] = await mocks.usersFactory(); - deleteRequest( - price, - { - user_id: unAuthorizedUser.user_id, - farm_id: mainFarm.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): delete:prices', - ); - done(); - }, - ); + const res = await deleteRequest(price, { + user_id: unAuthorizedUser.user_id, + farm_id: mainFarm.farm_id, + }); + + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): delete:prices'); }); }); }); diff --git a/packages/api/tests/product.test.js b/packages/api/tests/product.test.js index c9f6b8f5c0..2f4fa891c8 100644 --- a/packages/api/tests/product.test.js +++ b/packages/api/tests/product.test.js @@ -36,24 +36,22 @@ import soilAmendmentProductModel from '../src/models/soilAmendmentProductModel.j describe('Product Tests', () => { // let middleware; - function postProductRequest(data, { user_id, farm_id }, callback) { - chai + function postProductRequest(data, { user_id, farm_id }) { + return chai .request(server) .post(`/product`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function getRequest({ user_id, farm_id }, callback) { - chai + function getRequest({ user_id, farm_id }) { + return chai .request(server) .get(`/product/farm/${farm_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } async function patchRequest(data, product_id, { user_id, farm_id }) { @@ -93,10 +91,8 @@ describe('Product Tests', () => { } } - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); - await knex.destroy(); - done(); }); describe('Get products ', () => { @@ -106,23 +102,21 @@ describe('Product Tests', () => { [userFarmToTest] = await mocks.userFarmFactory({}, fakeUserFarm()); }); - test('Should get products on my farm', async (done) => { + test('Should get products on my farm', async () => { await Promise.all( [...Array(10)].map(() => mocks.productFactory({ promisedFarm: [{ farm_id: userFarmToTest.farm_id }] }), ), ); - getRequest( - { user_id: userFarmToTest.user_id, farm_id: userFarmToTest.farm_id }, - (err, res) => { - expect(res.status).toBe(200); - expect(res.body.length).toBe(10); - done(); - }, - ); + const res = await getRequest({ + user_id: userFarmToTest.user_id, + farm_id: userFarmToTest.farm_id, + }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(10); }); - test('Should get products on my farm but not default products', async (done) => { + test('Should get products on my farm but not default products', async () => { await Promise.all( [...Array(10)].map(() => mocks.productFactory({ promisedFarm: [{ farm_id: userFarmToTest.farm_id }] }), @@ -131,17 +125,15 @@ describe('Product Tests', () => { await Promise.all( [...Array(10)].map(() => mocks.productFactory({ promisedFarm: [{ farm_id: null }] })), ); - getRequest( - { user_id: userFarmToTest.user_id, farm_id: userFarmToTest.farm_id }, - (err, res) => { - expect(res.status).toBe(200); - expect(res.body.length).toBe(10); - done(); - }, - ); + const res = await getRequest({ + user_id: userFarmToTest.user_id, + farm_id: userFarmToTest.farm_id, + }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(10); }); - test('should get products on my farm, but not my other farms or defaults', async (done) => { + test('should get products on my farm, but not my other farms or defaults', async () => { const [otherUserFarm] = await mocks.userFarmFactory({ promisedUser: [{ user_id: userFarmToTest.user_id }], }); @@ -158,16 +150,14 @@ describe('Product Tests', () => { mocks.productFactory({ promisedFarm: [{ farm_id: otherUserFarm.farm_id }] }), ), ); - getRequest( - { user_id: userFarmToTest.user_id, farm_id: userFarmToTest.farm_id }, - (err, res) => { - expect(res.status).toBe(200); - expect(res.body.length).toBe(10); - const ids = res.body.map(({ product_id }) => product_id); - expect(otherFarmProducts.some(({ product_id }) => ids.includes(product_id))).toBe(false); - done(); - }, - ); + const res = await getRequest({ + user_id: userFarmToTest.user_id, + farm_id: userFarmToTest.farm_id, + }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(10); + const ids = res.body.map(({ product_id }) => product_id); + expect(otherFarmProducts.some(({ product_id }) => ids.includes(product_id))).toBe(false); }); }); @@ -178,41 +168,35 @@ describe('Product Tests', () => { prod = mocks.fakeProduct(); }); - test('should return 403 status if headers.farm_id is set to null', async (done) => { + test('should return 403 status if headers.farm_id is set to null', async () => { const [userFarm] = await mocks.userFarmFactory({}, fakeUserFarm()); - postProductRequest(prod, { user_id: userFarm.user_id, farm_id: null }, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await postProductRequest(prod, { user_id: userFarm.user_id, farm_id: null }); + expect(res.status).toBe(403); }); - test('should successfully create a product with minimal data', async (done) => { + test('should successfully create a product with minimal data', async () => { const [userFarm] = await mocks.userFarmFactory({}, fakeUserFarm()); prod.farm_id = userFarm.farm_id; - postProductRequest(prod, userFarm, (err, res) => { - expect(res.status).toBe(201); - done(); - }); + const res = await postProductRequest(prod, userFarm); + expect(res.status).toBe(201); }); - test('All users should be able to post and get a product', async (done) => { + test('All users should be able to post and get a product', async () => { const allUserRoles = [1, 2, 3, 5]; for (const role of allUserRoles) { const [userFarm] = await mocks.userFarmFactory({}, fakeUserFarm(role)); prod.farm_id = userFarm.farm_id; - postProductRequest(prod, userFarm, async (err, res) => { - expect(res.status).toBe(201); - const productsSaved = await productModel - .query() - .context({ showHidden: true }) - .where('farm_id', userFarm.farm_id); - expect(productsSaved.length).toBe(1); - done(); - }); + const res = await postProductRequest(prod, userFarm); + expect(res.status).toBe(201); + const productsSaved = await productModel + .query() + .context({ showHidden: true }) + .where('farm_id', userFarm.farm_id); + expect(productsSaved.length).toBe(1); } }); - test('should return 400 if elemental value is provided without elemental_unit', async (done) => { + test('should return 400 if elemental value is provided without elemental_unit', async () => { const [userFarm] = await mocks.userFarmFactory({}, fakeUserFarm()); const npkProduct = mocks.fakeProduct({ @@ -224,13 +208,11 @@ describe('Product Tests', () => { }, }); - postProductRequest(npkProduct, userFarm, (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postProductRequest(npkProduct, userFarm); + expect(res.status).toBe(400); }); - test('should return 400 if elemental_unit is percent and n + p + k > 100', async (done) => { + test('should return 400 if elemental_unit is percent and n + p + k > 100', async () => { const [userFarm] = await mocks.userFarmFactory({}, fakeUserFarm()); const npkProduct = mocks.fakeProduct({ @@ -243,13 +225,11 @@ describe('Product Tests', () => { }, }); - postProductRequest(npkProduct, userFarm, (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postProductRequest(npkProduct, userFarm); + expect(res.status).toBe(400); }); - test('should return 409 conflict if a product is created with the same name as an existing product', async (done) => { + test('should return 409 conflict if a product is created with the same name as an existing product', async () => { const [userFarm] = await mocks.userFarmFactory({}, fakeUserFarm()); const fertiliserProductA = mocks.fakeProduct({ @@ -263,17 +243,14 @@ describe('Product Tests', () => { await createProductInDatabase(userFarm, fertiliserProductA); - postProductRequest( + const res = await postProductRequest( { ...fertiliserProductA, ...soilAmendmentProductDetails }, userFarm, - (err, res) => { - expect(res.status).toBe(409); - done(); - }, ); + expect(res.status).toBe(409); }); - test('should successfully populate soil_amendment_product table', async (done) => { + test('should successfully populate soil_amendment_product table', async () => { const [userFarm] = await mocks.userFarmFactory({}, fakeUserFarm()); const soilAmendmentProduct = mocks.fakeProduct({ @@ -287,25 +264,22 @@ describe('Product Tests', () => { }, }); - postProductRequest(soilAmendmentProduct, userFarm, async (err, res) => { - expect(res.status).toBe(201); - - const [productRecord] = await productModel - .query() - .context({ showHidden: true }) - .where('farm_id', userFarm.farm_id); + const res = await postProductRequest(soilAmendmentProduct, userFarm); + expect(res.status).toBe(201); - const [soilAmendmentProductRecord] = await soilAmendmentProductModel - .query() - .where({ product_id: productRecord.product_id }); + const [productRecord] = await productModel + .query() + .context({ showHidden: true }) + .where('farm_id', userFarm.farm_id); - expect(soilAmendmentProductRecord.n).toBe(1); - expect(soilAmendmentProductRecord.p).toBe(2); - expect(soilAmendmentProductRecord.k).toBe(1); - expect(soilAmendmentProductRecord.elemental_unit).toBe('ratio'); + const [soilAmendmentProductRecord] = await soilAmendmentProductModel + .query() + .where({ product_id: productRecord.product_id }); - done(); - }); + expect(soilAmendmentProductRecord.n).toBe(1); + expect(soilAmendmentProductRecord.p).toBe(2); + expect(soilAmendmentProductRecord.k).toBe(1); + expect(soilAmendmentProductRecord.elemental_unit).toBe('ratio'); }); }); diff --git a/packages/api/tests/revenue_type.test.js b/packages/api/tests/revenue_type.test.js index b25ee71b15..5e9f776736 100644 --- a/packages/api/tests/revenue_type.test.js +++ b/packages/api/tests/revenue_type.test.js @@ -45,62 +45,47 @@ describe('Revenue Type Tests', () => { // FUNCTIONS - function postRevenueTypeRequest( - data, - { user_id = newOwner.user_id, farm_id = farm.farm_id }, - callback, - ) { - chai + function postRevenueTypeRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post(`/revenue_type`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - const postRevenueTypeRequestAsPromise = util.promisify(postRevenueTypeRequest); - - function patchRevenueTypeRequest( - data, - { user_id = newOwner.user_id, farm_id = farm.farm_id }, - callback, - ) { - chai + + function patchRevenueTypeRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .patch(`/revenue_type/${data.revenue_type_id}`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - const patchRevenueTypeRequestAsPromise = util.promisify(patchRevenueTypeRequest); function fakeUserFarm(role = 1) { return { ...mocks.fakeUserFarm(), role_id: role }; } - function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { - chai + function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .get(`/revenue_type/farm/${farm_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - const getRequestAsPromise = util.promisify(getRequest); - function deleteRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { + function deleteRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { const { revenue_type_id } = data; - chai + + return chai .request(server) .delete(`/revenue_type/${revenue_type_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - const deleteRequestAsPromise = util.promisify(deleteRequest); async function returnUserFarms(role) { const [mainFarm] = await mocks.farmFactory(); @@ -144,10 +129,9 @@ describe('Revenue Type Tests', () => { [newOwner] = await mocks.usersFactory(); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); // POST TESTS @@ -156,7 +140,7 @@ describe('Revenue Type Tests', () => { const { mainFarm, user } = await returnUserFarms(1); const revenue_type = getFakeRevenueType(mainFarm.farm_id); - const res = await postRevenueTypeRequestAsPromise(revenue_type, { + const res = await postRevenueTypeRequest(revenue_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -174,7 +158,7 @@ describe('Revenue Type Tests', () => { const { mainFarm, user } = await returnUserFarms(2); const revenue_type = getFakeRevenueType(mainFarm.farm_id); - const res = await postRevenueTypeRequestAsPromise(revenue_type, { + const res = await postRevenueTypeRequest(revenue_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -192,7 +176,7 @@ describe('Revenue Type Tests', () => { const { mainFarm, user } = await returnUserFarms(3); const revenue_type = getFakeRevenueType(mainFarm.farm_id); - const res = await postRevenueTypeRequestAsPromise(revenue_type, { + const res = await postRevenueTypeRequest(revenue_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -208,7 +192,7 @@ describe('Revenue Type Tests', () => { const revenue_type = getFakeRevenueType(mainFarm.farm_id); const [unAuthorizedUser] = await mocks.usersFactory(); - const res = await postRevenueTypeRequestAsPromise(revenue_type, { + const res = await postRevenueTypeRequest(revenue_type, { user_id: unAuthorizedUser.user_id, farm_id: mainFarm.farm_id, }); @@ -226,7 +210,7 @@ describe('Revenue Type Tests', () => { const { mainFarm, user } = await returnUserFarms(1); const revenue = await returnRevenueType(mainFarm); - const res = await getRequestAsPromise({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); expect(res.status).toBe(200); expect(res.body[0].farm_id).toBe(revenue.revenue_type.farm_id); }); @@ -235,7 +219,7 @@ describe('Revenue Type Tests', () => { const { mainFarm, user } = await returnUserFarms(2); const revenue = await returnRevenueType(mainFarm); - const res = await getRequestAsPromise({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); expect(res.status).toBe(200); expect(res.body[0].farm_id).toBe(revenue.revenue_type.farm_id); }); @@ -244,7 +228,7 @@ describe('Revenue Type Tests', () => { const { mainFarm, user } = await returnUserFarms(3); const revenue = await returnRevenueType(mainFarm); - const res = await getRequestAsPromise({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); expect(res.status).toBe(200); expect(res.body[0].farm_id).toBe(revenue.revenue_type.farm_id); }); @@ -254,7 +238,7 @@ describe('Revenue Type Tests', () => { const revenue = await returnRevenueType(mainFarm); const [unAuthorizedUser] = await mocks.usersFactory(); - const res = await getRequestAsPromise({ + const res = await getRequest({ user_id: unAuthorizedUser.user_id, farm_id: mainFarm.farm_id, }); @@ -270,7 +254,7 @@ describe('Revenue Type Tests', () => { test('Owner should get 403 if they try to delete default revenue type', async () => { const { mainFarm, user } = await returnUserFarms(1); const revenue = await returnDefaultRevenueType(); - const res = await deleteRequestAsPromise(revenue.revenue_type, { user_id: revenue.user_id }); + const res = await deleteRequest(revenue.revenue_type, { user_id: revenue.user_id }); expect(res.status).toBe(403); }); @@ -278,7 +262,7 @@ describe('Revenue Type Tests', () => { const { mainFarm, user } = await returnUserFarms(2); const revenue = await returnDefaultRevenueType(); - const res = await deleteRequestAsPromise(revenue.revenue_type, { user_id: user.user_id }); + const res = await deleteRequest(revenue.revenue_type, { user_id: user.user_id }); expect(res.status).toBe(403); }); @@ -286,7 +270,7 @@ describe('Revenue Type Tests', () => { const { mainFarm, user } = await returnUserFarms(3); const revenue = await returnDefaultRevenueType(); - const res = await deleteRequestAsPromise(revenue.revenue_type, { user_id: user.user_id }); + const res = await deleteRequest(revenue.revenue_type, { user_id: user.user_id }); expect(res.status).toBe(403); }); @@ -295,7 +279,7 @@ describe('Revenue Type Tests', () => { const revenue = await returnDefaultRevenueType(); const [unAuthorizedUser] = await mocks.usersFactory(); - const res = await deleteRequestAsPromise(revenue.revenue_type, { + const res = await deleteRequest(revenue.revenue_type, { user_id: unAuthorizedUser.user_id, }); expect(res.status).toBe(403); @@ -308,7 +292,7 @@ describe('Revenue Type Tests', () => { const { mainFarm, user } = await returnUserFarms(1); const revenue = await returnRevenueType(mainFarm); - const res = await deleteRequestAsPromise(revenue.revenue_type, { + const res = await deleteRequest(revenue.revenue_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -325,7 +309,7 @@ describe('Revenue Type Tests', () => { const { mainFarm, user } = await returnUserFarms(2); const revenue = await returnRevenueType(mainFarm); - const res = await deleteRequestAsPromise(revenue.revenue_type, { + const res = await deleteRequest(revenue.revenue_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -342,7 +326,7 @@ describe('Revenue Type Tests', () => { const { mainFarm, user } = await returnUserFarms(3); const revenue = await returnRevenueType(mainFarm); - const res = await deleteRequestAsPromise(revenue.revenue_type, { + const res = await deleteRequest(revenue.revenue_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -358,7 +342,7 @@ describe('Revenue Type Tests', () => { const [unAuthorizedUser] = await mocks.usersFactory(); const revenue = await returnRevenueType(mainFarm); - const res = await deleteRequestAsPromise(revenue.revenue_type, { + const res = await deleteRequest(revenue.revenue_type, { user_id: unAuthorizedUser.user_id, farm_id: mainFarm.farm_id, }); @@ -387,7 +371,7 @@ describe('Revenue Type Tests', () => { associatedSale, ); - const res = await deleteRequestAsPromise(revenue_type, { + const res = await deleteRequest(revenue_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -419,7 +403,7 @@ describe('Revenue Type Tests', () => { associatedDeletedSale, ); - const res = await deleteRequestAsPromise(revenue_type, { + const res = await deleteRequest(revenue_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -442,7 +426,7 @@ describe('Revenue Type Tests', () => { const { mainFarm, user } = await returnUserFarms(1); const revenue = await returnRevenueType(mainFarm); - const res = await patchRevenueTypeRequestAsPromise(revenue.revenue_type, { + const res = await patchRevenueTypeRequest(revenue.revenue_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -460,7 +444,7 @@ describe('Revenue Type Tests', () => { const { mainFarm, user } = await returnUserFarms(2); const revenue = await returnRevenueType(mainFarm); - const res = await patchRevenueTypeRequestAsPromise(revenue.revenue_type, { + const res = await patchRevenueTypeRequest(revenue.revenue_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -478,7 +462,7 @@ describe('Revenue Type Tests', () => { const { mainFarm, user } = await returnUserFarms(3); const revenue = await returnRevenueType(mainFarm); - const res = await patchRevenueTypeRequestAsPromise(revenue.revenue_type, { + const res = await patchRevenueTypeRequest(revenue.revenue_type, { user_id: user.user_id, farm_id: mainFarm.farm_id, }); @@ -494,7 +478,7 @@ describe('Revenue Type Tests', () => { const revenue = await returnRevenueType(mainFarm); const [unAuthorizedUser] = await mocks.usersFactory(); - const res = await patchRevenueTypeRequestAsPromise(revenue.revenue_type, { + const res = await patchRevenueTypeRequest(revenue.revenue_type, { user_id: unAuthorizedUser.user_id, farm_id: mainFarm.farm_id, }); diff --git a/packages/api/tests/sale.test.js b/packages/api/tests/sale.test.js index e6663468eb..b6e1b99b97 100644 --- a/packages/api/tests/sale.test.js +++ b/packages/api/tests/sale.test.js @@ -49,51 +49,43 @@ describe('Sale Tests', () => { await mocks.populateDefaultRevenueTypes(); }); - function postSaleRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }, callback) { - chai + function postSaleRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post(`/sale`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function getRequest( - { user_id = owner.user_id, farm_id = farm.farm_id, farm_id_in_params = farm.farm_id }, - callback, - ) { - chai + function getRequest({ + user_id = owner.user_id, + farm_id = farm.farm_id, + farm_id_in_params = farm.farm_id, + }) { + return chai .request(server) .get(`/sale/${farm_id_in_params}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - function deleteRequest({ user_id = owner.user_id, farm_id = farm.farm_id, sale_id }, callback) { - chai + function deleteRequest({ user_id = owner.user_id, farm_id = farm.farm_id, sale_id }) { + return chai .request(server) .delete(`/sale/${sale_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - function patchRequest( - data, - sale_id, - { user_id = owner.user_id, farm_id = farm.farm_id }, - callback, - ) { - chai + function patchRequest(data, sale_id, { user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .patch(`/sale/${sale_id}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } function fakeUserFarm(role = 1) { @@ -114,10 +106,9 @@ describe('Sale Tests', () => { [cropVariety] = await mocks.crop_varietyFactory({ promisedFarm: [farm], promisedCrop: [crop] }); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('Get && delete sale', () => { @@ -141,13 +132,11 @@ describe('Sale Tests', () => { }); }); - test('Should filter out deleted sale', async (done) => { + test('Should filter out deleted sale', async () => { await saleModel.query().context(owner).findById(sale.sale_id).delete(); - getRequest({ user_id: owner.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.length).toBe(0); - done(); - }); + const res = await getRequest({ user_id: owner.user_id }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(0); }); describe('Get sale authorization tests', () => { @@ -185,61 +174,43 @@ describe('Sale Tests', () => { ); }); - test('Owner should get sale by farm id', async (done) => { - getRequest({ user_id: owner.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].sale_id).toBe(sale.sale_id); - expect(res.body[0].crop_variety_sale.length).toBe(2); - expect(res.body[0].crop_variety_sale[1].crop_variety_id).toBe( - cropVariety1.crop_variety_id, - ); - done(); - }); + test('Owner should get sale by farm id', async () => { + const res = await getRequest({ user_id: owner.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].sale_id).toBe(sale.sale_id); + expect(res.body[0].crop_variety_sale.length).toBe(2); + expect(res.body[0].crop_variety_sale[1].crop_variety_id).toBe(cropVariety1.crop_variety_id); }); - test('Manager should get sale by farm id', async (done) => { - getRequest({ user_id: manager.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].sale_id).toBe(sale.sale_id); - expect(res.body[0].crop_variety_sale.length).toBe(2); - expect(res.body[0].crop_variety_sale[1].crop_variety_id).toBe( - cropVariety1.crop_variety_id, - ); - done(); - }); + test('Manager should get sale by farm id', async () => { + const res = await getRequest({ user_id: manager.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].sale_id).toBe(sale.sale_id); + expect(res.body[0].crop_variety_sale.length).toBe(2); + expect(res.body[0].crop_variety_sale[1].crop_variety_id).toBe(cropVariety1.crop_variety_id); }); - test('Worker should get sale by farm id', async (done) => { - getRequest({ user_id: newWorker.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].sale_id).toBe(sale.sale_id); - expect(res.body[0].crop_variety_sale.length).toBe(2); - expect(res.body[0].crop_variety_sale[1].crop_variety_id).toBe( - cropVariety1.crop_variety_id, - ); - done(); - }); + test('Worker should get sale by farm id', async () => { + const res = await getRequest({ user_id: newWorker.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].sale_id).toBe(sale.sale_id); + expect(res.body[0].crop_variety_sale.length).toBe(2); + expect(res.body[0].crop_variety_sale[1].crop_variety_id).toBe(cropVariety1.crop_variety_id); }); - test('Should get status 403 if an unauthorizedUser tries to get sale by farm id', async (done) => { - getRequest({ user_id: unAuthorizedUser.user_id }, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + test('Should get status 403 if an unauthorizedUser tries to get sale by farm id', async () => { + const res = await getRequest({ user_id: unAuthorizedUser.user_id }); + expect(res.status).toBe(403); }); - test('Circumvent authorization by modifying farm_id', async (done) => { - getRequest( - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - farm_id_in_params: farm.farm_id, - }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modifying farm_id', async () => { + const res = await getRequest({ + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + farm_id_in_params: farm.farm_id, + }); + + expect(res.status).toBe(403); }); }); @@ -281,89 +252,69 @@ describe('Sale Tests', () => { ); }); - test('Owner should delete a sale', async (done) => { - deleteRequest({ sale_id: sale.sale_id }, async (err, res) => { - expect(res.status).toBe(200); - const saleRes = await saleModel - .query() - .context({ showHidden: true }) - .where('sale_id', sale.sale_id); - expect(saleRes.length).toBe(1); - expect(saleRes[0].deleted).toBe(true); - // const saleRes = await saleModel.query().whereNotDeleted().where('sale_id', sale.sale_id); - // expect(saleRes.length).toBe(0); - done(); - }); + test('Owner should delete a sale', async () => { + const res = await deleteRequest({ sale_id: sale.sale_id }); + expect(res.status).toBe(200); + const saleRes = await saleModel + .query() + .context({ showHidden: true }) + .where('sale_id', sale.sale_id); + expect(saleRes.length).toBe(1); + expect(saleRes[0].deleted).toBe(true); }); - test('Manager should delete a sale', async (done) => { - deleteRequest({ user_id: manager.user_id, sale_id: sale.sale_id }, async (err, res) => { - expect(res.status).toBe(200); - const saleRes = await saleModel - .query() - .context({ showHidden: true }) - .where('sale_id', sale.sale_id); - expect(saleRes.length).toBe(1); - expect(saleRes[0].deleted).toBe(true); - done(); - }); + test('Manager should delete a sale', async () => { + const res = await deleteRequest({ user_id: manager.user_id, sale_id: sale.sale_id }); + expect(res.status).toBe(200); + const saleRes = await saleModel + .query() + .context({ showHidden: true }) + .where('sale_id', sale.sale_id); + expect(saleRes.length).toBe(1); + expect(saleRes[0].deleted).toBe(true); }); - test('Worker should delete their own sale', async (done) => { + test('Worker should delete their own sale', async () => { let [workersSale] = await mocks.saleFactory({ promisedUserFarm: [workerFarm] }); let [workersCropVarietySale] = await mocks.crop_variety_saleFactory({ promisedVarietyCrop: [cropVariety], promisedSale: [workersSale], }); - deleteRequest( - { user_id: newWorker.user_id, sale_id: workersSale.sale_id }, - async (err, res) => { - expect(res.status).toBe(200); - const saleRes = await saleModel - .query() - .context({ showHidden: true }) - .where('sale_id', workersSale.sale_id); - expect(saleRes.length).toBe(1); - expect(saleRes[0].deleted).toBe(true); - // const saleRes = await saleModel.query().whereNotDeleted().where('sale_id', sale.sale_id); - // expect(saleRes.length).toBe(0); - done(); - }, - ); + const res = await deleteRequest({ + user_id: newWorker.user_id, + sale_id: workersSale.sale_id, + }); + expect(res.status).toBe(200); + const saleRes = await saleModel + .query() + .context({ showHidden: true }) + .where('sale_id', workersSale.sale_id); + expect(saleRes.length).toBe(1); + expect(saleRes[0].deleted).toBe(true); }); - test('should return 403 if an unauthorized user tries to delete a sale', async (done) => { - deleteRequest( - { - user_id: unAuthorizedUser.user_id, - sale_id: sale.sale_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('should return 403 if an unauthorized user tries to delete a sale', async () => { + const res = await deleteRequest({ + user_id: unAuthorizedUser.user_id, + sale_id: sale.sale_id, + }); + + expect(res.status).toBe(403); }); - test('should return 403 if a worker tries to delete a sale', async (done) => { - deleteRequest({ user_id: newWorker.user_id, sale_id: sale.sale_id }, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + test('should return 403 if a worker tries to delete a sale', async () => { + const res = await deleteRequest({ user_id: newWorker.user_id, sale_id: sale.sale_id }); + expect(res.status).toBe(403); }); - test('Circumvent authorization by modifying farm_id', async (done) => { - deleteRequest( - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - sale_id: sale.sale_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modifying farm_id', async () => { + const res = await deleteRequest({ + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + sale_id: sale.sale_id, + }); + + expect(res.status).toBe(403); }); }); }); @@ -404,36 +355,28 @@ describe('Sale Tests', () => { }; }); - test('Should return 400 if crop_variety_sale is undefined', async (done) => { + test('Should return 400 if crop_variety_sale is undefined', async () => { sampleReqBody.crop_variety_sale = undefined; - postSaleRequest(sampleReqBody, {}, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postSaleRequest(sampleReqBody, {}); + expect(res.status).toBe(400); }); - test('Should return 400 if crop_variety_sale is empty[]', async (done) => { + test('Should return 400 if crop_variety_sale is empty[]', async () => { sampleReqBody.crop_variety_sale = []; - postSaleRequest(sampleReqBody, {}, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postSaleRequest(sampleReqBody, {}); + expect(res.status).toBe(400); }); - test('Should return 400 if crop_variety_sale is empty[{}]', async (done) => { + test('Should return 400 if crop_variety_sale is empty[{}]', async () => { sampleReqBody.crop_variety_sale = [{}]; - postSaleRequest(sampleReqBody, {}, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postSaleRequest(sampleReqBody, {}); + expect(res.status).toBe(400); }); - test('Should return 400 if crop_variety_id is invalid', async (done) => { + test('Should return 400 if crop_variety_id is invalid', async () => { sampleReqBody.crop_variety_sale[0].crop_variety_id = 9999999; - postSaleRequest(sampleReqBody, {}, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postSaleRequest(sampleReqBody, {}); + expect(res.status).toBe(400); }); // TODO: Edge case. @@ -445,17 +388,14 @@ describe('Sale Tests', () => { // }) // }); - test('Should return 400 if body.crop_variety_sale[i].crop exist', async (done) => { + test('Should return 400 if body.crop_variety_sale[i].crop exist', async () => { delete sampleReqBody.crop_variety_sale[0].crop_variety_id; sampleReqBody.crop_variety_sale[0].crop_variety = { ...mocks.fakeCropVariety(), farm_id: farm.farm_id, }; - // Should not allow upsertGraph to post new farm/crop/managementPlan through post sale request - postSaleRequest(sampleReqBody, {}, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postSaleRequest(sampleReqBody, {}); + expect(res.status).toBe(400); }); describe('Post sale authorization tests', () => { @@ -493,61 +433,55 @@ describe('Sale Tests', () => { ); }); - test('Owner should post and get a valid crop', async (done) => { - postSaleRequest(sampleReqBody, {}, async (err, res) => { - expect(res.status).toBe(201); - const sales = await saleModel.query().where('farm_id', farm.farm_id); - expect(sales.length).toBe(1); - expect(sales[0].customer_name).toBe(sampleReqBody.customer_name); - expect(sales[0].revenue_type_id).toBe(sampleReqBody.revenue_type_id); - const cropVarietySales = await cropVarietySaleModel - .query() - .where('sale_id', sales[0].sale_id); - expect(cropVarietySales.length).toBe(2); - expect(cropVarietySales[1].crop_variety_id).toBe( - sampleReqBody.crop_variety_sale[1].crop_variety_id, - ); - done(); - }); + test('Owner should post and get a valid crop', async () => { + const res = await postSaleRequest(sampleReqBody, {}); + expect(res.status).toBe(201); + const sales = await saleModel.query().where('farm_id', farm.farm_id); + expect(sales.length).toBe(1); + expect(sales[0].customer_name).toBe(sampleReqBody.customer_name); + expect(sales[0].revenue_type_id).toBe(sampleReqBody.revenue_type_id); + const cropVarietySales = await cropVarietySaleModel + .query() + .where('sale_id', sales[0].sale_id); + expect(cropVarietySales.length).toBe(2); + expect(cropVarietySales[1].crop_variety_id).toBe( + sampleReqBody.crop_variety_sale[1].crop_variety_id, + ); }); - test('Manager should post and get a valid crop', async (done) => { - postSaleRequest(sampleReqBody, { user_id: manager.user_id }, async (err, res) => { - expect(res.status).toBe(201); - const sales = await saleModel.query().where('farm_id', farm.farm_id); - expect(sales.length).toBe(1); - expect(sales[0].customer_name).toBe(sampleReqBody.customer_name); - expect(sales[0].revenue_type_id).toBe(sampleReqBody.revenue_type_id); - const cropVarietySales = await cropVarietySaleModel - .query() - .where('sale_id', sales[0].sale_id); - expect(cropVarietySales.length).toBe(2); - expect(cropVarietySales[1].crop_variety_id).toBe( - sampleReqBody.crop_variety_sale[1].crop_variety_id, - ); - done(); - }); + test('Manager should post and get a valid crop', async () => { + const res = await postSaleRequest(sampleReqBody, { user_id: manager.user_id }); + expect(res.status).toBe(201); + const sales = await saleModel.query().where('farm_id', farm.farm_id); + expect(sales.length).toBe(1); + expect(sales[0].customer_name).toBe(sampleReqBody.customer_name); + expect(sales[0].revenue_type_id).toBe(sampleReqBody.revenue_type_id); + const cropVarietySales = await cropVarietySaleModel + .query() + .where('sale_id', sales[0].sale_id); + expect(cropVarietySales.length).toBe(2); + expect(cropVarietySales[1].crop_variety_id).toBe( + sampleReqBody.crop_variety_sale[1].crop_variety_id, + ); }); - test('Worker should post and get a valid crop', async (done) => { - postSaleRequest(sampleReqBody, { user_id: worker.user_id }, async (err, res) => { - expect(res.status).toBe(201); - const sales = await saleModel.query().where('farm_id', farm.farm_id); - expect(sales.length).toBe(1); - expect(sales[0].customer_name).toBe(sampleReqBody.customer_name); - expect(sales[0].revenue_type_id).toBe(sampleReqBody.revenue_type_id); - const cropVarietySales = await cropVarietySaleModel - .query() - .where('sale_id', sales[0].sale_id); - expect(cropVarietySales.length).toBe(2); - expect(cropVarietySales[1].crop_variety_id).toBe( - sampleReqBody.crop_variety_sale[1].crop_variety_id, - ); - done(); - }); + test('Worker should post and get a valid crop', async () => { + const res = await postSaleRequest(sampleReqBody, { user_id: worker.user_id }); + expect(res.status).toBe(201); + const sales = await saleModel.query().where('farm_id', farm.farm_id); + expect(sales.length).toBe(1); + expect(sales[0].customer_name).toBe(sampleReqBody.customer_name); + expect(sales[0].revenue_type_id).toBe(sampleReqBody.revenue_type_id); + const cropVarietySales = await cropVarietySaleModel + .query() + .where('sale_id', sales[0].sale_id); + expect(cropVarietySales.length).toBe(2); + expect(cropVarietySales[1].crop_variety_id).toBe( + sampleReqBody.crop_variety_sale[1].crop_variety_id, + ); }); - const testGeneralSale = async (done, userId) => { + const testGeneralSale = async (userId) => { const [{ revenue_type_id }] = await mocks.revenue_typeFactory({ promisedFarm: [{ farm_id: farm.farm_id }], properties: { agriculture_associated: null, crop_generated: false }, @@ -557,50 +491,41 @@ describe('Sale Tests', () => { sampleReqBody.note = 'notes'; sampleReqBody.revenue_type_id = revenue_type_id; - postSaleRequest(sampleReqBody, { user_id: userId }, async (err, res) => { - expect(res.status).toBe(201); - const sales = await saleModel.query().where('farm_id', farm.farm_id); - expect(sales.length).toBe(1); - expect(sales[0].customer_name).toBe(sampleReqBody.customer_name); - expect(sales[0].value).toBe(sampleReqBody.value); - expect(sales[0].note).toBe(sampleReqBody.note); - expect(sales[0].revenue_type_id).toBe(sampleReqBody.revenue_type_id); - done(); - }); + const res = await postSaleRequest(sampleReqBody, { user_id: userId }); + expect(res.status).toBe(201); + const sales = await saleModel.query().where('farm_id', farm.farm_id); + expect(sales.length).toBe(1); + expect(sales[0].customer_name).toBe(sampleReqBody.customer_name); + expect(sales[0].value).toBe(sampleReqBody.value); + expect(sales[0].note).toBe(sampleReqBody.note); + expect(sales[0].revenue_type_id).toBe(sampleReqBody.revenue_type_id); }; - test(`Owner should post and get a general sale`, async (done) => { - testGeneralSale(done, owner.userId); + test(`Owner should post and get a general sale`, async () => { + await testGeneralSale(owner.userId); }); - test(`Manager should post and get a general sale`, async (done) => { - testGeneralSale(done, manager.userId); + test(`Manager should post and get a general sale`, async () => { + await testGeneralSale(manager.userId); }); - test(`Worker should post and get a general sale`, async (done) => { - testGeneralSale(done, worker.userId); + test(`Worker should post and get a general sale`, async () => { + await testGeneralSale(worker.userId); }); - test('should return 403 status if sale is posted by unauthorized user', async (done) => { - postSaleRequest(sampleReqBody, { user_id: unAuthorizedUser.user_id }, async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('User does not have the following permission(s): add:sales'); - done(); - }); + test('should return 403 status if sale is posted by unauthorized user', async () => { + const res = await postSaleRequest(sampleReqBody, { user_id: unAuthorizedUser.user_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): add:sales'); }); - test('Circumvent authorization by modify farm_id', async (done) => { - postSaleRequest( - sampleReqBody, - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modify farm_id', async () => { + const res = await postSaleRequest(sampleReqBody, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); }); }); }); @@ -663,7 +588,7 @@ describe('Sale Tests', () => { }; }); - test('Should return 400 if more than one crop_variety_sale with duplicate sale_id and crop_variety_id pair (pkey violation)', async (done) => { + test('Should return 400 if more than one crop_variety_sale with duplicate sale_id and crop_variety_id pair (pkey violation)', async () => { patchData.crop_variety_sale = [ { crop_variety_id: cropVariety2.crop_variety_id, @@ -678,18 +603,14 @@ describe('Sale Tests', () => { sale_value: cropVarietySale1.sale_value + 5, }, ]; - patchRequest(patchData, sale.sale_id, {}, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await patchRequest(patchData, sale.sale_id, {}); + expect(res.status).toBe(400); }); - test('Should return 400 if there are no crop variety sales in patch data', async (done) => { + test('Should return 400 if there are no crop variety sales in patch data', async () => { patchData.crop_variety_sale = []; - patchRequest(patchData, sale.sale_id, {}, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await patchRequest(patchData, sale.sale_id, {}); + expect(res.status).toBe(400); }); describe('Patch sale authorization tests', () => { @@ -730,47 +651,39 @@ describe('Sale Tests', () => { ); }); - test('Owner should patch a sale', async (done) => { - patchRequest(patchData, sale.sale_id, {}, async (err, res) => { - expect(res.status).toBe(200); - const saleRes = await saleModel.query().where('sale_id', sale.sale_id).first(); - expect(saleRes.customer_name).toBe(patchData.customer_name); + test('Owner should patch a sale', async () => { + const res = await patchRequest(patchData, sale.sale_id, {}); + expect(res.status).toBe(200); + const saleRes = await saleModel.query().where('sale_id', sale.sale_id).first(); + expect(saleRes.customer_name).toBe(patchData.customer_name); - const cropVarietySaleRes = await cropVarietySaleModel - .query() - .where('sale_id', sale.sale_id); - expect(cropVarietySaleRes.length).toBe(patchData.crop_variety_sale.length); - for (var i = 0; i < cropVarietySaleRes.length; i++) { - expect(cropVarietySaleRes[i].quantity).toBe(patchData.crop_variety_sale[i].quantity); - expect(cropVarietySaleRes[i].sale_value).toBe( - patchData.crop_variety_sale[i].sale_value, - ); - } - done(); - }); + const cropVarietySaleRes = await cropVarietySaleModel + .query() + .where('sale_id', sale.sale_id); + expect(cropVarietySaleRes.length).toBe(patchData.crop_variety_sale.length); + for (var i = 0; i < cropVarietySaleRes.length; i++) { + expect(cropVarietySaleRes[i].quantity).toBe(patchData.crop_variety_sale[i].quantity); + expect(cropVarietySaleRes[i].sale_value).toBe(patchData.crop_variety_sale[i].sale_value); + } }); - test('Manager should patch a sale', async (done) => { - patchRequest(patchData, sale.sale_id, { user_id: manager.user_id }, async (err, res) => { - expect(res.status).toBe(200); - const saleRes = await saleModel.query().where('sale_id', sale.sale_id).first(); - expect(saleRes.customer_name).toBe(patchData.customer_name); + test('Manager should patch a sale', async () => { + const res = await patchRequest(patchData, sale.sale_id, { user_id: manager.user_id }); + expect(res.status).toBe(200); + const saleRes = await saleModel.query().where('sale_id', sale.sale_id).first(); + expect(saleRes.customer_name).toBe(patchData.customer_name); - const cropVarietySaleRes = await cropVarietySaleModel - .query() - .where('sale_id', sale.sale_id); - expect(cropVarietySaleRes.length).toBe(patchData.crop_variety_sale.length); - for (var i = 0; i < cropVarietySaleRes.length; i++) { - expect(cropVarietySaleRes[i].quantity).toBe(patchData.crop_variety_sale[i].quantity); - expect(cropVarietySaleRes[i].sale_value).toBe( - patchData.crop_variety_sale[i].sale_value, - ); - } - done(); - }); + const cropVarietySaleRes = await cropVarietySaleModel + .query() + .where('sale_id', sale.sale_id); + expect(cropVarietySaleRes.length).toBe(patchData.crop_variety_sale.length); + for (var i = 0; i < cropVarietySaleRes.length; i++) { + expect(cropVarietySaleRes[i].quantity).toBe(patchData.crop_variety_sale[i].quantity); + expect(cropVarietySaleRes[i].sale_value).toBe(patchData.crop_variety_sale[i].sale_value); + } }); - test('Worker should patch a sale that they created', async (done) => { + test('Worker should patch a sale that they created', async () => { let [workersSale] = await mocks.saleFactory( { promisedUserFarm: [workerFarm] }, mocks.fakeSale({ revenue_type_id: cropSaleRevenueType.revenue_type_id }), @@ -780,47 +693,31 @@ describe('Sale Tests', () => { promisedSale: [workersSale], }); - patchRequest( - patchData, - workersSale.sale_id, - { user_id: worker.user_id }, - async (err, res) => { - expect(res.status).toBe(200); - const saleRes = await saleModel.query().where('sale_id', workersSale.sale_id).first(); - expect(saleRes.customer_name).toBe(patchData.customer_name); - - const cropVarietySaleRes = await cropVarietySaleModel - .query() - .where('sale_id', workersSale.sale_id); - expect(cropVarietySaleRes.length).toBe(patchData.crop_variety_sale.length); - for (var i = 0; i < cropVarietySaleRes.length; i++) { - expect(cropVarietySaleRes[i].quantity).toBe(patchData.crop_variety_sale[i].quantity); - expect(cropVarietySaleRes[i].sale_value).toBe( - patchData.crop_variety_sale[i].sale_value, - ); - } - done(); - }, - ); + const res = await patchRequest(patchData, workersSale.sale_id, { user_id: worker.user_id }); + expect(res.status).toBe(200); + const saleRes = await saleModel.query().where('sale_id', workersSale.sale_id).first(); + expect(saleRes.customer_name).toBe(patchData.customer_name); + + const cropVarietySaleRes = await cropVarietySaleModel + .query() + .where('sale_id', workersSale.sale_id); + expect(cropVarietySaleRes.length).toBe(patchData.crop_variety_sale.length); + for (var i = 0; i < cropVarietySaleRes.length; i++) { + expect(cropVarietySaleRes[i].quantity).toBe(patchData.crop_variety_sale[i].quantity); + expect(cropVarietySaleRes[i].sale_value).toBe(patchData.crop_variety_sale[i].sale_value); + } }); - test("Should return 403 if worker tries to patch another member's sale", async (done) => { - patchRequest(patchData, sale.sale_id, { user_id: worker.user_id }, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + test("Should return 403 if worker tries to patch another member's sale", async () => { + const res = await patchRequest(patchData, sale.sale_id, { user_id: worker.user_id }); + expect(res.status).toBe(403); }); - test('Should return 403 if unauthorized user tries to patch sale', async (done) => { - patchRequest( - patchData, - sale.sale_id, - { user_id: unauthorizedUser.user_id }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Should return 403 if unauthorized user tries to patch sale', async () => { + const res = await patchRequest(patchData, sale.sale_id, { + user_id: unauthorizedUser.user_id, + }); + expect(res.status).toBe(403); }); }); }); diff --git a/packages/api/tests/soil_amendment_fertiliser_types.test.js b/packages/api/tests/soil_amendment_fertiliser_types.test.js index 29512988c5..947bce05e6 100644 --- a/packages/api/tests/soil_amendment_fertiliser_types.test.js +++ b/packages/api/tests/soil_amendment_fertiliser_types.test.js @@ -39,14 +39,12 @@ describe('Soil Amendment FertiliserType Test', () => { token = global.token; }); - afterEach(async (done) => { + afterEach(async () => { await tableCleanup(knex); - done(); }); - afterAll(async (done) => { + afterAll(async () => { await knex.destroy(); - done(); }); async function getRequest({ user_id, farm_id }) { diff --git a/packages/api/tests/soil_amendment_methods.test.js b/packages/api/tests/soil_amendment_methods.test.js index 801ca981ad..fd585bf109 100644 --- a/packages/api/tests/soil_amendment_methods.test.js +++ b/packages/api/tests/soil_amendment_methods.test.js @@ -39,14 +39,12 @@ describe('Soil Amendment Methods Test', () => { token = global.token; }); - afterEach(async (done) => { + afterEach(async () => { await tableCleanup(knex); - done(); }); - afterAll(async (done) => { + afterAll(async () => { await knex.destroy(); - done(); }); async function getRequest({ user_id, farm_id }) { diff --git a/packages/api/tests/soil_amendment_purposes.test.js b/packages/api/tests/soil_amendment_purposes.test.js index 756ec3a78f..a2073d6cac 100644 --- a/packages/api/tests/soil_amendment_purposes.test.js +++ b/packages/api/tests/soil_amendment_purposes.test.js @@ -39,14 +39,12 @@ describe('Soil Amendment Purpose Test', () => { token = global.token; }); - afterEach(async (done) => { + afterEach(async () => { await tableCleanup(knex); - done(); }); - afterAll(async (done) => { + afterAll(async () => { await knex.destroy(); - done(); }); async function getRequest({ user_id, farm_id }) { diff --git a/packages/api/tests/supportTicket.test.js b/packages/api/tests/supportTicket.test.js index aec1a678d1..4b5a382f20 100644 --- a/packages/api/tests/supportTicket.test.js +++ b/packages/api/tests/supportTicket.test.js @@ -46,8 +46,8 @@ describe('supportTicket Tests', () => { token = global.token; }); - function postRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }, callback) { - chai + function postRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post(`/support_ticket`) .set('Content-Type', 'multipart/form-data') @@ -56,8 +56,7 @@ describe('supportTicket Tests', () => { .field({ _file_: data.attachments, data: JSON.stringify(data), - }) - .end(callback); + }); } function fakeUserFarm(role = 1) { @@ -73,10 +72,9 @@ describe('supportTicket Tests', () => { ); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('Post support ticket', () => { @@ -86,17 +84,15 @@ describe('supportTicket Tests', () => { fakeSupportTicket = mocks.fakeSupportTicket(farm.farm_id); }); - test('Owner post support ticket', async (done) => { - postRequest(fakeSupportTicket, {}, async (err, res) => { - expect(res.status).toBe(201); - const supportTickets = await supportTicketModel - .query() - .context({ showHidden: true }) - .where('support_ticket_id', res.body.support_ticket_id); - expect(supportTickets.length).toBe(1); - expect(supportTickets[0].created_by_user_id).toBe(owner.user_id); - done(); - }); + test('Owner post support ticket', async () => { + const res = await postRequest(fakeSupportTicket, {}); + expect(res.status).toBe(201); + const supportTickets = await supportTicketModel + .query() + .context({ showHidden: true }) + .where('support_ticket_id', res.body.support_ticket_id); + expect(supportTickets.length).toBe(1); + expect(supportTickets[0].created_by_user_id).toBe(owner.user_id); }); }); }); diff --git a/packages/api/tests/task.test.js b/packages/api/tests/task.test.js index 9c5461360f..bb2494ed35 100644 --- a/packages/api/tests/task.test.js +++ b/packages/api/tests/task.test.js @@ -32,121 +32,109 @@ describe('Task tests', () => { ); } - function assignTaskRequest({ user_id, farm_id }, data, task_id, callback) { - chai + function assignTaskRequest({ user_id, farm_id }, data, task_id) { + return chai .request(server) .patch(`/task/assign/${task_id}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function postTaskRequest({ user_id, farm_id }, type, data, callback) { - chai + function postTaskRequest({ user_id, farm_id }, type, data) { + return chai .request(server) .post(`/task/${type}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function postHarvestTasksRequest({ user_id, farm_id }, data, callback) { - chai + function postHarvestTasksRequest({ user_id, farm_id }, data) { + return chai .request(server) .post('/task/harvest_tasks') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function postTransplantTaskRequest({ user_id, farm_id }, data, callback) { - chai + function postTransplantTaskRequest({ user_id, farm_id }, data) { + return chai .request(server) .post('/task/transplant_task') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function getTasksRequest({ user_id, farm_id }, callback) { - chai + function getTasksRequest({ user_id, farm_id }) { + return chai .request(server) .get(`/task/${farm_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - function getHarvestUsesRequest({ user_id, farm_id }, callback) { - chai + function getHarvestUsesRequest({ user_id, farm_id }) { + return chai .request(server) .get(`/task/harvest_uses/farm/${farm_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - function assignAllTasksOnDateRequest({ user_id, farm_id }, data, task_id, callback) { - chai + function assignAllTasksOnDateRequest({ user_id, farm_id }, data, task_id) { + return chai .request(server) .patch(`/task/assign_all_tasks_on_date/${task_id}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function patchTaskDateRequest({ user_id, farm_id }, data, task_id, callback) { - chai + function patchTaskDateRequest({ user_id, farm_id }, data, task_id) { + return chai .request(server) .patch(`/task/patch_due_date/${task_id}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function patchTaskWageRequest({ user_id, farm_id }, data, task_id, callback) { - chai + function patchTaskWageRequest({ user_id, farm_id }, data, task_id) { + return chai .request(server) .patch(`/task/patch_wage/${task_id}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function completeTaskRequest({ user_id, farm_id }, data, task_id, type, callback) { - chai + function completeTaskRequest({ user_id, farm_id }, data, task_id, type) { + return chai .request(server) .patch(`/task/complete/${type}/${task_id}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function abandonTaskRequest({ user_id, farm_id }, data, task_id, callback) { - chai + function abandonTaskRequest({ user_id, farm_id }, data, task_id) { + return chai .request(server) .patch(`/task/abandon/${task_id}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function deleteTaskRequest({ user_id, farm_id }, task_id, callback) { - chai + function deleteTaskRequest({ user_id, farm_id }, task_id) { + return chai .request(server) .delete(`/task/${task_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } function fakeUserFarm(role = 1) { @@ -216,14 +204,13 @@ describe('Task tests', () => { }); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('PATCH Assginee tests', () => { - test('Owners should be able to assign person to task', async (done) => { + test('Owners should be able to assign person to task', async () => { const userFarm = { ...fakeUserFarm(1), wage: { type: '', amount: 30 } }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, userFarm); const [{ task_id }] = await mocks.taskFactory({ promisedUser: [{ user_id }] }); @@ -232,21 +219,18 @@ describe('Task tests', () => { promisedTask: [{ task_id }], promisedField: [{ location_id }], }); - assignTaskRequest( + const res = await assignTaskRequest( { user_id, farm_id }, { assignee_user_id: user_id }, task_id, - async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task_id); - // expect(updated_task.wage_at_moment).toBe(30); - expect(updated_task.assignee_user_id).toBe(user_id); - done(); - }, ); + expect(res.status).toBe(200); + const updated_task = await getTask(task_id); + // expect(updated_task.wage_at_moment).toBe(30); + expect(updated_task.assignee_user_id).toBe(user_id); }); - test('Should not be able to assign tasks to Inactive users', async (done) => { + test('Should not be able to assign tasks to Inactive users', async () => { const userFarm = { ...fakeUserFarm(1), wage: { type: '', amount: 30 } }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, userFarm); const [{ user_id: assignee_user_id }] = await mocks.userFarmFactory( @@ -263,13 +247,11 @@ describe('Task tests', () => { promisedTask: [{ task_id }], promisedField: [{ location_id }], }); - assignTaskRequest({ user_id, farm_id }, { assignee_user_id }, task_id, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await assignTaskRequest({ user_id, farm_id }, { assignee_user_id }, task_id); + expect(res.status).toBe(400); }); - test('Managers should be able to assign person to task', async (done) => { + test('Managers should be able to assign person to task', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(2)); const [{ task_id }] = await mocks.taskFactory({ promisedUser: [{ user_id }] }); const [{ location_id }] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); @@ -277,20 +259,17 @@ describe('Task tests', () => { promisedTask: [{ task_id }], promisedField: [{ location_id }], }); - assignTaskRequest( + const res = await assignTaskRequest( { user_id, farm_id }, { assignee_user_id: user_id }, task_id, - async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task_id); - expect(updated_task.assignee_user_id).toBe(user_id); - done(); - }, ); + expect(res.status).toBe(200); + const updated_task = await getTask(task_id); + expect(updated_task.assignee_user_id).toBe(user_id); }); - test('EO should be able to assign person to task', async (done) => { + test('EO should be able to assign person to task', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(5)); const [{ task_id }] = await mocks.taskFactory({ promisedUser: [{ user_id }] }); const [{ location_id }] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); @@ -298,20 +277,17 @@ describe('Task tests', () => { promisedTask: [{ task_id }], promisedField: [{ location_id }], }); - assignTaskRequest( + const res = await assignTaskRequest( { user_id, farm_id }, { assignee_user_id: user_id }, task_id, - async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task_id); - expect(updated_task.assignee_user_id).toBe(user_id); - done(); - }, ); + expect(res.status).toBe(200); + const updated_task = await getTask(task_id); + expect(updated_task.assignee_user_id).toBe(user_id); }); - test('Worker should be able to assign self to task', async (done) => { + test('Worker should be able to assign self to task', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(3)); const [{ task_id }] = await mocks.taskFactory({ promisedUser: [{ user_id }] }); const [{ location_id }] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); @@ -319,20 +295,17 @@ describe('Task tests', () => { promisedTask: [{ task_id }], promisedField: [{ location_id }], }); - assignTaskRequest( + const res = await assignTaskRequest( { user_id, farm_id }, { assignee_user_id: user_id }, task_id, - async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task_id); - expect(updated_task.assignee_user_id).toBe(user_id); - done(); - }, ); + expect(res.status).toBe(200); + const updated_task = await getTask(task_id); + expect(updated_task.assignee_user_id).toBe(user_id); }); - test('Worker should not be able to assign another person to task', async (done) => { + test('Worker should not be able to assign another person to task', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(3)); const [{ user_id: other_user_id }] = await mocks.userFarmFactory( { promisedFarm: [{ farm_id }] }, @@ -344,18 +317,15 @@ describe('Task tests', () => { promisedTask: [{ task_id }], promisedField: [{ location_id }], }); - assignTaskRequest( + const res = await assignTaskRequest( { user_id, farm_id }, { assignee_user_id: other_user_id }, task_id, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, ); + expect(res.status).toBe(403); }); - test('Farm worker should not be able to re-assign a task assigned to another person', async (done) => { + test('Farm worker should not be able to re-assign a task assigned to another person', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(3)); const [{ user_id: admin_user_id }] = await mocks.userFarmFactory( { promisedFarm: [{ farm_id }] }, @@ -375,18 +345,15 @@ describe('Task tests', () => { promisedTask: [{ task_id }], promisedField: [{ location_id }], }); - assignTaskRequest( + const res = await assignTaskRequest( { user_id, farm_id }, { assignee_user_id: user_id }, task_id, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, ); + expect(res.status).toBe(403); }); - test('Should not be able to re-assign completed tasks', async (done) => { + test('Should not be able to re-assign completed tasks', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const [{ user_id: another_id }] = await mocks.userFarmFactory( { promisedFarm: [{ farm_id }] }, @@ -402,18 +369,15 @@ describe('Task tests', () => { promisedTask: [{ task_id }], promisedField: [{ location_id }], }); - assignTaskRequest( + const res = await assignTaskRequest( { user_id, farm_id }, { assignee_user_id: another_id }, task_id, - async (err, res) => { - expect(res.status).toBe(400); - done(); - }, ); + expect(res.status).toBe(400); }); - test('Should not be able to re-assign abandoned tasks', async (done) => { + test('Should not be able to re-assign abandoned tasks', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const [{ user_id: another_id }] = await mocks.userFarmFactory( { promisedFarm: [{ farm_id }] }, @@ -429,18 +393,15 @@ describe('Task tests', () => { promisedTask: [{ task_id }], promisedField: [{ location_id }], }); - assignTaskRequest( + const res = await assignTaskRequest( { user_id, farm_id }, { assignee_user_id: another_id }, task_id, - async (err, res) => { - expect(res.status).toBe(400); - done(); - }, ); + expect(res.status).toBe(400); }); - test('Owner should be able to assign person to multiple tasks on date', async (done) => { + test('Owner should be able to assign person to multiple tasks on date', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const date = faker.date.future().toISOString().split('T')[0]; const [task_1] = await mocks.taskFactory( @@ -457,25 +418,24 @@ describe('Task tests', () => { const task_2_id = task_2.task_id; await mocks.location_tasksFactory({ promisedTask: [task_1], promisedField: [location_1] }); await mocks.location_tasksFactory({ promisedTask: [task_2], promisedField: [location_2] }); - assignAllTasksOnDateRequest( + + const res = await assignAllTasksOnDateRequest( { user_id, farm_id }, { assignee_user_id: user_id, date, }, task_1_id, - async (err, res) => { - expect(res.status).toBe(200); - const updated_task_1 = await getTask(task_1_id); - const updated_task_2 = await getTask(task_2_id); - expect(updated_task_1.assignee_user_id).toBe(user_id); - expect(updated_task_2.assignee_user_id).toBe(user_id); - done(); - }, ); + + expect(res.status).toBe(200); + const updated_task_1 = await getTask(task_1_id); + const updated_task_2 = await getTask(task_2_id); + expect(updated_task_1.assignee_user_id).toBe(user_id); + expect(updated_task_2.assignee_user_id).toBe(user_id); }); - test('Manager should be able to assign person to multiple tasks on date', async (done) => { + test('Manager should be able to assign person to multiple tasks on date', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(2)); const date = faker.date.future().toISOString().split('T')[0]; const [task_1] = await mocks.taskFactory( @@ -492,25 +452,24 @@ describe('Task tests', () => { const task_2_id = task_2.task_id; await mocks.location_tasksFactory({ promisedTask: [task_1], promisedField: [location_1] }); await mocks.location_tasksFactory({ promisedTask: [task_2], promisedField: [location_2] }); - assignAllTasksOnDateRequest( + + const res = await assignAllTasksOnDateRequest( { user_id, farm_id }, { assignee_user_id: user_id, date, }, task_1_id, - async (err, res) => { - expect(res.status).toBe(200); - const updated_task_1 = await getTask(task_1_id); - const updated_task_2 = await getTask(task_2_id); - expect(updated_task_1.assignee_user_id).toBe(user_id); - expect(updated_task_2.assignee_user_id).toBe(user_id); - done(); - }, ); + + expect(res.status).toBe(200); + const updated_task_1 = await getTask(task_1_id); + const updated_task_2 = await getTask(task_2_id); + expect(updated_task_1.assignee_user_id).toBe(user_id); + expect(updated_task_2.assignee_user_id).toBe(user_id); }); - test('EO should be able to assign person to multiple tasks on date', async (done) => { + test('EO should be able to assign person to multiple tasks on date', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(5)); const date = faker.date.future().toISOString().split('T')[0]; const [task_1] = await mocks.taskFactory( @@ -527,25 +486,24 @@ describe('Task tests', () => { const task_2_id = task_2.task_id; await mocks.location_tasksFactory({ promisedTask: [task_1], promisedField: [location_1] }); await mocks.location_tasksFactory({ promisedTask: [task_2], promisedField: [location_2] }); - assignAllTasksOnDateRequest( + + const res = await assignAllTasksOnDateRequest( { user_id, farm_id }, { assignee_user_id: user_id, date, }, task_1_id, - async (err, res) => { - expect(res.status).toBe(200); - const updated_task_1 = await getTask(task_1_id); - const updated_task_2 = await getTask(task_2_id); - expect(updated_task_1.assignee_user_id).toBe(user_id); - expect(updated_task_2.assignee_user_id).toBe(user_id); - done(); - }, ); + + expect(res.status).toBe(200); + const updated_task_1 = await getTask(task_1_id); + const updated_task_2 = await getTask(task_2_id); + expect(updated_task_1.assignee_user_id).toBe(user_id); + expect(updated_task_2.assignee_user_id).toBe(user_id); }); - test('should be able to assign a person to multiple tasks without an assignee on a date', async (done) => { + test('should be able to assign a person to multiple tasks without an assignee on a date', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(5)); const [{ user_id: another_user }] = await mocks.userFarmFactory({ promisedFarm: [{ farm_id }], @@ -574,27 +532,26 @@ describe('Task tests', () => { await mocks.location_tasksFactory({ promisedTask: [task_1], promisedField: [location_1] }); await mocks.location_tasksFactory({ promisedTask: [task_2], promisedField: [location_2] }); await mocks.location_tasksFactory({ promisedTask: [task_3], promisedField: [location_2] }); - assignAllTasksOnDateRequest( + + const res = await assignAllTasksOnDateRequest( { user_id, farm_id }, { assignee_user_id: user_id, date, }, task_1_id, - async (err, res) => { - expect(res.status).toBe(200); - const updated_task_1 = await getTask(task_1_id); - const updated_task_2 = await getTask(task_2_id); - const updated_task_3 = await getTask(task_3_id); - expect(updated_task_1.assignee_user_id).toBe(user_id); - expect(updated_task_2.assignee_user_id).toBe(user_id); - expect(updated_task_3.assignee_user_id).toBe(another_user); - done(); - }, ); + + expect(res.status).toBe(200); + const updated_task_1 = await getTask(task_1_id); + const updated_task_2 = await getTask(task_2_id); + const updated_task_3 = await getTask(task_3_id); + expect(updated_task_1.assignee_user_id).toBe(user_id); + expect(updated_task_2.assignee_user_id).toBe(user_id); + expect(updated_task_3.assignee_user_id).toBe(another_user); }); - test('Worker should be able to assign self to multiple tasks on date', async (done) => { + test('Worker should be able to assign self to multiple tasks on date', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(3)); const date = faker.date.future().toISOString().split('T')[0]; const [task_1] = await mocks.taskFactory( @@ -611,25 +568,24 @@ describe('Task tests', () => { const task_2_id = task_2.task_id; await mocks.location_tasksFactory({ promisedTask: [task_1], promisedField: [location_1] }); await mocks.location_tasksFactory({ promisedTask: [task_2], promisedField: [location_2] }); - assignAllTasksOnDateRequest( + + const res = await assignAllTasksOnDateRequest( { user_id, farm_id }, { assignee_user_id: user_id, date, }, task_1_id, - async (err, res) => { - expect(res.status).toBe(200); - const updated_task_1 = await getTask(task_1_id); - const updated_task_2 = await getTask(task_2_id); - expect(updated_task_1.assignee_user_id).toBe(user_id); - expect(updated_task_2.assignee_user_id).toBe(user_id); - done(); - }, ); + + expect(res.status).toBe(200); + const updated_task_1 = await getTask(task_1_id); + const updated_task_2 = await getTask(task_2_id); + expect(updated_task_1.assignee_user_id).toBe(user_id); + expect(updated_task_2.assignee_user_id).toBe(user_id); }); - test('Worker should not be able to assign other person to multiple tasks on date', async (done) => { + test('Worker should not be able to assign other person to multiple tasks on date', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(3)); const [{ user_id: other_user_id }] = await mocks.userFarmFactory( { promisedFarm: [{ farm_id }] }, @@ -648,21 +604,20 @@ describe('Task tests', () => { const [location_2] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); await mocks.location_tasksFactory({ promisedTask: [task_1], promisedField: [location_1] }); await mocks.location_tasksFactory({ promisedTask: [task_2], promisedField: [location_2] }); - assignAllTasksOnDateRequest( + + const res = await assignAllTasksOnDateRequest( { user_id, farm_id }, { assignee_user_id: other_user_id, date, }, task_1.task_id, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, ); + + expect(res.status).toBe(403); }); - test('Should only re-assign multiple non-completed or abandoned tasks on date', async (done) => { + test('Should only re-assign multiple non-completed or abandoned tasks on date', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const [{ user_id: another_id }] = await mocks.userFarmFactory( { promisedFarm: [{ farm_id }] }, @@ -705,30 +660,29 @@ describe('Task tests', () => { promisedTask: [abandoned_task], promisedField: [location_2], }); - assignAllTasksOnDateRequest( + + const res = await assignAllTasksOnDateRequest( { user_id, farm_id }, { assignee_user_id: another_id, date, }, task_1.task_id, - async (err, res) => { - expect(res.status).toBe(200); - expect(res.body.length).toBe(2); - const updated_task_1 = await getTask(task_1.task_id); - const updated_task_2 = await getTask(task_2.task_id); - expect(updated_task_1.assignee_user_id).toBe(another_id); - expect(updated_task_2.assignee_user_id).toBe(another_id); - const updated_completed_task = await getTask(completed_task.task_id); - expect(updated_completed_task.assignee_user_id).toBe(null); - const updated_abandoned_task = await getTask(abandoned_task.task_id); - expect(updated_abandoned_task.assignee_user_id).toBe(null); - done(); - }, ); + + expect(res.status).toBe(200); + expect(res.body.length).toBe(2); + const updated_task_1 = await getTask(task_1.task_id); + const updated_task_2 = await getTask(task_2.task_id); + expect(updated_task_1.assignee_user_id).toBe(another_id); + expect(updated_task_2.assignee_user_id).toBe(another_id); + const updated_completed_task = await getTask(completed_task.task_id); + expect(updated_completed_task.assignee_user_id).toBe(null); + const updated_abandoned_task = await getTask(abandoned_task.task_id); + expect(updated_abandoned_task.assignee_user_id).toBe(null); }); - test('Farm owner should be able to reassign a task and assign all tasks on date', async (done) => { + test('Farm owner should be able to reassign a task and assign all tasks on date', async () => { const [{ user_id: ownerUserId, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const [{ user_id: anotherUserId }] = await mocks.userFarmFactory( { promisedFarm: [{ farm_id }] }, @@ -764,24 +718,22 @@ describe('Task tests', () => { promisedField: [location_1], }); - assignAllTasksOnDateRequest( + const res = await assignAllTasksOnDateRequest( { user_id: ownerUserId, farm_id }, { assignee_user_id: anotherUserId, date }, assignedTask.task_id, - async (err, res) => { - expect(res.status).toBe(200); - const reassignedTask = await getTask(assignedTask.task_id); - const updatedTask1 = await getTask(unassignedTask1.task_id); - const updatedTask2 = await getTask(unassignedTask2.task_id); - expect(reassignedTask.assignee_user_id).toBe(anotherUserId); - expect(updatedTask1.assignee_user_id).toBe(anotherUserId); - expect(updatedTask2.assignee_user_id).toBe(anotherUserId); - done(); - }, ); + + expect(res.status).toBe(200); + const reassignedTask = await getTask(assignedTask.task_id); + const updatedTask1 = await getTask(unassignedTask1.task_id); + const updatedTask2 = await getTask(unassignedTask2.task_id); + expect(reassignedTask.assignee_user_id).toBe(anotherUserId); + expect(updatedTask1.assignee_user_id).toBe(anotherUserId); + expect(updatedTask2.assignee_user_id).toBe(anotherUserId); }); - test('Farm worker should not be able to reassign a task and assign all tasks on date', async (done) => { + test('Farm worker should not be able to reassign a task and assign all tasks on date', async () => { const [{ user_id: ownerUserId, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const [{ user_id: workerUserId }] = await mocks.userFarmFactory( { promisedFarm: [{ farm_id }] }, @@ -817,26 +769,24 @@ describe('Task tests', () => { promisedField: [location_1], }); - assignAllTasksOnDateRequest( + const res = await assignAllTasksOnDateRequest( { user_id: workerUserId, farm_id }, { assignee_user_id: workerUserId, date }, assignedTaskBefore.task_id, - async (err, res) => { - expect(res.status).toBe(403); - const assignedTaskAfter = await getTask(assignedTaskBefore.task_id); - const unassignedTask1After = await getTask(unassignedTask1Before.task_id); - const unassignedTask2After = await getTask(unassignedTask2Before.task_id); - expect(assignedTaskAfter.assignee_user_id).toBe(ownerUserId); - expect(unassignedTask1After.assignee_user_id).toBe(null); - expect(unassignedTask2After.assignee_user_id).toBe(null); - done(); - }, ); + + expect(res.status).toBe(403); + const assignedTaskAfter = await getTask(assignedTaskBefore.task_id); + const unassignedTask1After = await getTask(unassignedTask1Before.task_id); + const unassignedTask2After = await getTask(unassignedTask2Before.task_id); + expect(assignedTaskAfter.assignee_user_id).toBe(ownerUserId); + expect(unassignedTask1After.assignee_user_id).toBe(null); + expect(unassignedTask2After.assignee_user_id).toBe(null); }); }); describe('GET harvest uses', () => { - test('should get all harvest_uses for a farm', async (done) => { + test('should get all harvest_uses for a farm', async () => { const userFarm = { ...fakeUserFarm(1), wage: { type: '', amount: 30 } }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, userFarm); const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id }] }); @@ -881,14 +831,12 @@ describe('Task tests', () => { } }), ); - getHarvestUsesRequest({ user_id, farm_id }, async (err, res) => { - expect(res.status).toBe(200); - expect(res.body.length).toBe(9); - done(); - }); + const res = await getHarvestUsesRequest({ user_id, farm_id }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(9); }); - test('should get all harvest uses related to a farm, but not different farms of that user', async (done) => { + test('should get all harvest uses related to a farm, but not different farms of that user', async () => { const userFarm = { ...fakeUserFarm(1), wage: { type: '', amount: 30 } }; const [firstUserFarm] = await mocks.userFarmFactory({}, userFarm); const [secondUserFarm] = await mocks.userFarmFactory({}, userFarm); @@ -936,19 +884,17 @@ describe('Task tests', () => { } }), ); - getHarvestUsesRequest( - { user_id: firstUserFarm.user_id, farm_id: firstUserFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - expect(res.body.length).toBe(3); - done(); - }, - ); + const res = await getHarvestUsesRequest({ + user_id: firstUserFarm.user_id, + farm_id: firstUserFarm.farm_id, + }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(3); }); }); describe('GET tasks', () => { - test('should get all tasks for a farm ', async (done) => { + test('should get all tasks for a farm ', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); await Promise.all( [...Array(10)].map(async () => { @@ -972,14 +918,12 @@ describe('Task tests', () => { }); }), ); - getTasksRequest({ farm_id, user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body.length).toBe(10); - done(); - }); + const res = await getTasksRequest({ farm_id, user_id }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(10); }); - xtest('should get all tasks related to a farm, but not from different farms of that user', async (done) => { + xtest('should get all tasks related to a farm, but not from different farms of that user', async () => { const [firstUserFarm] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const [secondUserFarmWithSameUser] = await mocks.userFarmFactory( { promisedUser: [{ user_id: firstUserFarm.user_id }] }, @@ -1012,14 +956,12 @@ describe('Task tests', () => { }); }), ); - getTasksRequest( - { farm_id: firstUserFarm.farm_id, user_id: firstUserFarm.user_id }, - (err, res) => { - expect(res.status).toBe(200); - expect(res.body.length).toBe(10); - done(); - }, - ); + const res = await getTasksRequest({ + farm_id: firstUserFarm.farm_id, + user_id: firstUserFarm.user_id, + }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(10); }); }); @@ -1074,7 +1016,7 @@ describe('Task tests', () => { harvest_task: () => mocks.fakeHarvestTask(), }; - test('should successfully create a bunch of harvest tasks', async (done) => { + test('should successfully create a bunch of harvest tasks', async () => { const userFarm = { ...fakeUserFarm(1), wage: { type: '', amount: 30 } }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, userFarm); const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id }] }); @@ -1108,31 +1050,29 @@ describe('Task tests', () => { }; }); - postHarvestTasksRequest({ user_id, farm_id }, harvest_tasks, async (err, res) => { - expect(res.status).toBe(201); - const task_ids = res.body.map(({ task_id }) => task_id); - for (let i = 0; i < task_ids.length; i++) { - const created_task = await knex('task').where({ task_id: task_ids[i] }).first(); - expect(created_task.task_type_id).toBe(task_type_id); - expect(created_task.wage_at_moment).toBe(30); - const isTaskRelatedToLocation = await knex('location_tasks') - .where({ task_id: task_ids[i] }) - .first(); - expect(isTaskRelatedToLocation.location_id).toBe(location_id); - expect(isTaskRelatedToLocation.task_id).toBe(Number(task_ids[i])); - const isTaskRelatedToManagementPlans = await knex('management_tasks').where({ - task_id: task_ids[i], - }); - expect(isTaskRelatedToManagementPlans.length).toBe(1); - const created_harvest_task = await knex('harvest_task').where({ - task_id: task_ids[i], - }); - expect(created_harvest_task.length).toBe(1); - expect(created_harvest_task[0].task_id).toBe(Number(task_ids[i])); - expect(created_harvest_task[0].projected_quantity).toBe(300); - } - done(); - }); + const res = await postHarvestTasksRequest({ user_id, farm_id }, harvest_tasks); + expect(res.status).toBe(201); + const task_ids = res.body.map(({ task_id }) => task_id); + for (let i = 0; i < task_ids.length; i++) { + const created_task = await knex('task').where({ task_id: task_ids[i] }).first(); + expect(created_task.task_type_id).toBe(task_type_id); + expect(created_task.wage_at_moment).toBe(30); + const isTaskRelatedToLocation = await knex('location_tasks') + .where({ task_id: task_ids[i] }) + .first(); + expect(isTaskRelatedToLocation.location_id).toBe(location_id); + expect(isTaskRelatedToLocation.task_id).toBe(Number(task_ids[i])); + const isTaskRelatedToManagementPlans = await knex('management_tasks').where({ + task_id: task_ids[i], + }); + expect(isTaskRelatedToManagementPlans.length).toBe(1); + const created_harvest_task = await knex('harvest_task').where({ + task_id: task_ids[i], + }); + expect(created_harvest_task.length).toBe(1); + expect(created_harvest_task[0].task_id).toBe(Number(task_ids[i])); + expect(created_harvest_task[0].projected_quantity).toBe(300); + } }); describe('transplant task tests', () => { @@ -1205,16 +1145,14 @@ describe('Task tests', () => { } ['row_method', 'bed_method', 'container_method'].map((planting_method) => { - test(`should create ${planting_method} transplant tasks`, async (done) => { + test(`should create ${planting_method} transplant tasks`, async () => { const { transplant_task, userFarm } = await getBody(planting_method); - postTransplantTaskRequest(userFarm, transplant_task, async (err, res) => { - await expectPlantingMethodPosted(res, transplant_task); - done(); - }); + const res = await postTransplantTaskRequest(userFarm, transplant_task); + await expectPlantingMethodPosted(res, transplant_task); }); }); - test(`should fail to create a transplant task when plan's location is for a different farm`, async (done) => { + test(`should fail to create a transplant task when plan's location is for a different farm`, async () => { const [userFarm2] = await generateUserFarms(1); const [{ location_id: locationIdInFarm2 }] = await mocks.fieldFactory({ promisedFarm: [{ farm_id: userFarm2.farm_id }], @@ -1222,13 +1160,11 @@ describe('Task tests', () => { const { transplant_task, userFarm } = await getBody('row_method'); transplant_task.transplant_task.planting_management_plan.location_id = locationIdInFarm2; - postTransplantTaskRequest(userFarm, transplant_task, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await postTransplantTaskRequest(userFarm, transplant_task); + expect(res.status).toBe(403); }); - test(`should fail to create a transplant task when previous plan is for different farm's location`, async (done) => { + test(`should fail to create a transplant task when previous plan is for different farm's location`, async () => { const [userFarm2] = await generateUserFarms(1); const { transplant_task, userFarm } = await getBody('row_method'); const [ @@ -1236,10 +1172,8 @@ describe('Task tests', () => { ] = await mocks.planting_management_planFactory({ promisedFarm: [userFarm2] }); transplant_task.transplant_task.prev_planting_management_plan_id = prev_planting_management_plan_id; - postTransplantTaskRequest(userFarm, transplant_task, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await postTransplantTaskRequest(userFarm, transplant_task); + expect(res.status).toBe(403); }); }); @@ -1282,7 +1216,7 @@ describe('Task tests', () => { // }); Object.keys(fakeTaskData).map((type) => { - test(`should successfully create a ${type} with a management plan`, async (done) => { + test(`should successfully create a ${type} with a management plan`, async () => { const { user_id, farm_id, @@ -1304,26 +1238,24 @@ describe('Task tests', () => { if (tasksWithProducts.some((task) => task == type)) { data[`${type}_products`] = await fakeProductData[`${type}_products`](farm_id); } - postTaskRequest({ user_id, farm_id }, type, data, async (err, res) => { - expect(res.status).toBe(201); - const { task_id } = res.body; - const createdTask = await knex('task').where({ task_id }).first(); - expect(createdTask).toBeDefined(); - const isTaskRelatedToLocation = await knex('location_tasks').where({ task_id }).first(); - expect(isTaskRelatedToLocation.location_id).toBe(location_id); - expect(isTaskRelatedToLocation.task_id).toBe(task_id); - const isTaskRelatedToManagementPlans = await knex('management_tasks').where({ - task_id, - }); - expect(isTaskRelatedToManagementPlans.length).toBe(1); - const specificTask = await knex(type).where({ task_id }); - expect(specificTask.length).toBe(1); - expect(specificTask[0].task_id).toBe(task_id); - done(); + const res = await postTaskRequest({ user_id, farm_id }, type, data); + expect(res.status).toBe(201); + const { task_id } = res.body; + const createdTask = await knex('task').where({ task_id }).first(); + expect(createdTask).toBeDefined(); + const isTaskRelatedToLocation = await knex('location_tasks').where({ task_id }).first(); + expect(isTaskRelatedToLocation.location_id).toBe(location_id); + expect(isTaskRelatedToLocation.task_id).toBe(task_id); + const isTaskRelatedToManagementPlans = await knex('management_tasks').where({ + task_id, }); + expect(isTaskRelatedToManagementPlans.length).toBe(1); + const specificTask = await knex(type).where({ task_id }); + expect(specificTask.length).toBe(1); + expect(specificTask[0].task_id).toBe(task_id); }); - test(`should fail to create a ${type} when locations contain different farm's location`, async (done) => { + test(`should fail to create a ${type} when locations contain different farm's location`, async () => { const [userFarm1, userFarm2] = await generateUserFarms(2); const { farm_id, user_id } = userFarm1; const [{ location_id }] = await mocks.fieldFactory({ @@ -1354,13 +1286,11 @@ describe('Task tests', () => { managementPlans: [{ planting_management_plan_id }], }; - postTaskRequest({ user_id, farm_id }, type, data, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await postTaskRequest({ user_id, farm_id }, type, data); + expect(res.status).toBe(403); }); - test(`should fail to create a ${type} when any managementPlan is for different farm's location`, async (done) => { + test(`should fail to create a ${type} when any managementPlan is for different farm's location`, async () => { const [userFarm1, userFarm2] = await generateUserFarms(2); const { farm_id, user_id } = userFarm1; const [{ location_id }] = await mocks.fieldFactory({ @@ -1416,14 +1346,12 @@ describe('Task tests', () => { managementPlans, }; - postTaskRequest({ user_id, farm_id }, type, data, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await postTaskRequest({ user_id, farm_id }, type, data); + expect(res.status).toBe(403); }); }); - test('should create a task (i.e soil amendment) with multiple management plans', async (done) => { + test('should create a task (i.e soil amendment) with multiple management plans', async () => { const { user_id, farm_id, location_id, task_type_id } = await userFarmTaskGenerator(true); const promisedManagement = await Promise.all( [...Array(3)].map(async () => @@ -1478,21 +1406,19 @@ describe('Task tests', () => { managementPlans, }; - postTaskRequest({ user_id, farm_id }, 'soil_amendment_task', data, async (err, res) => { - expect(res.status).toBe(201); - const { task_id } = res.body; - const createdTask = await knex('task').where({ task_id }).first(); - expect(createdTask).toBeDefined(); - const isTaskRelatedToLocation = await knex('location_tasks').where({ task_id }).first(); - expect(isTaskRelatedToLocation.location_id).toBe(location_id); - expect(isTaskRelatedToLocation.task_id).toBe(task_id); - const isTaskRelatedToManagementPlans = await knex('management_tasks').where({ task_id }); - expect(isTaskRelatedToManagementPlans.length).toBe(3); - done(); - }); + const res = await postTaskRequest({ user_id, farm_id }, 'soil_amendment_task', data); + expect(res.status).toBe(201); + const { task_id } = res.body; + const createdTask = await knex('task').where({ task_id }).first(); + expect(createdTask).toBeDefined(); + const isTaskRelatedToLocation = await knex('location_tasks').where({ task_id }).first(); + expect(isTaskRelatedToLocation.location_id).toBe(location_id); + expect(isTaskRelatedToLocation.task_id).toBe(task_id); + const isTaskRelatedToManagementPlans = await knex('management_tasks').where({ task_id }); + expect(isTaskRelatedToManagementPlans.length).toBe(3); }); - test('should create a task (i.e soil amendment) and override wage', async (done) => { + test('should create a task (i.e soil amendment) and override wage', async () => { const { user_id, farm_id, location_id, task_type_id } = await userFarmTaskGenerator(true); const promisedManagement = await Promise.all( [...Array(3)].map(async () => @@ -1547,22 +1473,20 @@ describe('Task tests', () => { managementPlans, }; - postTaskRequest({ user_id, farm_id }, 'soil_amendment_task', data, async (err, res) => { - expect(res.status).toBe(201); - const { task_id } = res.body; - const createdTask = await knex('task').where({ task_id }).first(); - expect(createdTask).toBeDefined(); - const isTaskRelatedToLocation = await knex('location_tasks').where({ task_id }).first(); - expect(isTaskRelatedToLocation.location_id).toBe(location_id); - expect(isTaskRelatedToLocation.task_id).toBe(task_id); - expect(createdTask.wage_at_moment).toBe(50); - const isTaskRelatedToManagementPlans = await knex('management_tasks').where({ task_id }); - expect(isTaskRelatedToManagementPlans.length).toBe(3); - done(); - }); - }); - - test('should create a task (i.e pest control) and patch a product', async (done) => { + const res = await postTaskRequest({ user_id, farm_id }, 'soil_amendment_task', data); + expect(res.status).toBe(201); + const { task_id } = res.body; + const createdTask = await knex('task').where({ task_id }).first(); + expect(createdTask).toBeDefined(); + const isTaskRelatedToLocation = await knex('location_tasks').where({ task_id }).first(); + expect(isTaskRelatedToLocation.location_id).toBe(location_id); + expect(isTaskRelatedToLocation.task_id).toBe(task_id); + expect(createdTask.wage_at_moment).toBe(50); + const isTaskRelatedToManagementPlans = await knex('management_tasks').where({ task_id }); + expect(isTaskRelatedToManagementPlans.length).toBe(3); + }); + + test('should create a task (i.e pest control) and patch a product', async () => { const { user_id, farm_id, location_id, task_type_id } = await userFarmTaskGenerator(true); const promisedManagement = await Promise.all( [...Array(3)].map(async () => @@ -1604,25 +1528,23 @@ describe('Task tests', () => { managementPlans, }; - postTaskRequest({ user_id, farm_id }, 'pest_control_task', data, async (err, res) => { - expect(res.status).toBe(201); - const { task_id } = res.body; - const { product_id } = res.body.pest_control_task; - const createdTask = await knex('task').where({ task_id }).first(); - expect(createdTask).toBeDefined(); - const isTaskRelatedToLocation = await knex('location_tasks').where({ task_id }).first(); - expect(isTaskRelatedToLocation.location_id).toBe(location_id); - expect(isTaskRelatedToLocation.task_id).toBe(task_id); - expect(createdTask.wage_at_moment).toBe(50); - const isTaskRelatedToManagementPlans = await knex('management_tasks').where({ task_id }); - expect(isTaskRelatedToManagementPlans.length).toBe(3); - const specificProduct = await knex('product').where({ product_id }).first(); - expect(specificProduct.name).toBe('pestProduct'); - done(); - }); - }); - - test('should create a task (i.e pest control) and create a product', async (done) => { + const res = await postTaskRequest({ user_id, farm_id }, 'pest_control_task', data); + expect(res.status).toBe(201); + const { task_id } = res.body; + const { product_id } = res.body.pest_control_task; + const createdTask = await knex('task').where({ task_id }).first(); + expect(createdTask).toBeDefined(); + const isTaskRelatedToLocation = await knex('location_tasks').where({ task_id }).first(); + expect(isTaskRelatedToLocation.location_id).toBe(location_id); + expect(isTaskRelatedToLocation.task_id).toBe(task_id); + expect(createdTask.wage_at_moment).toBe(50); + const isTaskRelatedToManagementPlans = await knex('management_tasks').where({ task_id }); + expect(isTaskRelatedToManagementPlans.length).toBe(3); + const specificProduct = await knex('product').where({ product_id }).first(); + expect(specificProduct.name).toBe('pestProduct'); + }); + + test('should create a task (i.e pest control) and create a product', async () => { const { user_id, farm_id, location_id, task_type_id } = await userFarmTaskGenerator(true); const promisedManagement = await Promise.all( [...Array(3)].map(async () => @@ -1666,25 +1588,23 @@ describe('Task tests', () => { managementPlans, }; - postTaskRequest({ user_id, farm_id }, 'pest_control_task', data, async (err, res) => { - expect(res.status).toBe(201); - const { task_id } = res.body; - const { product_id } = res.body.pest_control_task; - const createdTask = await knex('task').where({ task_id }).first(); - expect(createdTask).toBeDefined(); - const isTaskRelatedToLocation = await knex('location_tasks').where({ task_id }).first(); - expect(isTaskRelatedToLocation.location_id).toBe(location_id); - expect(isTaskRelatedToLocation.task_id).toBe(task_id); - expect(createdTask.wage_at_moment).toBe(50); - const isTaskRelatedToManagementPlans = await knex('management_tasks').where({ task_id }); - expect(isTaskRelatedToManagementPlans.length).toBe(3); - const specificProduct = await knex('product').where({ product_id }).first(); - expect(specificProduct.name).toBe('pestProduct2'); - done(); - }); - }); - - test('should fail to create a task were a worker is trying to assign someone else', async (done) => { + const res = await postTaskRequest({ user_id, farm_id }, 'pest_control_task', data); + expect(res.status).toBe(201); + const { task_id } = res.body; + const { product_id } = res.body.pest_control_task; + const createdTask = await knex('task').where({ task_id }).first(); + expect(createdTask).toBeDefined(); + const isTaskRelatedToLocation = await knex('location_tasks').where({ task_id }).first(); + expect(isTaskRelatedToLocation.location_id).toBe(location_id); + expect(isTaskRelatedToLocation.task_id).toBe(task_id); + expect(createdTask.wage_at_moment).toBe(50); + const isTaskRelatedToManagementPlans = await knex('management_tasks').where({ task_id }); + expect(isTaskRelatedToManagementPlans.length).toBe(3); + const specificProduct = await knex('product').where({ product_id }).first(); + expect(specificProduct.name).toBe('pestProduct2'); + }); + + test('should fail to create a task were a worker is trying to assign someone else', async () => { const { farm_id, location_id, @@ -1710,18 +1630,15 @@ describe('Task tests', () => { managementPlans: [{ management_plan_id }], }; - postTaskRequest( + const res = await postTaskRequest( { user_id: worker_id, farm_id }, 'soil_amendment_task', data, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, ); + expect(res.status).toBe(403); }); - test('should fail to create a task were a worker is trying to modify wage for himself ', async (done) => { + test('should fail to create a task were a worker is trying to modify wage for himself ', async () => { const { farm_id, location_id, @@ -1744,15 +1661,12 @@ describe('Task tests', () => { managementPlans: [{ management_plan_id }], }; - postTaskRequest( + const res = await postTaskRequest( { user_id: worker_id, farm_id }, 'soil_amendment_task', data, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, ); + expect(res.status).toBe(403); }); }); }); @@ -1819,7 +1733,7 @@ describe('Task tests', () => { completion_notes: notes, }; - test('should return 403 if non-assignee tries to complete task', async (done) => { + test('should return 403 if non-assignee tries to complete task', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const [{ user_id: another_id }] = await mocks.userFarmFactory( { promisedFarm: [{ farm_id }] }, @@ -1831,25 +1745,23 @@ describe('Task tests', () => { promisedTask: [{ task_id }], promisedField: [{ location_id }], }); - assignTaskRequest({ user_id, farm_id }, { assignee_user_id: user_id }, task_id, async () => { - completeTaskRequest( - { user_id: another_id, farm_id }, - { - ...fakeCompletionData, - pest_control_task: fakeTaskData.pest_control_task(), - assignee_user_id: user_id, - }, - task_id, - 'pest_control_task', - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); - }); + await assignTaskRequest({ user_id, farm_id }, { assignee_user_id: user_id }, task_id); + + const res = await completeTaskRequest( + { user_id: another_id, farm_id }, + { + ...fakeCompletionData, + pest_control_task: fakeTaskData.pest_control_task(), + assignee_user_id: user_id, + }, + task_id, + 'pest_control_task', + ); + + expect(res.status).toBe(403); }); - test('should be able to complete a soil amendment task', async (done) => { + test('should be able to complete a soil amendment task', async () => { const userFarm = { ...fakeUserFarm(1), wage: { type: '', amount: 30 } }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, userFarm); const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id }] }); @@ -1878,7 +1790,7 @@ describe('Task tests', () => { farm_id, ); - completeTaskRequest( + const res = await completeTaskRequest( { user_id, farm_id }, { ...fakeCompletionData, @@ -1888,23 +1800,21 @@ describe('Task tests', () => { }, task_id, 'soil_amendment_task', - async (err, res) => { - expect(res.status).toBe(200); - const completed_task = await knex('task').where({ task_id }).first(); - expect(toLocal8601Extended(completed_task.complete_date)).toBe(complete_date); - expect(completed_task.duration).toBe(duration); - expect(completed_task.happiness).toBe(happiness); - expect(completed_task.completion_notes).toBe(notes); - const patched_soil_amendment_task = await knex('soil_amendment_task') - .where({ task_id }) - .first(); - expect(patched_soil_amendment_task.purpose).toBe(new_soil_amendment_task.purpose); - done(); - }, ); + + expect(res.status).toBe(200); + const completed_task = await knex('task').where({ task_id }).first(); + expect(toLocal8601Extended(completed_task.complete_date)).toBe(complete_date); + expect(completed_task.duration).toBe(duration); + expect(completed_task.happiness).toBe(happiness); + expect(completed_task.completion_notes).toBe(notes); + const patched_soil_amendment_task = await knex('soil_amendment_task') + .where({ task_id }) + .first(); + expect(patched_soil_amendment_task.purpose).toBe(new_soil_amendment_task.purpose); }); - test('should be able to update a soil amendment task', async (done) => { + test('should be able to update a soil amendment task', async () => { const userFarm = { ...fakeUserFarm(1), wage: { type: '', amount: 30 } }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, userFarm); const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id }] }); @@ -1971,30 +1881,29 @@ describe('Task tests', () => { locations: [{ location_id }], }; - // Add task - postTaskRequest({ user_id, farm_id }, 'soil_amendment_task', taskData, async (err, res) => { - expect(res.status).toBe(201); - const createdTask = res.body; - const createdTaskProducts = createdTask.soil_amendment_task_products; - const { task_id } = createdTask; - // Delete abandonment reason to prevent validation error - delete createdTask.abandonment_reason; - - // Remove a purpose relationship - const taskProductIdForDeletedPurpose = createdTaskProducts[0].id; - const deletedPurposeRelationship = createdTaskProducts[0].purpose_relationships.pop(); - // Delete a task product - const deletedTaskProduct = createdTaskProducts.pop(); - // Add a new task product - createdTaskProducts.push( - mocks.fakeSoilAmendmentTaskProduct({ - product_id: soilAmendmentProductThree.product_id, - purpose_relationships: [{ purpose_id: soilAmendmentPurpose }], - }), - ); + const res = await postTaskRequest({ user_id, farm_id }, 'soil_amendment_task', taskData); + expect(res.status).toBe(201); + const createdTask = res.body; + const createdTaskProducts = createdTask.soil_amendment_task_products; + const { task_id } = createdTask; + // Delete abandonment reason to prevent validation error + delete createdTask.abandonment_reason; + + // Remove a purpose relationship + const taskProductIdForDeletedPurpose = createdTaskProducts[0].id; + const deletedPurposeRelationship = createdTaskProducts[0].purpose_relationships.pop(); + // Delete a task product + const deletedTaskProduct = createdTaskProducts.pop(); + // Add a new task product + createdTaskProducts.push( + mocks.fakeSoilAmendmentTaskProduct({ + product_id: soilAmendmentProductThree.product_id, + purpose_relationships: [{ purpose_id: soilAmendmentPurpose }], + }), + ); - // Update the task - completeTaskRequest( + { + const res = await completeTaskRequest( { user_id, farm_id }, { ...createdTask, @@ -2002,51 +1911,47 @@ describe('Task tests', () => { }, task_id, 'soil_amendment_task', - async (err, res) => { - expect(res.status).toBe(200); - - // Two active and one deleted task product should be present - const completed_task_products = await knex('soil_amendment_task_products').where({ - task_id, - }); - expect(completed_task_products.length).toBe(3); - expect( - completed_task_products.find((prod) => prod.id == deletedTaskProduct.id).deleted, - ).toBe(true); - const completed_soil_amendment_task_products_purpose_relationship = await knex( - 'soil_amendment_task_products_purpose_relationship', - ).whereIn('task_products_id', [ - completed_task_products[0].id, - completed_task_products[1].id, - completed_task_products[2].id, - ]); - expect(completed_soil_amendment_task_products_purpose_relationship.length).toBe(3); - - // The relationship created originally should be hard deleted - const deletedRelationship = await knex( - 'soil_amendment_task_products_purpose_relationship', - ).where('task_products_id', taskProductIdForDeletedPurpose); - expect(deletedRelationship.length).toBe(1); - expect(deletedRelationship[0].purpose_id).not.toBe( - deletedPurposeRelationship.purpose_id, - ); - - // The added product should be present and have a relationship - const addedTaskProduct = await knex('soil_amendment_task_products') - .where({ task_id }) - .andWhere({ product_id: soilAmendmentProductThree.product_id }); - expect(addedTaskProduct.length).toBe(1); - const addedRelationship = await knex( - 'soil_amendment_task_products_purpose_relationship', - ).where('task_products_id', addedTaskProduct[0].id); - expect(addedRelationship.length).toBe(1); - done(); - }, ); - }); + + expect(res.status).toBe(200); + + // Two active and one deleted task product should be present + const completed_task_products = await knex('soil_amendment_task_products').where({ + task_id, + }); + expect(completed_task_products.length).toBe(3); + expect( + completed_task_products.find((prod) => prod.id == deletedTaskProduct.id).deleted, + ).toBe(true); + const completed_soil_amendment_task_products_purpose_relationship = await knex( + 'soil_amendment_task_products_purpose_relationship', + ).whereIn('task_products_id', [ + completed_task_products[0].id, + completed_task_products[1].id, + completed_task_products[2].id, + ]); + expect(completed_soil_amendment_task_products_purpose_relationship.length).toBe(3); + + // The relationship created originally should be hard deleted + const deletedRelationship = await knex( + 'soil_amendment_task_products_purpose_relationship', + ).where('task_products_id', taskProductIdForDeletedPurpose); + expect(deletedRelationship.length).toBe(1); + expect(deletedRelationship[0].purpose_id).not.toBe(deletedPurposeRelationship.purpose_id); + + // The added product should be present and have a relationship + const addedTaskProduct = await knex('soil_amendment_task_products') + .where({ task_id }) + .andWhere({ product_id: soilAmendmentProductThree.product_id }); + expect(addedTaskProduct.length).toBe(1); + const addedRelationship = await knex( + 'soil_amendment_task_products_purpose_relationship', + ).where('task_products_id', addedTaskProduct[0].id); + expect(addedRelationship.length).toBe(1); + } }); - test('should not be able to delete the last purpose', async (done) => { + test('should not be able to delete the last purpose', async () => { const userFarm = { ...fakeUserFarm(1), wage: { type: '', amount: 30 } }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, userFarm); const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id }] }); @@ -2104,24 +2009,23 @@ describe('Task tests', () => { locations: [{ location_id }], }; - // Add task - postTaskRequest({ user_id, farm_id }, 'soil_amendment_task', taskData, async (err, res) => { - expect(res.status).toBe(201); - const createdTask = res.body; - const createdTaskProducts = createdTask.soil_amendment_task_products; - const { task_id } = createdTask; - // Delete abandonment reason to prevent validation error - delete createdTask.abandonment_reason; - - // Remove all purpose relationships - const taskProductForDeletedPurpose = createdTaskProducts.find( - (product) => product.product_id == soilAmendmentProductTwo.product_id, - ); - const taskProductIdForDeletedPurpose = taskProductForDeletedPurpose.id; - taskProductForDeletedPurpose.purpose_relationships.pop(); + const res = await postTaskRequest({ user_id, farm_id }, 'soil_amendment_task', taskData); + expect(res.status).toBe(201); + const createdTask = res.body; + const createdTaskProducts = createdTask.soil_amendment_task_products; + const { task_id } = createdTask; + // Delete abandonment reason to prevent validation error + delete createdTask.abandonment_reason; + + // Remove all purpose relationships + const taskProductForDeletedPurpose = createdTaskProducts.find( + (product) => product.product_id == soilAmendmentProductTwo.product_id, + ); + const taskProductIdForDeletedPurpose = taskProductForDeletedPurpose.id; + taskProductForDeletedPurpose.purpose_relationships.pop(); - // Update the task - completeTaskRequest( + { + const res = await completeTaskRequest( { user_id, farm_id }, { ...createdTask, @@ -2129,19 +2033,17 @@ describe('Task tests', () => { }, task_id, 'soil_amendment_task', - async (err, res) => { - expect(res.status).toBe(400); - const completed_soil_amendment_task_products_purpose_relationship = await knex( - 'soil_amendment_task_products_purpose_relationship', - ).whereIn('task_products_id', [taskProductIdForDeletedPurpose]); - expect(completed_soil_amendment_task_products_purpose_relationship.length).toBe(1); - done(); - }, ); - }); + + expect(res.status).toBe(400); + const completed_soil_amendment_task_products_purpose_relationship = await knex( + 'soil_amendment_task_products_purpose_relationship', + ).whereIn('task_products_id', [taskProductIdForDeletedPurpose]); + expect(completed_soil_amendment_task_products_purpose_relationship.length).toBe(1); + } }); - test('should not be able to delete the last product', async (done) => { + test('should not be able to delete the last product', async () => { const userFarm = { ...fakeUserFarm(1), wage: { type: '', amount: 30 } }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, userFarm); const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id }] }); @@ -2182,19 +2084,19 @@ describe('Task tests', () => { locations: [{ location_id }], }; - // Add task - postTaskRequest({ user_id, farm_id }, 'soil_amendment_task', taskData, async (err, res) => { - expect(res.status).toBe(201); - const createdTask = res.body; - const createdTaskProducts = createdTask.soil_amendment_task_products; - const { task_id } = createdTask; - // Delete abandonment reason to prevent validation error - delete createdTask.abandonment_reason; + const res = await postTaskRequest({ user_id, farm_id }, 'soil_amendment_task', taskData); + expect(res.status).toBe(201); + const createdTask = res.body; + const createdTaskProducts = createdTask.soil_amendment_task_products; + const { task_id } = createdTask; + // Delete abandonment reason to prevent validation error + delete createdTask.abandonment_reason; - // Delete a task product - const deletedTaskProductOne = createdTaskProducts.pop(); + // Delete a task product + const deletedTaskProductOne = createdTaskProducts.pop(); - completeTaskRequest( + { + const res = await completeTaskRequest( { user_id, farm_id }, { ...createdTask, @@ -2202,22 +2104,20 @@ describe('Task tests', () => { }, task_id, 'soil_amendment_task', - async (err, res) => { - expect(res.status).toBe(400); - - // One deleted task product should be present - const completed_task_products = await knex('soil_amendment_task_products').where({ - task_id, - }); - expect(completed_task_products.length).toBe(1); - expect(completed_task_products[0].deleted).toBe(false); - done(); - }, ); - }); + + expect(res.status).toBe(400); + + // One deleted task product should be present + const completed_task_products = await knex('soil_amendment_task_products').where({ + task_id, + }); + expect(completed_task_products.length).toBe(1); + expect(completed_task_products[0].deleted).toBe(false); + } }); - test('should not be able set deleted to true on the last product', async (done) => { + test('should not be able set deleted to true on the last product', async () => { const userFarm = { ...fakeUserFarm(1), wage: { type: '', amount: 30 } }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, userFarm); const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id }] }); @@ -2262,18 +2162,18 @@ describe('Task tests', () => { locations: [{ location_id }], }; - // Add task - postTaskRequest({ user_id, farm_id }, 'soil_amendment_task', taskData, async (err, res) => { - expect(res.status).toBe(201); - const createdTask = res.body; - const { task_id } = createdTask; - // Delete abandonment reason to prevent validation error - delete createdTask.abandonment_reason; + const res = await postTaskRequest({ user_id, farm_id }, 'soil_amendment_task', taskData); + expect(res.status).toBe(201); + const createdTask = res.body; + const { task_id } = createdTask; + // Delete abandonment reason to prevent validation error + delete createdTask.abandonment_reason; - // Delete a task product - createdTask.soil_amendment_task_products[0].deleted = true; + // Delete a task product + createdTask.soil_amendment_task_products[0].deleted = true; - completeTaskRequest( + { + const res = await completeTaskRequest( { user_id, farm_id }, { ...createdTask, @@ -2281,22 +2181,20 @@ describe('Task tests', () => { }, task_id, 'soil_amendment_task', - async (err, res) => { - expect(res.status).toBe(400); - - // One deleted task product should be present - const completed_task_products = await knex('soil_amendment_task_products').where({ - task_id, - }); - expect(completed_task_products.length).toBe(1); - expect(completed_task_products[0].deleted).toBe(false); - done(); - }, ); - }); + + expect(res.status).toBe(400); + + // One deleted task product should be present + const completed_task_products = await knex('soil_amendment_task_products').where({ + task_id, + }); + expect(completed_task_products.length).toBe(1); + expect(completed_task_products[0].deleted).toBe(false); + } }); - test('should be able to switch product ids on complete product by updating product id and adding removed product as new back in', async (done) => { + test('should be able to switch product ids on complete product by updating product id and adding removed product as new back in', async () => { const userFarm = { ...fakeUserFarm(1), wage: { type: '', amount: 30 } }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, userFarm); const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id }] }); @@ -2348,35 +2246,35 @@ describe('Task tests', () => { locations: [{ location_id }], }; - // Add task - postTaskRequest({ user_id, farm_id }, 'soil_amendment_task', taskData, async (err, res) => { - expect(res.status).toBe(201); - const createdTask = res.body; - const { task_id } = createdTask; - // Delete abandonment reason to prevent validation error - delete createdTask.abandonment_reason; - - // Find index of second task product - const indexOfFirstProduct = createdTask.soil_amendment_task_products.findIndex( - (tp) => tp.product_id === soilAmendmentProductOne.product_id, - ); - const indexOfSecondProduct = createdTask.soil_amendment_task_products.findIndex( - (tp) => tp.product_id === soilAmendmentProductTwo.product_id, - ); + const res = await postTaskRequest({ user_id, farm_id }, 'soil_amendment_task', taskData); + expect(res.status).toBe(201); + const createdTask = res.body; + const { task_id } = createdTask; + // Delete abandonment reason to prevent validation error + delete createdTask.abandonment_reason; - // Replace second task product with new taskProduct with id of first task product - createdTask.soil_amendment_task_products[ - indexOfSecondProduct - ] = mocks.fakeSoilAmendmentTaskProduct({ - product_id: soilAmendmentProductOne.product_id, - purpose_relationships: [{ purpose_id: soilAmendmentPurpose }], - }); + // Find index of second task product + const indexOfFirstProduct = createdTask.soil_amendment_task_products.findIndex( + (tp) => tp.product_id === soilAmendmentProductOne.product_id, + ); + const indexOfSecondProduct = createdTask.soil_amendment_task_products.findIndex( + (tp) => tp.product_id === soilAmendmentProductTwo.product_id, + ); - // Update first task product id to second product id - createdTask.soil_amendment_task_products[indexOfFirstProduct].product_id = - soilAmendmentProductTwo.product_id; + // Replace second task product with new taskProduct with id of first task product + createdTask.soil_amendment_task_products[ + indexOfSecondProduct + ] = mocks.fakeSoilAmendmentTaskProduct({ + product_id: soilAmendmentProductOne.product_id, + purpose_relationships: [{ purpose_id: soilAmendmentPurpose }], + }); + + // Update first task product id to second product id + createdTask.soil_amendment_task_products[indexOfFirstProduct].product_id = + soilAmendmentProductTwo.product_id; - completeTaskRequest( + { + const res = await completeTaskRequest( { user_id, farm_id }, { ...createdTask, @@ -2384,21 +2282,19 @@ describe('Task tests', () => { }, task_id, 'soil_amendment_task', - async (err, res) => { - expect(res.status).toBe(200); - - // One deleted task product should be present - const completed_task_products = await knex('soil_amendment_task_products').where({ - task_id, - }); - expect(completed_task_products.length).toBe(3); - done(); - }, ); - }); + + expect(res.status).toBe(200); + + // One deleted task product should be present + const completed_task_products = await knex('soil_amendment_task_products').where({ + task_id, + }); + expect(completed_task_products.length).toBe(3); + } }); - test('should be able to complete a pest control task', async (done) => { + test('should be able to complete a pest control task', async () => { const userFarm = { ...fakeUserFarm(1), wage: { type: '', amount: 30 } }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, userFarm); const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id }] }); @@ -2424,7 +2320,7 @@ describe('Task tests', () => { const new_pest_control_task = fakeTaskData.pest_control_task(); - completeTaskRequest( + const res = await completeTaskRequest( { user_id, farm_id }, { ...fakeCompletionData, @@ -2432,29 +2328,23 @@ describe('Task tests', () => { }, task_id, 'pest_control_task', - async (err, res) => { - expect(res.status).toBe(200); - const completed_task = await knex('task').where({ task_id }).first(); - expect(toLocal8601Extended(completed_task.complete_date)).toBe(complete_date); - expect(completed_task.duration).toBe(duration); - expect(completed_task.happiness).toBe(happiness); - expect(completed_task.completion_notes).toBe(notes); - const patched_pest_control_task = await knex('pest_control_task') - .where({ task_id }) - .first(); - expect(patched_pest_control_task.volume || patched_pest_control_task.weight).toBe( - new_pest_control_task.product_quantity, - ); - expect(patched_pest_control_task.pest_target).toBe(new_pest_control_task.pest_target); - expect(patched_pest_control_task.control_method).toBe( - new_pest_control_task.control_method, - ); - done(); - }, ); + + expect(res.status).toBe(200); + const completed_task = await knex('task').where({ task_id }).first(); + expect(toLocal8601Extended(completed_task.complete_date)).toBe(complete_date); + expect(completed_task.duration).toBe(duration); + expect(completed_task.happiness).toBe(happiness); + expect(completed_task.completion_notes).toBe(notes); + const patched_pest_control_task = await knex('pest_control_task').where({ task_id }).first(); + expect(patched_pest_control_task.volume || patched_pest_control_task.weight).toBe( + new_pest_control_task.product_quantity, + ); + expect(patched_pest_control_task.pest_target).toBe(new_pest_control_task.pest_target); + expect(patched_pest_control_task.control_method).toBe(new_pest_control_task.control_method); }); - test('should be able to complete a field work task with a new custom field work task type', async (done) => { + test('should be able to complete a field work task with a new custom field work task type', async () => { const userFarm = { ...fakeUserFarm(1), wage: { type: '', amount: 30 } }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, userFarm); const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id }] }); @@ -2479,7 +2369,8 @@ describe('Task tests', () => { await mocks.field_work_taskFactory({ promisedTask: [{ task_id }] }); const new_field_work_task = customFieldWorkTask(faker.lorem.words(2)); - completeTaskRequest( + + const res = await completeTaskRequest( { user_id, farm_id }, { ...fakeCompletionData, @@ -2487,19 +2378,17 @@ describe('Task tests', () => { }, task_id, 'field_work_task', - async (err, res) => { - expect(res.status).toBe(200); - const completed_task = await knex('task').where({ task_id }).first(); - expect(toLocal8601Extended(completed_task.complete_date)).toBe(complete_date); - expect(completed_task.duration).toBe(duration); - expect(completed_task.happiness).toBe(happiness); - expect(completed_task.completion_notes).toBe(notes); - done(); - }, ); + + expect(res.status).toBe(200); + const completed_task = await knex('task').where({ task_id }).first(); + expect(toLocal8601Extended(completed_task.complete_date)).toBe(complete_date); + expect(completed_task.duration).toBe(duration); + expect(completed_task.happiness).toBe(happiness); + expect(completed_task.completion_notes).toBe(notes); }); - test('should be able to complete a harvest task', async (done) => { + test('should be able to complete a harvest task', async () => { const userFarm = { ...fakeUserFarm(1), wage: { type: '', amount: 30 } }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, userFarm); const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id }] }); @@ -2541,7 +2430,8 @@ describe('Task tests', () => { harvest_uses.push(harvest_use); actual_quantity += harvest_use.quantity; }); - completeTaskRequest( + + const res = await completeTaskRequest( { user_id, farm_id }, { task: { ...fakeCompletionData, harvest_task: { task_id, actual_quantity } }, @@ -2549,26 +2439,24 @@ describe('Task tests', () => { }, task_id, 'harvest_task', - async (err, res) => { - expect(res.status).toBe(200); - const completed_task = await knex('task').where({ task_id }).first(); - expect(toLocal8601Extended(completed_task.complete_date)).toBe(complete_date); - expect(completed_task.duration).toBe(duration); - expect(completed_task.happiness).toBe(happiness); - expect(completed_task.completion_notes).toBe(notes); - const new_harvest_uses = await knex('harvest_use').where({ task_id }); - expect(new_harvest_uses.length).toBe(harvest_uses.length); - const patched_harvest_task = await knex('harvest_task').where({ task_id }).first(); - expect(patched_harvest_task.actual_quantity).toBe(actual_quantity); - let harvest_uses_quantity = 0; - new_harvest_uses.forEach(({ quantity }) => (harvest_uses_quantity += quantity)); - expect(harvest_uses_quantity).toBe(actual_quantity); - done(); - }, ); + + expect(res.status).toBe(200); + const completed_task = await knex('task').where({ task_id }).first(); + expect(toLocal8601Extended(completed_task.complete_date)).toBe(complete_date); + expect(completed_task.duration).toBe(duration); + expect(completed_task.happiness).toBe(happiness); + expect(completed_task.completion_notes).toBe(notes); + const new_harvest_uses = await knex('harvest_use').where({ task_id }); + expect(new_harvest_uses.length).toBe(harvest_uses.length); + const patched_harvest_task = await knex('harvest_task').where({ task_id }).first(); + expect(patched_harvest_task.actual_quantity).toBe(actual_quantity); + let harvest_uses_quantity = 0; + new_harvest_uses.forEach(({ quantity }) => (harvest_uses_quantity += quantity)); + expect(harvest_uses_quantity).toBe(actual_quantity); }); - test('wage_at_moment should be updated when completing a harvest task', async (done) => { + test('wage_at_moment should be updated when completing a harvest task', async () => { const userFarm = { ...fakeUserFarm(1), wage: { type: '', amount: 30 } }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, userFarm); const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id }] }); @@ -2613,7 +2501,8 @@ describe('Task tests', () => { harvest_uses.push(harvest_use); actual_quantity += harvest_use.quantity; }); - completeTaskRequest( + + const res = await completeTaskRequest( { user_id, farm_id }, { task: { ...fakeCompletionData, harvest_task: { task_id, actual_quantity } }, @@ -2621,17 +2510,15 @@ describe('Task tests', () => { }, task_id, 'harvest_task', - async (err, res) => { - expect(res.status).toBe(200); - const completed_task = await knex('task').where({ task_id }).first(); - expect(completed_task.wage_at_moment).toBe(WAGE_AT_MOMENT); - done(); - }, ); + + expect(res.status).toBe(200); + const completed_task = await knex('task').where({ task_id }).first(); + expect(completed_task.wage_at_moment).toBe(WAGE_AT_MOMENT); }); //TODO: complete plant task test - xtest('should be able to complete a plant task', async (done) => { + xtest('should be able to complete a plant task', async () => { const userFarm = { ...fakeUserFarm(1), wage: { type: '', amount: 30 } }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, userFarm); const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id }] }); @@ -2657,7 +2544,7 @@ describe('Task tests', () => { const new_plant_task = fakeTaskData.plant_task(); - completeTaskRequest( + const res = await completeTaskRequest( { user_id, farm_id }, { ...fakeCompletionData, @@ -2665,22 +2552,20 @@ describe('Task tests', () => { }, task_id, 'plant_task', - async (err, res) => { - expect(res.status).toBe(200); - const completed_task = await knex('task').where({ task_id }).first(); - expect(completed_task.complete_date.toString()).toBe(complete_date.toString()); - expect(completed_task.duration).toBe(duration); - expect(completed_task.happiness).toBe(happiness); - expect(completed_task.completion_notes).toBe(notes); - const patched_plant_task = await knex('plant_task').where({ task_id }).first(); - expect(patched_plant_task.space_depth_cm).toBe(new_plant_task.space_depth_cm); - expect(patched_plant_task.space_length_cm).toBe(new_plant_task.space_length_cm); - expect(patched_plant_task.space_width_cm).toBe(new_plant_task.space_width_cm); - done(); - }, ); + + expect(res.status).toBe(200); + const completed_task = await knex('task').where({ task_id }).first(); + expect(completed_task.complete_date.toString()).toBe(complete_date.toString()); + expect(completed_task.duration).toBe(duration); + expect(completed_task.happiness).toBe(happiness); + expect(completed_task.completion_notes).toBe(notes); + const patched_plant_task = await knex('plant_task').where({ task_id }).first(); + expect(patched_plant_task.space_depth_cm).toBe(new_plant_task.space_depth_cm); + expect(patched_plant_task.space_length_cm).toBe(new_plant_task.space_length_cm); + expect(patched_plant_task.space_width_cm).toBe(new_plant_task.space_width_cm); }); - test('should complete a task (i.e pest control task) with multiple management plans', async (done) => { + test('should complete a task (i.e pest control task) with multiple management plans', async () => { const userFarm = { ...fakeUserFarm(1), wage: { type: '', amount: 30 } }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, userFarm); const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id }] }); @@ -2740,7 +2625,7 @@ describe('Task tests', () => { const new_pest_control_task = fakeTaskData.pest_control_task(); - completeTaskRequest( + const res = await completeTaskRequest( { user_id, farm_id }, { ...fakeCompletionData, @@ -2748,37 +2633,31 @@ describe('Task tests', () => { }, task_id, 'pest_control_task', - async (err, res) => { - expect(res.status).toBe(200); - const completed_task = await knex('task').where({ task_id }).first(); - expect(toLocal8601Extended(completed_task.complete_date)).toBe(complete_date); - expect(completed_task.duration).toBe(duration); - expect(completed_task.happiness).toBe(happiness); - expect(completed_task.completion_notes).toBe(notes); - const patched_pest_control_task = await knex('pest_control_task') - .where({ task_id }) - .first(); - expect(patched_pest_control_task.volume || patched_pest_control_task.weight).toBe( - new_pest_control_task.product_quantity, - ); - expect(patched_pest_control_task.control_method).toBe( - new_pest_control_task.control_method, - ); - const management_plan_1 = await knex('management_plan') - .where({ management_plan_id: promisedManagement[0][0].management_plan_id }) - .first(); - const management_plan_2 = await knex('management_plan') - .where({ management_plan_id: promisedManagement[1][0].management_plan_id }) - .first(); - const management_plan_3 = await knex('management_plan') - .where({ management_plan_id: promisedManagement[2][0].management_plan_id }) - .first(); - expect(toLocal8601Extended(management_plan_1.start_date)).toBe(complete_date); - expect(toLocal8601Extended(management_plan_2.start_date)).toBe(complete_date); - expect(toLocal8601Extended(management_plan_3.start_date)).toBe(complete_date); - done(); - }, ); + + expect(res.status).toBe(200); + const completed_task = await knex('task').where({ task_id }).first(); + expect(toLocal8601Extended(completed_task.complete_date)).toBe(complete_date); + expect(completed_task.duration).toBe(duration); + expect(completed_task.happiness).toBe(happiness); + expect(completed_task.completion_notes).toBe(notes); + const patched_pest_control_task = await knex('pest_control_task').where({ task_id }).first(); + expect(patched_pest_control_task.volume || patched_pest_control_task.weight).toBe( + new_pest_control_task.product_quantity, + ); + expect(patched_pest_control_task.control_method).toBe(new_pest_control_task.control_method); + const management_plan_1 = await knex('management_plan') + .where({ management_plan_id: promisedManagement[0][0].management_plan_id }) + .first(); + const management_plan_2 = await knex('management_plan') + .where({ management_plan_id: promisedManagement[1][0].management_plan_id }) + .first(); + const management_plan_3 = await knex('management_plan') + .where({ management_plan_id: promisedManagement[2][0].management_plan_id }) + .first(); + expect(toLocal8601Extended(management_plan_1.start_date)).toBe(complete_date); + expect(toLocal8601Extended(management_plan_2.start_date)).toBe(complete_date); + expect(toLocal8601Extended(management_plan_3.start_date)).toBe(complete_date); }); }); @@ -2792,7 +2671,7 @@ describe('Task tests', () => { abandon_date: new Date(), }; - test('An unassigned task should not abandoned with a rating', async (done) => { + test('An unassigned task should not abandoned with a rating', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const date = faker.date.future().toISOString().split('T')[0]; const [task] = await mocks.taskFactory( @@ -2805,18 +2684,15 @@ describe('Task tests', () => { ...abandonTaskBody, happiness: faker.datatype.number({ min: 1, max: 5 }), }; - abandonTaskRequest( + const res = await abandonTaskRequest( { user_id, farm_id }, abandonTaskBodyWithRating, task.task_id, - async (err, res) => { - expect(res.status).toBe(400); - done(); - }, ); + expect(res.status).toBe(400); }); - test('An unassigned task should not abandoned with a duration', async (done) => { + test('An unassigned task should not abandoned with a duration', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const date = faker.date.future().toISOString().split('T')[0]; const [task] = await mocks.taskFactory( @@ -2829,18 +2705,15 @@ describe('Task tests', () => { ...abandonTaskBody, duration: faker.datatype.number(1000), }; - abandonTaskRequest( + const res = await abandonTaskRequest( { user_id, farm_id }, abandonTaskBodyWithDuration, task.task_id, - async (err, res) => { - expect(res.status).toBe(400); - done(); - }, ); + expect(res.status).toBe(400); }); - test('Owner should be able to abandon a task', async (done) => { + test('Owner should be able to abandon a task', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const date = faker.date.future().toISOString().split('T')[0]; const [task] = await mocks.taskFactory( @@ -2851,18 +2724,16 @@ describe('Task tests', () => { ); const [location] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); await mocks.location_tasksFactory({ promisedTask: [task], promisedField: [location] }); - abandonTaskRequest({ user_id, farm_id }, abandonTaskBody, task.task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task.task_id); - expect(updated_task.abandon_date).toBeDefined(); - expect(updated_task.abandonment_reason).toBe(CROP_FAILURE); - expect(updated_task.other_abandonment_reason).toBe(null); - expect(updated_task.abandonment_notes).toBe(sampleNote); - done(); - }); + const res = await abandonTaskRequest({ user_id, farm_id }, abandonTaskBody, task.task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task.task_id); + expect(updated_task.abandon_date).toBeDefined(); + expect(updated_task.abandonment_reason).toBe(CROP_FAILURE); + expect(updated_task.other_abandonment_reason).toBe(null); + expect(updated_task.abandonment_notes).toBe(sampleNote); }); - test('Manager should be able to abandon a task', async (done) => { + test('Manager should be able to abandon a task', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(2)); const date = faker.date.future().toISOString().split('T')[0]; const [task] = await mocks.taskFactory( @@ -2871,18 +2742,16 @@ describe('Task tests', () => { ); const [location] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); await mocks.location_tasksFactory({ promisedTask: [task], promisedField: [location] }); - abandonTaskRequest({ user_id, farm_id }, abandonTaskBody, task.task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task.task_id); - expect(updated_task.abandon_date).toBeDefined(); - expect(updated_task.abandonment_reason).toBe(CROP_FAILURE); - expect(updated_task.other_abandonment_reason).toBe(null); - expect(updated_task.abandonment_notes).toBe(sampleNote); - done(); - }); + const res = await abandonTaskRequest({ user_id, farm_id }, abandonTaskBody, task.task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task.task_id); + expect(updated_task.abandon_date).toBeDefined(); + expect(updated_task.abandonment_reason).toBe(CROP_FAILURE); + expect(updated_task.other_abandonment_reason).toBe(null); + expect(updated_task.abandonment_notes).toBe(sampleNote); }); - test('EO should be able to abandon a task', async (done) => { + test('EO should be able to abandon a task', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(5)); const date = faker.date.future().toISOString().split('T')[0]; const [task] = await mocks.taskFactory( @@ -2891,18 +2760,16 @@ describe('Task tests', () => { ); const [location] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); await mocks.location_tasksFactory({ promisedTask: [task], promisedField: [location] }); - abandonTaskRequest({ user_id, farm_id }, abandonTaskBody, task.task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task.task_id); - expect(updated_task.abandon_date).toBeDefined(); - expect(updated_task.abandonment_reason).toBe(CROP_FAILURE); - expect(updated_task.other_abandonment_reason).toBe(null); - expect(updated_task.abandonment_notes).toBe(sampleNote); - done(); - }); + const res = await abandonTaskRequest({ user_id, farm_id }, abandonTaskBody, task.task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task.task_id); + expect(updated_task.abandon_date).toBeDefined(); + expect(updated_task.abandonment_reason).toBe(CROP_FAILURE); + expect(updated_task.other_abandonment_reason).toBe(null); + expect(updated_task.abandonment_notes).toBe(sampleNote); }); - test('Admin should be able to abandon a task they do not own', async (done) => { + test('Admin should be able to abandon a task they do not own', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const [{ user_id: other_user_id }] = await mocks.userFarmFactory( { promisedFarm: [{ farm_id }] }, @@ -2915,18 +2782,16 @@ describe('Task tests', () => { ); const [location] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); await mocks.location_tasksFactory({ promisedTask: [task], promisedField: [location] }); - abandonTaskRequest({ user_id, farm_id }, abandonTaskBody, task.task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task.task_id); - expect(updated_task.abandon_date).toBeDefined(); - expect(updated_task.abandonment_reason).toBe(CROP_FAILURE); - expect(updated_task.other_abandonment_reason).toBe(null); - expect(updated_task.abandonment_notes).toBe(sampleNote); - done(); - }); + const res = await abandonTaskRequest({ user_id, farm_id }, abandonTaskBody, task.task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task.task_id); + expect(updated_task.abandon_date).toBeDefined(); + expect(updated_task.abandonment_reason).toBe(CROP_FAILURE); + expect(updated_task.other_abandonment_reason).toBe(null); + expect(updated_task.abandonment_notes).toBe(sampleNote); }); - test('Admin should be able to abandon a task they are not assigned to', async (done) => { + test('Admin should be able to abandon a task they are not assigned to', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const [{ user_id: other_user_id }] = await mocks.userFarmFactory( { promisedFarm: [{ farm_id }] }, @@ -2941,18 +2806,16 @@ describe('Task tests', () => { ); const [location] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); await mocks.location_tasksFactory({ promisedTask: [task], promisedField: [location] }); - abandonTaskRequest({ user_id, farm_id }, abandonTaskBody, task.task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task.task_id); - expect(updated_task.abandon_date).toBeDefined(); - expect(updated_task.abandonment_reason).toBe(CROP_FAILURE); - expect(updated_task.other_abandonment_reason).toBe(null); - expect(updated_task.abandonment_notes).toBe(sampleNote); - done(); - }); + const res = await abandonTaskRequest({ user_id, farm_id }, abandonTaskBody, task.task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task.task_id); + expect(updated_task.abandon_date).toBeDefined(); + expect(updated_task.abandonment_reason).toBe(CROP_FAILURE); + expect(updated_task.other_abandonment_reason).toBe(null); + expect(updated_task.abandonment_notes).toBe(sampleNote); }); - test('Worker should be able to abandon a task they own', async (done) => { + test('Worker should be able to abandon a task they own', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(3)); const date = faker.date.future().toISOString().split('T')[0]; const [task] = await mocks.taskFactory( @@ -2963,18 +2826,16 @@ describe('Task tests', () => { ); const [location] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); await mocks.location_tasksFactory({ promisedTask: [task], promisedField: [location] }); - abandonTaskRequest({ user_id, farm_id }, abandonTaskBody, task.task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task.task_id); - expect(updated_task.abandon_date).toBeDefined(); - expect(updated_task.abandonment_reason).toBe(CROP_FAILURE); - expect(updated_task.other_abandonment_reason).toBe(null); - expect(updated_task.abandonment_notes).toBe(sampleNote); - done(); - }); + const res = await abandonTaskRequest({ user_id, farm_id }, abandonTaskBody, task.task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task.task_id); + expect(updated_task.abandon_date).toBeDefined(); + expect(updated_task.abandonment_reason).toBe(CROP_FAILURE); + expect(updated_task.other_abandonment_reason).toBe(null); + expect(updated_task.abandonment_notes).toBe(sampleNote); }); - test('Worker should be able to abandon a task they are assigned to', async (done) => { + test('Worker should be able to abandon a task they are assigned to', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(3)); const [{ user_id: other_user_id }] = await mocks.userFarmFactory( { promisedFarm: [{ farm_id }] }, @@ -2989,18 +2850,16 @@ describe('Task tests', () => { ); const [location] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); await mocks.location_tasksFactory({ promisedTask: [task], promisedField: [location] }); - abandonTaskRequest({ user_id, farm_id }, abandonTaskBody, task.task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task.task_id); - expect(updated_task.abandon_date).toBeDefined(); - expect(updated_task.abandonment_reason).toBe(CROP_FAILURE); - expect(updated_task.other_abandonment_reason).toBe(null); - expect(updated_task.abandonment_notes).toBe(sampleNote); - done(); - }); + const res = await abandonTaskRequest({ user_id, farm_id }, abandonTaskBody, task.task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task.task_id); + expect(updated_task.abandon_date).toBeDefined(); + expect(updated_task.abandonment_reason).toBe(CROP_FAILURE); + expect(updated_task.other_abandonment_reason).toBe(null); + expect(updated_task.abandonment_notes).toBe(sampleNote); }); - test('Worker should not be able to abandon a task they neither own or are assigned', async (done) => { + test('Worker should not be able to abandon a task they neither own or are assigned', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(3)); const [{ user_id: other_user_id }] = await mocks.userFarmFactory( { promisedFarm: [{ farm_id }] }, @@ -3015,15 +2874,13 @@ describe('Task tests', () => { ); const [location] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); await mocks.location_tasksFactory({ promisedTask: [task], promisedField: [location] }); - abandonTaskRequest({ user_id, farm_id }, abandonTaskBody, task.task_id, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await abandonTaskRequest({ user_id, farm_id }, abandonTaskBody, task.task_id); + expect(res.status).toBe(403); }); }); describe('DELETE task tests', () => { - test('Owner should be able to delete a task', async (done) => { + test('Owner should be able to delete a task', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const date = faker.date.future().toISOString().split('T')[0]; const [task] = await mocks.taskFactory( @@ -3032,15 +2889,13 @@ describe('Task tests', () => { ); const [location] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); await mocks.location_tasksFactory({ promisedTask: [task], promisedField: [location] }); - deleteTaskRequest({ user_id, farm_id }, task.task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task.task_id); - expect(updated_task.deleted).toBe(true); - done(); - }); + const res = await deleteTaskRequest({ user_id, farm_id }, task.task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task.task_id); + expect(updated_task.deleted).toBe(true); }); - test('Manager should be able to delete a task', async (done) => { + test('Manager should be able to delete a task', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(2)); const date = faker.date.future().toISOString().split('T')[0]; const [task] = await mocks.taskFactory( @@ -3049,15 +2904,13 @@ describe('Task tests', () => { ); const [location] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); await mocks.location_tasksFactory({ promisedTask: [task], promisedField: [location] }); - deleteTaskRequest({ user_id, farm_id }, task.task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task.task_id); - expect(updated_task.deleted).toBe(true); - done(); - }); + const res = await deleteTaskRequest({ user_id, farm_id }, task.task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task.task_id); + expect(updated_task.deleted).toBe(true); }); - test('EO should be able to delete a task', async (done) => { + test('EO should be able to delete a task', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(5)); const date = faker.date.future().toISOString().split('T')[0]; const [task] = await mocks.taskFactory( @@ -3066,15 +2919,13 @@ describe('Task tests', () => { ); const [location] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); await mocks.location_tasksFactory({ promisedTask: [task], promisedField: [location] }); - deleteTaskRequest({ user_id, farm_id }, task.task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task.task_id); - expect(updated_task.deleted).toBe(true); - done(); - }); + const res = await deleteTaskRequest({ user_id, farm_id }, task.task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task.task_id); + expect(updated_task.deleted).toBe(true); }); - test('Owner should be able to delete a task they do not own', async (done) => { + test('Owner should be able to delete a task they do not own', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const [{ user_id: other_user_id }] = await mocks.userFarmFactory( { promisedFarm: [{ farm_id }] }, @@ -3087,15 +2938,13 @@ describe('Task tests', () => { ); const [location] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); await mocks.location_tasksFactory({ promisedTask: [task], promisedField: [location] }); - deleteTaskRequest({ user_id, farm_id }, task.task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task.task_id); - expect(updated_task.deleted).toBe(true); - done(); - }); + const res = await deleteTaskRequest({ user_id, farm_id }, task.task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task.task_id); + expect(updated_task.deleted).toBe(true); }); - test('Owner should be able to delete a task they are not assigned to', async (done) => { + test('Owner should be able to delete a task they are not assigned to', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); const [{ user_id: other_user_id }] = await mocks.userFarmFactory( { promisedFarm: [{ farm_id }] }, @@ -3108,15 +2957,13 @@ describe('Task tests', () => { ); const [location] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); await mocks.location_tasksFactory({ promisedTask: [task], promisedField: [location] }); - deleteTaskRequest({ user_id, farm_id }, task.task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task.task_id); - expect(updated_task.deleted).toBe(true); - done(); - }); + const res = await deleteTaskRequest({ user_id, farm_id }, task.task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task.task_id); + expect(updated_task.deleted).toBe(true); }); - test('Worker should not be able to delete any task', async (done) => { + test('Worker should not be able to delete any task', async () => { const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(3)); const date = faker.date.future().toISOString().split('T')[0]; const [task] = await mocks.taskFactory( @@ -3125,15 +2972,13 @@ describe('Task tests', () => { ); const [location] = await mocks.locationFactory({ promisedFarm: [{ farm_id }] }); await mocks.location_tasksFactory({ promisedTask: [task], promisedField: [location] }); - deleteTaskRequest({ user_id, farm_id }, task.task_id, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await deleteTaskRequest({ user_id, farm_id }, task.task_id); + expect(res.status).toBe(403); }); }); describe('Patch task due date test', () => { - test('Farm owner must be able to patch task due date to today', async (done) => { + test('Farm owner must be able to patch task due date to today', async () => { const today = new Date(); const due_date = today.toISOString().split('T')[0]; const patchTaskDateBody = { due_date }; @@ -3145,15 +2990,13 @@ describe('Task tests', () => { promisedField: [{ location_id }], }); - patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task_id); - expect(toLocal8601Extended(updated_task.due_date)).toBe(due_date); - done(); - }); + const res = await patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task_id); + expect(toLocal8601Extended(updated_task.due_date)).toBe(due_date); }); - test('Farm owner must be able to patch task due date to a future date', async (done) => { + test('Farm owner must be able to patch task due date to a future date', async () => { const due_date = faker.date.future().toISOString().split('T')[0]; const patchTaskDateBody = { due_date }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(1)); @@ -3164,15 +3007,13 @@ describe('Task tests', () => { promisedField: [{ location_id }], }); - patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task_id); - expect(toLocal8601Extended(updated_task.due_date)).toBe(due_date); - done(); - }); + const res = await patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task_id); + expect(toLocal8601Extended(updated_task.due_date)).toBe(due_date); }); - test('Farm owner should be able to patch task due date to a date in the past', async (done) => { + test('Farm owner should be able to patch task due date to a date in the past', async () => { const past = faker.date.past(); const due_date = past.toISOString().split('T')[0]; const patchTaskDateBody = { due_date }; @@ -3184,13 +3025,11 @@ describe('Task tests', () => { promisedField: [{ location_id }], }); - patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id, async (err, res) => { - expect(res.status).toBe(200); - done(); - }); + const res = await patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id); + expect(res.status).toBe(200); }); - test('EO must be able to patch task due date to today', async (done) => { + test('EO must be able to patch task due date to today', async () => { const today = new Date(); const due_date = today.toISOString().split('T')[0]; const patchTaskDateBody = { due_date }; @@ -3202,15 +3041,13 @@ describe('Task tests', () => { promisedField: [{ location_id }], }); - patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task_id); - expect(toLocal8601Extended(updated_task.due_date)).toBe(due_date); - done(); - }); + const res = await patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task_id); + expect(toLocal8601Extended(updated_task.due_date)).toBe(due_date); }); - test('EO must be able to patch task due date to a future date', async (done) => { + test('EO must be able to patch task due date to a future date', async () => { const due_date = faker.date.future().toISOString().split('T')[0]; const patchTaskDateBody = { due_date }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(5)); @@ -3221,15 +3058,13 @@ describe('Task tests', () => { promisedField: [{ location_id }], }); - patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task_id); - expect(toLocal8601Extended(updated_task.due_date)).toBe(due_date); - done(); - }); + const res = await patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task_id); + expect(toLocal8601Extended(updated_task.due_date)).toBe(due_date); }); - test('EO should be able to patch task due date to a date in the past', async (done) => { + test('EO should be able to patch task due date to a date in the past', async () => { const past = faker.date.past(); const due_date = past.toISOString().split('T')[0]; const patchTaskDateBody = { due_date }; @@ -3241,13 +3076,11 @@ describe('Task tests', () => { promisedField: [{ location_id }], }); - patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id, async (err, res) => { - expect(res.status).toBe(200); - done(); - }); + const res = await patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id); + expect(res.status).toBe(200); }); - test('Managers must be able to patch task due date to today', async (done) => { + test('Managers must be able to patch task due date to today', async () => { const today = new Date(); const due_date = today.toISOString().split('T')[0]; const patchTaskDateBody = { due_date }; @@ -3259,15 +3092,13 @@ describe('Task tests', () => { promisedField: [{ location_id }], }); - patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task_id); - expect(toLocal8601Extended(updated_task.due_date)).toBe(due_date); - done(); - }); + const res = await patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task_id); + expect(toLocal8601Extended(updated_task.due_date)).toBe(due_date); }); - test('Managers must be able to patch task due date to a future date', async (done) => { + test('Managers must be able to patch task due date to a future date', async () => { const due_date = faker.date.future().toISOString().split('T')[0]; const patchTaskDateBody = { due_date }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(5)); @@ -3278,15 +3109,13 @@ describe('Task tests', () => { promisedField: [{ location_id }], }); - patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task_id); - expect(toLocal8601Extended(updated_task.due_date)).toBe(due_date); - done(); - }); + const res = await patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task_id); + expect(toLocal8601Extended(updated_task.due_date)).toBe(due_date); }); - test('Managers should be able to patch task due date to a date in the past', async (done) => { + test('Managers should be able to patch task due date to a date in the past', async () => { const past = faker.date.past(); const due_date = past.toISOString().split('T')[0]; const patchTaskDateBody = { due_date }; @@ -3298,13 +3127,11 @@ describe('Task tests', () => { promisedField: [{ location_id }], }); - patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id, async (err, res) => { - expect(res.status).toBe(200); - done(); - }); + const res = await patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id); + expect(res.status).toBe(200); }); - test('Farm worker must not be able to patch task due date', async (done) => { + test('Farm worker must not be able to patch task due date', async () => { const due_date = faker.date.future().toISOString().split('T')[0]; const patchTaskDateBody = { due_date }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(3)); @@ -3315,15 +3142,13 @@ describe('Task tests', () => { promisedField: [{ location_id }], }); - patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await patchTaskDateRequest({ user_id, farm_id }, patchTaskDateBody, task_id); + expect(res.status).toBe(403); }); }); describe('Patch task wage test', () => { - const testWithRole = async (userRoleId, wage_at_moment, done) => { + const testWithRole = async (userRoleId, wage_at_moment) => { const patchTaskWageBody = { wage_at_moment }; const [{ user_id, farm_id }] = await mocks.userFarmFactory({}, fakeUserFarm(userRoleId)); const [{ task_id }] = await mocks.taskFactory({ promisedUser: [{ user_id }] }); @@ -3335,36 +3160,32 @@ describe('Task tests', () => { const adminRoles = [1, 2, 5]; if (adminRoles.includes(userRoleId)) { - patchTaskWageRequest({ user_id, farm_id }, patchTaskWageBody, task_id, async (err, res) => { - expect(res.status).toBe(200); - const updated_task = await getTask(task_id); - expect(updated_task.wage_at_moment).toBe(wage_at_moment); - expect(updated_task.override_hourly_wage).toBe(true); - done(); - }); + const res = await patchTaskWageRequest({ user_id, farm_id }, patchTaskWageBody, task_id); + expect(res.status).toBe(200); + const updated_task = await getTask(task_id); + expect(updated_task.wage_at_moment).toBe(wage_at_moment); + expect(updated_task.override_hourly_wage).toBe(true); return; } - patchTaskWageRequest({ user_id, farm_id }, patchTaskWageBody, task_id, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await patchTaskWageRequest({ user_id, farm_id }, patchTaskWageBody, task_id); + expect(res.status).toBe(403); }; - test('Farm owner must be able to patch task wage', async (done) => { - testWithRole(1, 33, done); + test('Farm owner must be able to patch task wage', async () => { + await testWithRole(1, 33); }); - test('EO must be able to patch task wage', async (done) => { - testWithRole(5, 27, done); + test('EO must be able to patch task wage', async () => { + await testWithRole(5, 27); }); - test('Managers must be able to patch task wage', async (done) => { - testWithRole(2, 37, done); + test('Managers must be able to patch task wage', async () => { + await testWithRole(2, 37); }); - test('Farm worker must not be able to patch task wage', async (done) => { - testWithRole(3, 30, done); + test('Farm worker must not be able to patch task wage', async () => { + await testWithRole(3, 30); }); }); }); diff --git a/packages/api/tests/taskNotification.test.js b/packages/api/tests/taskNotification.test.js index 462ef5e4d0..fdfeadc9db 100644 --- a/packages/api/tests/taskNotification.test.js +++ b/packages/api/tests/taskNotification.test.js @@ -68,43 +68,39 @@ describe('Task Notification Tests', () => { }); // Clean up after test finishes - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); - afterEach(async (done) => { + afterEach(async () => { await knex.raw(` UPDATE task SET deleted = TRUE WHERE deleted = FALSE; UPDATE notification SET deleted = TRUE WHERE deleted = FALSE; UPDATE notification_user SET deleted = TRUE WHERE deleted = FALSE; `); - done(); }); - function patchAssignTaskRequest({ user_id, farm_id }, assignee_user_id, task_id, callback) { - chai + function patchAssignTaskRequest({ user_id, farm_id }, assignee_user_id, task_id) { + return chai .request(server) .patch(`/task/assign/${task_id}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send(assignee_user_id) - .end(callback); + .send(assignee_user_id); } - function patchAbandonTaskRequest({ user_id, farm_id }, data, task_id, callback) { - chai + function patchAbandonTaskRequest({ user_id, farm_id }, data, task_id) { + return chai .request(server) .patch(`/task/abandon/${task_id}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } describe('Task Reassignment Notification Tests', () => { - test('Owner will receive a reassignment notification when task has been reassigned to them from a worker', async (done) => { + test('Owner will receive a reassignment notification when task has been reassigned to them from a worker', async () => { const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id: farm.farm_id }], }); @@ -124,31 +120,25 @@ describe('Task Notification Tests', () => { promisedField: [{ location_id }], }); - patchAssignTaskRequest( + const res = await patchAssignTaskRequest( { user_id: farmOwner.user_id, farm_id: farm.farm_id }, { assignee_user_id: farmOwner.user_id }, task_id, - async (err, res) => { - expect(res.status).toBe(200); - const notifications = await knex('notification_user') - .join( - 'notification', - 'notification.notification_id', - 'notification_user.notification_id', - ) - .where({ - 'notification_user.user_id': farmWorker.user_id, - 'notification_user.deleted': false, - 'notification.deleted': false, - }); - expect(notifications.length).toBe(1); - expect(notifications[0].title.translation_key).toBe('NOTIFICATION.TASK_REASSIGNED.TITLE'); - done(); - }, ); + + expect(res.status).toBe(200); + const notifications = await knex('notification_user') + .join('notification', 'notification.notification_id', 'notification_user.notification_id') + .where({ + 'notification_user.user_id': farmWorker.user_id, + 'notification_user.deleted': false, + 'notification.deleted': false, + }); + expect(notifications.length).toBe(1); + expect(notifications[0].title.translation_key).toBe('NOTIFICATION.TASK_REASSIGNED.TITLE'); }); - test('Reassigned user should have a regular assignment notification', async (done) => { + test('Reassigned user should have a regular assignment notification', async () => { const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id: farm.farm_id }], }); @@ -168,31 +158,25 @@ describe('Task Notification Tests', () => { promisedField: [{ location_id }], }); - patchAssignTaskRequest( + const res = await patchAssignTaskRequest( { user_id: farmOwner.user_id, farm_id: farm.farm_id }, { assignee_user_id: farmWorker.user_id }, task_id, - async (err, res) => { - expect(res.status).toBe(200); - const notifications = await knex('notification_user') - .join( - 'notification', - 'notification.notification_id', - 'notification_user.notification_id', - ) - .where({ - 'notification_user.user_id': farmWorker.user_id, - 'notification_user.deleted': false, - 'notification.deleted': false, - }); - expect(notifications.length).toBe(1); - expect(notifications[0].title.translation_key).toBe('NOTIFICATION.TASK_ASSIGNED.TITLE'); - done(); - }, ); + + expect(res.status).toBe(200); + const notifications = await knex('notification_user') + .join('notification', 'notification.notification_id', 'notification_user.notification_id') + .where({ + 'notification_user.user_id': farmWorker.user_id, + 'notification_user.deleted': false, + 'notification.deleted': false, + }); + expect(notifications.length).toBe(1); + expect(notifications[0].title.translation_key).toBe('NOTIFICATION.TASK_ASSIGNED.TITLE'); }); - test('Other workers will not receive a reassignment notification of other tasks', async (done) => { + test('Other workers will not receive a reassignment notification of other tasks', async () => { const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id: farm.farm_id }], }); @@ -212,29 +196,23 @@ describe('Task Notification Tests', () => { promisedField: [{ location_id }], }); - patchAssignTaskRequest( + const res = await patchAssignTaskRequest( { user_id: farmOwner.user_id, farm_id: farm.farm_id }, { assignee_user_id: farmWorker.user_id }, task_id, - async (err, res) => { - expect(res.status).toBe(200); - const notifications = await knex('notification_user') - .join( - 'notification', - 'notification.notification_id', - 'notification_user.notification_id', - ) - .where({ - 'notification_user.user_id': farmWorker2.user_id, - 'notification_user.deleted': false, - 'notification.deleted': false, - }); - expect(notifications.length).toBe(0); - done(); - }, ); + + expect(res.status).toBe(200); + const notifications = await knex('notification_user') + .join('notification', 'notification.notification_id', 'notification_user.notification_id') + .where({ + 'notification_user.user_id': farmWorker2.user_id, + 'notification_user.deleted': false, + 'notification.deleted': false, + }); + expect(notifications.length).toBe(0); }); - test('Owner will receive a notification when a task in unassigned', async (done) => { + test('Owner will receive a notification when a task in unassigned', async () => { const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id: farm.farm_id }], }); @@ -254,32 +232,26 @@ describe('Task Notification Tests', () => { promisedField: [{ location_id }], }); - patchAssignTaskRequest( + const res = await patchAssignTaskRequest( { user_id: farmOwner.user_id, farm_id: farm.farm_id }, { assignee_user_id: null }, task_id, - async (err, res) => { - expect(res.status).toBe(200); - const notifications = await knex('notification_user') - .join( - 'notification', - 'notification.notification_id', - 'notification_user.notification_id', - ) - .where({ - 'notification_user.user_id': farmOwner.user_id, - 'notification_user.deleted': false, - 'notification.deleted': false, - }); - expect(notifications.length).toBe(1); - expect(notifications[0].title.translation_key).toBe('NOTIFICATION.TASK_UNASSIGNED.TITLE'); - expect(notifications[0].body.translation_key).toBe('NOTIFICATION.TASK_UNASSIGNED.BODY'); - done(); - }, ); + + expect(res.status).toBe(200); + const notifications = await knex('notification_user') + .join('notification', 'notification.notification_id', 'notification_user.notification_id') + .where({ + 'notification_user.user_id': farmOwner.user_id, + 'notification_user.deleted': false, + 'notification.deleted': false, + }); + expect(notifications.length).toBe(1); + expect(notifications[0].title.translation_key).toBe('NOTIFICATION.TASK_UNASSIGNED.TITLE'); + expect(notifications[0].body.translation_key).toBe('NOTIFICATION.TASK_UNASSIGNED.BODY'); }); - test('Worker does not receive a task unassigned notification', async (done) => { + test('Worker does not receive a task unassigned notification', async () => { const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id: farm.farm_id }], }); @@ -299,29 +271,23 @@ describe('Task Notification Tests', () => { promisedField: [{ location_id }], }); - patchAssignTaskRequest( + const res = await patchAssignTaskRequest( { user_id: farmOwner.user_id, farm_id: farm.farm_id }, { assignee_user_id: null }, task_id, - async (err, res) => { - expect(res.status).toBe(200); - const notifications = await knex('notification_user') - .join( - 'notification', - 'notification.notification_id', - 'notification_user.notification_id', - ) - .where({ - 'notification_user.user_id': farmWorker.user_id, - 'notification_user.deleted': false, - 'notification.deleted': false, - }); - expect(notifications.length).toBe(1); - expect(notifications[0].title.translation_key).toBe('NOTIFICATION.TASK_REASSIGNED.TITLE'); - expect(notifications[0].body.translation_key).toBe('NOTIFICATION.TASK_REASSIGNED.BODY'); - done(); - }, ); + + expect(res.status).toBe(200); + const notifications = await knex('notification_user') + .join('notification', 'notification.notification_id', 'notification_user.notification_id') + .where({ + 'notification_user.user_id': farmWorker.user_id, + 'notification_user.deleted': false, + 'notification.deleted': false, + }); + expect(notifications.length).toBe(1); + expect(notifications[0].title.translation_key).toBe('NOTIFICATION.TASK_REASSIGNED.TITLE'); + expect(notifications[0].body.translation_key).toBe('NOTIFICATION.TASK_REASSIGNED.BODY'); }); }); @@ -332,7 +298,7 @@ describe('Task Notification Tests', () => { abandon_date: '2022-05-24', }; - test('A worker should receive an abandonment notification when their task has been abandoned by owner', async (done) => { + test('A worker should receive an abandonment notification when their task has been abandoned by owner', async () => { const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id: farm.farm_id }], }); @@ -352,31 +318,25 @@ describe('Task Notification Tests', () => { promisedField: [{ location_id }], }); - patchAbandonTaskRequest( + const res = await patchAbandonTaskRequest( { user_id: farmOwner.user_id, farm_id: farm.farm_id }, abandonTaskRequest, task_id, - async (err, res) => { - expect(res.status).toBe(200); - const notifications = await knex('notification_user') - .join( - 'notification', - 'notification.notification_id', - 'notification_user.notification_id', - ) - .where({ - 'notification_user.user_id': farmWorker.user_id, - 'notification_user.deleted': false, - 'notification.deleted': false, - }); - expect(notifications.length).toBe(1); - expect(notifications[0].title.translation_key).toBe('NOTIFICATION.TASK_ABANDONED.TITLE'); - done(); - }, ); + + expect(res.status).toBe(200); + const notifications = await knex('notification_user') + .join('notification', 'notification.notification_id', 'notification_user.notification_id') + .where({ + 'notification_user.user_id': farmWorker.user_id, + 'notification_user.deleted': false, + 'notification.deleted': false, + }); + expect(notifications.length).toBe(1); + expect(notifications[0].title.translation_key).toBe('NOTIFICATION.TASK_ABANDONED.TITLE'); }); - test('Other workers should not receive an abandonment notification when a worker task has been abandoned by owner', async (done) => { + test('Other workers should not receive an abandonment notification when a worker task has been abandoned by owner', async () => { const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id: farm.farm_id }], }); @@ -396,30 +356,24 @@ describe('Task Notification Tests', () => { promisedField: [{ location_id }], }); - patchAbandonTaskRequest( + const res = await patchAbandonTaskRequest( { user_id: farmOwner.user_id, farm_id: farm.farm_id }, abandonTaskRequest, task_id, - async (err, res) => { - expect(res.status).toBe(200); - const notifications = await knex('notification_user') - .join( - 'notification', - 'notification.notification_id', - 'notification_user.notification_id', - ) - .where({ - 'notification_user.user_id': farmWorker2.user_id, - 'notification_user.deleted': false, - 'notification.deleted': false, - }); - expect(notifications.length).toBe(0); - done(); - }, ); + + expect(res.status).toBe(200); + const notifications = await knex('notification_user') + .join('notification', 'notification.notification_id', 'notification_user.notification_id') + .where({ + 'notification_user.user_id': farmWorker2.user_id, + 'notification_user.deleted': false, + 'notification.deleted': false, + }); + expect(notifications.length).toBe(0); }); - test('No abandonment notification created when an unassigned task has been abandoned by owner', async (done) => { + test('No abandonment notification created when an unassigned task has been abandoned by owner', async () => { const [{ task_type_id }] = await mocks.task_typeFactory({ promisedFarm: [{ farm_id: farm.farm_id }], }); @@ -439,27 +393,21 @@ describe('Task Notification Tests', () => { promisedField: [{ location_id }], }); - patchAbandonTaskRequest( + const res = await patchAbandonTaskRequest( { user_id: farmOwner.user_id, farm_id: farm.farm_id }, abandonTaskRequest, task_id, - async (err, res) => { - expect(res.status).toBe(200); - const notifications = await knex('notification_user') - .join( - 'notification', - 'notification.notification_id', - 'notification_user.notification_id', - ) - .where({ - 'notification_user.user_id': farmWorker.user_id, - 'notification_user.deleted': false, - 'notification.deleted': false, - }); - expect(notifications.length).toBe(0); - done(); - }, ); + + expect(res.status).toBe(200); + const notifications = await knex('notification_user') + .join('notification', 'notification.notification_id', 'notification_user.notification_id') + .where({ + 'notification_user.user_id': farmWorker.user_id, + 'notification_user.deleted': false, + 'notification.deleted': false, + }); + expect(notifications.length).toBe(0); }); }); }); diff --git a/packages/api/tests/tasktype.test.js b/packages/api/tests/tasktype.test.js index 1508d94058..8164f715d7 100644 --- a/packages/api/tests/tasktype.test.js +++ b/packages/api/tests/tasktype.test.js @@ -40,31 +40,30 @@ xdescribe('taskType Tests', () => { token = global.token; }); - function postRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }, callback) { - chai + function postRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post(`/task_type`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function getRequest( - { user_id = owner.user_id, farm_id = farm.farm_id, url = `/task_type/farm/${farm.farm_id}` }, - callback, - ) { - chai.request(server).get(url).set('user_id', user_id).set('farm_id', farm_id).end(callback); + function getRequest({ + user_id = owner.user_id, + farm_id = farm.farm_id, + url = `/task_type/farm/${farm.farm_id}`, + }) { + return chai.request(server).get(url).set('user_id', user_id).set('farm_id', farm_id); } - function deleteRequest({ user_id = owner.user_id, farm_id = farm.farm_id, task_id }, callback) { - chai + function deleteRequest({ user_id = owner.user_id, farm_id = farm.farm_id, task_id }) { + return chai .request(server) .delete(`/task_type/${task_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } function fakeUserFarm(role = 1) { @@ -86,10 +85,9 @@ xdescribe('taskType Tests', () => { ); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('Get && delete taskType', () => { @@ -98,7 +96,7 @@ xdescribe('taskType Tests', () => { [taskType] = await mocks.taskTypeFactory({ promisedFarm: [farm] }); }); - test('Get by farm_id should filter out deleted task types', async (done) => { + test('Get by farm_id should filter out deleted task types', async () => { await taskTypeModel .query() .context({ @@ -107,13 +105,11 @@ xdescribe('taskType Tests', () => { }) .findById(taskType.task_id) .delete(); - getRequest({ user_id: owner.user_id }, (err, res) => { - expect(res.status).toBe(404); - done(); - }); + const res = await getRequest({ user_id: owner.user_id }); + expect(res.status).toBe(404); }); - test('Get by task_id should filter out deleted task types', async (done) => { + test('Get by task_id should filter out deleted task types', async () => { await taskTypeModel .query() .context({ @@ -122,22 +118,21 @@ xdescribe('taskType Tests', () => { }) .findById(taskType.task_id) .delete(); - getRequest({ user_id: owner.user_id, url: `/task_type/${taskType.task_id}` }, (err, res) => { - expect(res.status).toBe(404); - done(); + const res = await getRequest({ + user_id: owner.user_id, + url: `/task_type/${taskType.task_id}`, }); + expect(res.status).toBe(404); }); - test('Workers should get seeded taskType', async (done) => { + test('Workers should get seeded taskType', async () => { let [seedtaskType] = await mocks.taskTypeFactory( { promisedFarm: [{ farm_id: null }] }, mocks.fakeTaskType(), ); - getRequest({ user_id: owner.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[1].taskType_id).toBe(seedtaskType.taskType_id); - done(); - }); + const res = await getRequest({ user_id: owner.user_id }); + expect(res.status).toBe(200); + expect(res.body[1].taskType_id).toBe(seedtaskType.taskType_id); }); describe('Get task type authorization tests', () => { @@ -166,115 +161,93 @@ xdescribe('taskType Tests', () => { ); }); - test('Owner should get taskType by farm id', async (done) => { - getRequest({ user_id: owner.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].task_id).toBe(taskType.task_id); - done(); - }); + test('Owner should get taskType by farm id', async () => { + const res = await getRequest({ user_id: owner.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].task_id).toBe(taskType.task_id); }); - test('Manager should get taskType by farm id', async (done) => { - getRequest({ user_id: manager.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].task_id).toBe(taskType.task_id); - done(); - }); + test('Manager should get taskType by farm id', async () => { + const res = await getRequest({ user_id: manager.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].task_id).toBe(taskType.task_id); }); - test('Worker should get taskType by farm id', async (done) => { - getRequest({ user_id: worker.user_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].task_id).toBe(taskType.task_id); - done(); - }); + test('Worker should get taskType by farm id', async () => { + const res = await getRequest({ user_id: worker.user_id }); + expect(res.status).toBe(200); + expect(res.body[0].task_id).toBe(taskType.task_id); }); - test('Should get status 403 if an unauthorizedUser tries to get taskType by farm_id', async (done) => { - getRequest({ user_id: unAuthorizedUser.user_id }, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + test('Should get status 403 if an unauthorizedUser tries to get taskType by farm_id', async () => { + const res = await getRequest({ user_id: unAuthorizedUser.user_id }); + expect(res.status).toBe(403); }); - test('Circumvent authorization by modifying farm_id', async (done) => { - getRequest( - { user_id: unAuthorizedUser.user_id, farm_id: farmunAuthorizedUser.farm_id }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modifying farm_id', async () => { + const res = await getRequest({ + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); }); - test('Owner should get taskType by task_id', async (done) => { - getRequest( - { user_id: owner.user_id, url: `/task_type/${taskType.task_id}` }, - (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].task_id).toBe(taskType.task_id); - done(); - }, - ); + test('Owner should get taskType by task_id', async () => { + const res = await getRequest({ + user_id: owner.user_id, + url: `/task_type/${taskType.task_id}`, + }); + expect(res.status).toBe(200); + expect(res.body[0].task_id).toBe(taskType.task_id); }); - test('Manager should get taskType by task_id', async (done) => { - getRequest( - { user_id: manager.user_id, url: `/task_type/${taskType.task_id}` }, - (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].task_id).toBe(taskType.task_id); - done(); - }, - ); + test('Manager should get taskType by task_id', async () => { + const res = await getRequest({ + user_id: manager.user_id, + url: `/task_type/${taskType.task_id}`, + }); + expect(res.status).toBe(200); + expect(res.body[0].task_id).toBe(taskType.task_id); }); - test('Worker should get taskType by task_id', async (done) => { - getRequest( - { user_id: worker.user_id, url: `/task_type/${taskType.task_id}` }, - (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].task_id).toBe(taskType.task_id); - done(); - }, - ); + test('Worker should get taskType by task_id', async () => { + const res = await getRequest({ + user_id: worker.user_id, + url: `/task_type/${taskType.task_id}`, + }); + expect(res.status).toBe(200); + expect(res.body[0].task_id).toBe(taskType.task_id); }); - test('Should get status 403 if an unauthorizedUser tries to get taskType by task_id', async (done) => { - getRequest( - { user_id: unAuthorizedUser.user_id, url: `/task_type/${taskType.task_id}` }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Should get status 403 if an unauthorizedUser tries to get taskType by task_id', async () => { + const res = await getRequest({ + user_id: unAuthorizedUser.user_id, + url: `/task_type/${taskType.task_id}`, + }); + + expect(res.status).toBe(403); }); - test('Get taskType by task_id circumvent authorization by modifying farm_id', async (done) => { - getRequest( - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - url: `/task_type/${taskType.task_id}`, - }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Get taskType by task_id circumvent authorization by modifying farm_id', async () => { + const res = await getRequest({ + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + url: `/task_type/${taskType.task_id}`, + }); + + expect(res.status).toBe(403); }); }); describe('Delete task type', function () { - test('should return 403 if user tries to delete a seeded taskType', async (done) => { + test('should return 403 if user tries to delete a seeded taskType', async () => { let [seedTaskType] = await mocks.taskTypeFactory( { promisedFarm: [{ farm_id: null }] }, mocks.fakeTaskType(), ); - deleteRequest({ task_id: seedTaskType.task_id }, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await deleteRequest({ task_id: seedTaskType.task_id }); + expect(res.status).toBe(403); }); describe('Delete task type authorization tests', () => { @@ -303,67 +276,49 @@ xdescribe('taskType Tests', () => { ); }); - test('Owner should delete a task type', async (done) => { - deleteRequest({ task_id: taskType.task_id }, async (err, res) => { - expect(res.status).toBe(200); - const taskTypeRes = await taskTypeModel - .query() - .context({ showHidden: true }) - .where('task_id', taskType.task_id); - expect(taskTypeRes.length).toBe(1); - expect(taskTypeRes[0].deleted).toBe(true); - done(); - }); + test('Owner should delete a task type', async () => { + const res = await deleteRequest({ task_id: taskType.task_id }); + expect(res.status).toBe(200); + const taskTypeRes = await taskTypeModel + .query() + .context({ showHidden: true }) + .where('task_id', taskType.task_id); + expect(taskTypeRes.length).toBe(1); + expect(taskTypeRes[0].deleted).toBe(true); }); - test('Manager should delete a taskType', async (done) => { - deleteRequest( - { user_id: manager.user_id, task_id: taskType.task_id }, - async (err, res) => { - expect(res.status).toBe(200); - const taskTypeRes = await taskTypeModel - .query() - .context({ showHidden: true }) - .where('task_id', taskType.task_id); - expect(taskTypeRes.length).toBe(1); - expect(taskTypeRes[0].deleted).toBe(true); - done(); - }, - ); + test('Manager should delete a taskType', async () => { + const res = await deleteRequest({ user_id: manager.user_id, task_id: taskType.task_id }); + expect(res.status).toBe(200); + const taskTypeRes = await taskTypeModel + .query() + .context({ showHidden: true }) + .where('task_id', taskType.task_id); + expect(taskTypeRes.length).toBe(1); + expect(taskTypeRes[0].deleted).toBe(true); }); - test('should return 403 if an unauthorized user tries to delete a taskType', async (done) => { - deleteRequest( - { user_id: unAuthorizedUser.user_id, task_id: taskType.task_id }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('should return 403 if an unauthorized user tries to delete a taskType', async () => { + const res = await deleteRequest({ + user_id: unAuthorizedUser.user_id, + task_id: taskType.task_id, + }); + expect(res.status).toBe(403); }); - test('should return 403 if a worker tries to delete a taskType', async (done) => { - deleteRequest( - { user_id: worker.user_id, task_id: taskType.task_id }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('should return 403 if a worker tries to delete a taskType', async () => { + const res = await deleteRequest({ user_id: worker.user_id, task_id: taskType.task_id }); + expect(res.status).toBe(403); }); - test('Circumvent authorization by modifying farm_id', async (done) => { - deleteRequest( - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser.farm_id, - task_id: taskType.task_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modifying farm_id', async () => { + const res = await deleteRequest({ + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + task_id: taskType.task_id, + }); + + expect(res.status).toBe(403); }); }); }); @@ -376,12 +331,10 @@ xdescribe('taskType Tests', () => { fakeTaskType = getfakeTaskType(); }); - test('should return 403 status if headers.farm_id is set to null', async (done) => { + test('should return 403 status if headers.farm_id is set to null', async () => { fakeTaskType.farm_id = null; - postRequest(fakeTaskType, {}, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await postRequest(fakeTaskType, {}); + expect(res.status).toBe(403); }); describe('Post taskType authorization tests', () => { @@ -410,61 +363,51 @@ xdescribe('taskType Tests', () => { ); }); - test('Owner should post and get a valid taskType', async (done) => { - postRequest(fakeTaskType, {}, async (err, res) => { - expect(res.status).toBe(201); - const taskTypes = await taskTypeModel - .query() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(taskTypes.length).toBe(1); - expect(taskTypes[0].task_name).toBe(fakeTaskType.task_name); - done(); - }); + test('Owner should post and get a valid taskType', async () => { + const res = await postRequest(fakeTaskType, {}); + expect(res.status).toBe(201); + const taskTypes = await taskTypeModel + .query() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(taskTypes.length).toBe(1); + expect(taskTypes[0].task_name).toBe(fakeTaskType.task_name); }); - test('Manager should post and get a valid taskType', async (done) => { - postRequest(fakeTaskType, { user_id: manager.user_id }, async (err, res) => { - expect(res.status).toBe(201); - const taskTypes = await taskTypeModel - .query() - .context({ showHidden: true }) - .where('farm_id', farm.farm_id); - expect(taskTypes.length).toBe(1); - expect(taskTypes[0].task_name).toBe(fakeTaskType.task_name); - done(); - }); + test('Manager should post and get a valid taskType', async () => { + const res = await postRequest(fakeTaskType, { user_id: manager.user_id }); + expect(res.status).toBe(201); + const taskTypes = await taskTypeModel + .query() + .context({ showHidden: true }) + .where('farm_id', farm.farm_id); + expect(taskTypes.length).toBe(1); + expect(taskTypes[0].task_name).toBe(fakeTaskType.task_name); }); - test('should return 403 status if taskType is posted by worker', async (done) => { - postRequest(fakeTaskType, { user_id: worker.user_id }, async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): add:task_types', - ); - done(); - }); + test('should return 403 status if taskType is posted by worker', async () => { + const res = await postRequest(fakeTaskType, { user_id: worker.user_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): add:task_types', + ); }); - test('should return 403 status if taskType is posted by unauthorized user', async (done) => { - postRequest(fakeTaskType, { user_id: unAuthorizedUser.user_id }, async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): add:task_types', - ); - done(); - }); + test('should return 403 status if taskType is posted by unauthorized user', async () => { + const res = await postRequest(fakeTaskType, { user_id: unAuthorizedUser.user_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): add:task_types', + ); }); - test('Circumvent authorization by modify farm_id', async (done) => { - postRequest( - fakeTaskType, - { user_id: unAuthorizedUser.user_id, farm_id: farmunAuthorizedUser.farm_id }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modify farm_id', async () => { + const res = await postRequest(fakeTaskType, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); }); }); }); diff --git a/packages/api/tests/timeNotification.test.js b/packages/api/tests/timeNotification.test.js index b7f6697a8a..d70b28b76b 100644 --- a/packages/api/tests/timeNotification.test.js +++ b/packages/api/tests/timeNotification.test.js @@ -133,38 +133,36 @@ describe('Time Based Notification Tests', () => { } } - function postWeeklyUnassignedTasksRequest(data, callback) { + function postWeeklyUnassignedTasksRequest(data) { const { farm_id } = data; - chai + + return chai .request(server) .post(`/time_notification/weekly_unassigned_tasks/${farm_id}`) - .send({ isDayLaterThanUtc }) - .end(callback); + .send({ isDayLaterThanUtc }); } - function postDailyDueTodayTasks(data, callback) { + function postDailyDueTodayTasks(data) { const { farm_id } = data; - chai + + return chai .request(server) .post(`/time_notification/daily_due_today_tasks/${farm_id}`) - .send({ isDayLaterThanUtc }) - .end(callback); + .send({ isDayLaterThanUtc }); } // Clean up after test finishes - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); - afterEach(async (done) => { + afterEach(async () => { await knex.raw(` UPDATE task SET deleted = TRUE WHERE deleted = FALSE; UPDATE notification SET deleted = TRUE WHERE deleted = FALSE; UPDATE notification_user SET deleted = TRUE WHERE deleted = FALSE; `); - done(); }); describe('Unassigned Tasks Due This Week Notification Test', () => { @@ -177,29 +175,23 @@ describe('Time Based Notification Tests', () => { }); }); - test('Farm Owners Should Receive Notification', async (done) => { - postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }, async (err, res) => { - expect(res.status).toBe(201); - const notifications = await knex('notification_user') - .join( - 'notification', - 'notification.notification_id', - 'notification_user.notification_id', - ) - .where({ - 'notification_user.user_id': farmOwner.user_id, - 'notification_user.deleted': false, - 'notification.deleted': false, - }); - expect(notifications.length).toBe(1); - expect(notifications[0].title.translation_key).toBe( - 'NOTIFICATION.WEEKLY_UNASSIGNED_TASKS.TITLE', - ); - done(); - }); + test('Farm Owners Should Receive Notification', async () => { + const res = await postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }); + expect(res.status).toBe(201); + const notifications = await knex('notification_user') + .join('notification', 'notification.notification_id', 'notification_user.notification_id') + .where({ + 'notification_user.user_id': farmOwner.user_id, + 'notification_user.deleted': false, + 'notification.deleted': false, + }); + expect(notifications.length).toBe(1); + expect(notifications[0].title.translation_key).toBe( + 'NOTIFICATION.WEEKLY_UNASSIGNED_TASKS.TITLE', + ); }); - test('Farm Managers Should Receive Notification', async (done) => { + test('Farm Managers Should Receive Notification', async () => { const [farmManager] = await mocks.usersFactory(); await mocks.userFarmFactory( { @@ -209,28 +201,22 @@ describe('Time Based Notification Tests', () => { mocks.fakeUserFarm({ role_id: 2 }), ); - postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }, async (err, res) => { - expect(res.status).toBe(201); - const notifications = await knex('notification_user') - .join( - 'notification', - 'notification.notification_id', - 'notification_user.notification_id', - ) - .where({ - 'notification_user.user_id': farmManager.user_id, - 'notification_user.deleted': false, - 'notification.deleted': false, - }); - expect(notifications.length).toBe(1); - expect(notifications[0].title.translation_key).toBe( - 'NOTIFICATION.WEEKLY_UNASSIGNED_TASKS.TITLE', - ); - done(); - }); + const res = await postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }); + expect(res.status).toBe(201); + const notifications = await knex('notification_user') + .join('notification', 'notification.notification_id', 'notification_user.notification_id') + .where({ + 'notification_user.user_id': farmManager.user_id, + 'notification_user.deleted': false, + 'notification.deleted': false, + }); + expect(notifications.length).toBe(1); + expect(notifications[0].title.translation_key).toBe( + 'NOTIFICATION.WEEKLY_UNASSIGNED_TASKS.TITLE', + ); }); - test('Extension Officers Should Receive Notification', async (done) => { + test('Extension Officers Should Receive Notification', async () => { const [extensionOfficer] = await mocks.usersFactory(); await mocks.userFarmFactory( { @@ -240,28 +226,22 @@ describe('Time Based Notification Tests', () => { mocks.fakeUserFarm({ role_id: 5 }), ); - postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }, async (err, res) => { - expect(res.status).toBe(201); - const notifications = await knex('notification_user') - .join( - 'notification', - 'notification.notification_id', - 'notification_user.notification_id', - ) - .where({ - 'notification_user.user_id': extensionOfficer.user_id, - 'notification_user.deleted': false, - 'notification.deleted': false, - }); - expect(notifications.length).toBe(1); - expect(notifications[0].title.translation_key).toBe( - 'NOTIFICATION.WEEKLY_UNASSIGNED_TASKS.TITLE', - ); - done(); - }); + const res = await postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }); + expect(res.status).toBe(201); + const notifications = await knex('notification_user') + .join('notification', 'notification.notification_id', 'notification_user.notification_id') + .where({ + 'notification_user.user_id': extensionOfficer.user_id, + 'notification_user.deleted': false, + 'notification.deleted': false, + }); + expect(notifications.length).toBe(1); + expect(notifications[0].title.translation_key).toBe( + 'NOTIFICATION.WEEKLY_UNASSIGNED_TASKS.TITLE', + ); }); - test('Farm Worker Should Not Receive Notification', async (done) => { + test('Farm Worker Should Not Receive Notification', async () => { const [farmWorker] = await mocks.usersFactory(); await mocks.userFarmFactory( { @@ -271,18 +251,16 @@ describe('Time Based Notification Tests', () => { mocks.fakeUserFarm({ role_id: 3 }), ); - postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }, async (err, res) => { - expect(res.status).toBe(201); - const notifications = await knex('notification_user').where({ - user_id: farmWorker.user_id, - deleted: false, - }); - expect(notifications.length).toBe(0); - done(); + const res = await postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }); + expect(res.status).toBe(201); + const notifications = await knex('notification_user').where({ + user_id: farmWorker.user_id, + deleted: false, }); + expect(notifications.length).toBe(0); }); - test('Farm Manager at a Different Farm Should Not Receive Notification', async (done) => { + test('Farm Manager at a Different Farm Should Not Receive Notification', async () => { const [otherFarmManager] = await mocks.usersFactory(); const [otherFarm] = await mocks.farmFactory(); await mocks.userFarmFactory( @@ -293,28 +271,24 @@ describe('Time Based Notification Tests', () => { mocks.fakeUserFarm({ role_id: 2 }), ); - postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }, async (err, res) => { - expect(res.status).toBe(201); - const notifications = await knex('notification_user').where({ - user_id: otherFarmManager.user_id, - deleted: false, - }); - expect(notifications.length).toBe(0); - done(); + const res = await postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }); + expect(res.status).toBe(201); + const notifications = await knex('notification_user').where({ + user_id: otherFarmManager.user_id, + deleted: false, }); + expect(notifications.length).toBe(0); }); }); describe('Notification Only Sent Under Correct Conditions Tests', () => { - test('Not Sent When There Are No Unassigned Tasks', (done) => { - postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }, async (err, res) => { - expect(res.status).toBe(200); - const notifications = await knex('notification').where({ deleted: false }); - expect(notifications.length).toBe(0); - done(); - }); + test('Not Sent When There Are No Unassigned Tasks', async () => { + const res = await postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }); + expect(res.status).toBe(200); + const notifications = await knex('notification').where({ deleted: false }); + expect(notifications.length).toBe(0); }); - test('Not Sent When The Only Unassigned Tasks Are Due Later Then 7 Days', async (done) => { + test('Not Sent When The Only Unassigned Tasks Are Due Later Then 7 Days', async () => { const laterThanOneWeekFromNow = fakeToday; laterThanOneWeekFromNow.setDate(laterThanOneWeekFromNow.getDate() + 8); const laterThanOneWeekFromNowStr = laterThanOneWeekFromNow.toISOString().split('T')[0]; @@ -324,39 +298,33 @@ describe('Time Based Notification Tests', () => { assignee_user_id: null, }); - postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }, async (err, res) => { - expect(res.status).toBe(200); - const notifications = await knex('notification').where({ deleted: false }); - expect(notifications.length).toBe(0); - done(); - }); + const res = await postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }); + expect(res.status).toBe(200); + const notifications = await knex('notification').where({ deleted: false }); + expect(notifications.length).toBe(0); }); - test('Not Sent When The Only Tasks Due This Week Are Assigned', async (done) => { + test('Not Sent When The Only Tasks Due This Week Are Assigned', async () => { await createFullTask({ due_date: faker.date.soon(6, fakeToday).toISOString().split('T')[0], assignee_user_id: farmOwner.user_id, }); - postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }, async (err, res) => { - expect(res.status).toBe(200); - const notifications = await knex('notification').where({ deleted: false }); - expect(notifications.length).toBe(0); - done(); - }); + const res = await postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }); + expect(res.status).toBe(200); + const notifications = await knex('notification').where({ deleted: false }); + expect(notifications.length).toBe(0); }); - test('Sent When There Are Unassigned Tasks Due Within The Next 7 days', async (done) => { + test('Sent When There Are Unassigned Tasks Due Within The Next 7 days', async () => { await createFullTask({ due_date: faker.date.soon(6, fakeToday).toISOString().split('T')[0], assignee_user_id: null, }); - postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }, async (err, res) => { - expect(res.status).toBe(201); - const notifications = await knex('notification').where({ deleted: false }); - expect(notifications.length).toBe(1); - done(); - }); + const res = await postWeeklyUnassignedTasksRequest({ farm_id: farm.farm_id }); + expect(res.status).toBe(201); + const notifications = await knex('notification').where({ deleted: false }); + expect(notifications.length).toBe(1); }); }); }); @@ -376,47 +344,43 @@ describe('Time Based Notification Tests', () => { }); describe('Notification sent tests', () => { - test('Farm worker should receive a due today notification', async (done) => { + test('Farm worker should receive a due today notification', async () => { await createFullTask({ due_date: fakeToday.toISOString().split('T')[0], assignee_user_id: farmWorker.user_id, }); - postDailyDueTodayTasks({ farm_id: farm.farm_id }, async (err, res) => { - expect(res.status).toBe(201); - const notifications = await knex('notification').where({ - 'notification.farm_id': farm.farm_id, - 'notification.deleted': false, - }); - expect(notifications.length).toBe(1); - expect(notifications[0].title.translation_key).toBe( - 'NOTIFICATION.DAILY_TASKS_DUE_TODAY.TITLE', - ); - done(); + const res = await postDailyDueTodayTasks({ farm_id: farm.farm_id }); + expect(res.status).toBe(201); + const notifications = await knex('notification').where({ + 'notification.farm_id': farm.farm_id, + 'notification.deleted': false, }); + expect(notifications.length).toBe(1); + expect(notifications[0].title.translation_key).toBe( + 'NOTIFICATION.DAILY_TASKS_DUE_TODAY.TITLE', + ); }); - test('Farm owner should receive a due today notification', async (done) => { + test('Farm owner should receive a due today notification', async () => { await createFullTask({ due_date: fakeToday.toISOString().split('T')[0], assignee_user_id: farmOwner.user_id, }); - postDailyDueTodayTasks({ farm_id: farm.farm_id }, async (err, res) => { - expect(res.status).toBe(201); - const notifications = await knex('notification').where({ - 'notification.farm_id': farm.farm_id, - 'notification.deleted': false, - }); - expect(notifications.length).toBe(1); - expect(notifications[0].title.translation_key).toBe( - 'NOTIFICATION.DAILY_TASKS_DUE_TODAY.TITLE', - ); - done(); + const res = await postDailyDueTodayTasks({ farm_id: farm.farm_id }); + expect(res.status).toBe(201); + const notifications = await knex('notification').where({ + 'notification.farm_id': farm.farm_id, + 'notification.deleted': false, }); + expect(notifications.length).toBe(1); + expect(notifications[0].title.translation_key).toBe( + 'NOTIFICATION.DAILY_TASKS_DUE_TODAY.TITLE', + ); }); - test('Multiple farm workers in the same farm should receive a due today notification', async (done) => { + test('Multiple farm workers in the same farm should receive a due today notification', async () => { await createFullTask({ due_date: fakeToday.toISOString().split('T')[0], assignee_user_id: farmOwner.user_id, @@ -427,41 +391,37 @@ describe('Time Based Notification Tests', () => { assignee_user_id: farmWorker.user_id, }); - postDailyDueTodayTasks({ farm_id: farm.farm_id }, async (err, res) => { - expect(res.status).toBe(201); - const notifications = await knex('notification').where({ - 'notification.farm_id': farm.farm_id, - 'notification.deleted': false, - }); - expect(notifications.length).toBe(2); - expect(notifications[0].title.translation_key).toBe( - 'NOTIFICATION.DAILY_TASKS_DUE_TODAY.TITLE', - ); - done(); + const res = await postDailyDueTodayTasks({ farm_id: farm.farm_id }); + expect(res.status).toBe(201); + const notifications = await knex('notification').where({ + 'notification.farm_id': farm.farm_id, + 'notification.deleted': false, }); + expect(notifications.length).toBe(2); + expect(notifications[0].title.translation_key).toBe( + 'NOTIFICATION.DAILY_TASKS_DUE_TODAY.TITLE', + ); }); }); describe('Notification not sent tests', () => { - test('Notification not sent if no active workers in a farm', async (done) => { + test('Notification not sent if no active workers in a farm', async () => { const [farm2] = await mocks.farmFactory(); await createFullTask({ due_date: faker.date.soon(2, fakeToday).toISOString().split('T')[0], assignee_user_id: farmWorker.user_id, }); - postDailyDueTodayTasks({ farm_id: farm2.farm_id }, async (err, res) => { - expect(res.status).toBe(200); - const notifications = await knex('notification').where({ - 'notification.farm_id': farm2.farm_id, - 'notification.deleted': false, - }); - expect(notifications.length).toBe(0); - done(); + const res = await postDailyDueTodayTasks({ farm_id: farm2.farm_id }); + expect(res.status).toBe(200); + const notifications = await knex('notification').where({ + 'notification.farm_id': farm2.farm_id, + 'notification.deleted': false, }); + expect(notifications.length).toBe(0); }); - test('Other farm worker should not receive a due today notification of another worker', async (done) => { + test('Other farm worker should not receive a due today notification of another worker', async () => { const [farmWorker2] = await mocks.usersFactory(); await mocks.userFarmFactory( { @@ -476,46 +436,34 @@ describe('Time Based Notification Tests', () => { assignee_user_id: farmWorker.user_id, }); - postDailyDueTodayTasks({ farm_id: farm.farm_id }, async (err, res) => { - expect(res.status).toBe(201); - const notifications = await knex('notification_user') - .join( - 'notification', - 'notification.notification_id', - 'notification_user.notification_id', - ) - .where({ - 'notification_user.user_id': farmWorker2.user_id, - 'notification_user.deleted': false, - 'notification.deleted': false, - }); - expect(notifications.length).toBe(0); - done(); - }); + const res = await postDailyDueTodayTasks({ farm_id: farm.farm_id }); + expect(res.status).toBe(201); + const notifications = await knex('notification_user') + .join('notification', 'notification.notification_id', 'notification_user.notification_id') + .where({ + 'notification_user.user_id': farmWorker2.user_id, + 'notification_user.deleted': false, + 'notification.deleted': false, + }); + expect(notifications.length).toBe(0); }); - test('Farm workers should not receive a due today notification of unassigned tasks', async (done) => { + test('Farm workers should not receive a due today notification of unassigned tasks', async () => { await createFullTask({ due_date: fakeToday.toISOString().split('T')[0], assignee_user_id: null, }); - postDailyDueTodayTasks({ farm_id: farm.farm_id }, async (err, res) => { - expect(res.status).toBe(200); - const notifications = await knex('notification_user') - .join( - 'notification', - 'notification.notification_id', - 'notification_user.notification_id', - ) - .where({ - 'notification_user.user_id': farmWorker.user_id, - 'notification_user.deleted': false, - 'notification.deleted': false, - }); - expect(notifications.length).toBe(0); - done(); - }); + const res = await postDailyDueTodayTasks({ farm_id: farm.farm_id }); + expect(res.status).toBe(200); + const notifications = await knex('notification_user') + .join('notification', 'notification.notification_id', 'notification_user.notification_id') + .where({ + 'notification_user.user_id': farmWorker.user_id, + 'notification_user.deleted': false, + 'notification.deleted': false, + }); + expect(notifications.length).toBe(0); }); }); }); diff --git a/packages/api/tests/user.test.js b/packages/api/tests/user.test.js index 14e3696470..dfdfbb967e 100644 --- a/packages/api/tests/user.test.js +++ b/packages/api/tests/user.test.js @@ -46,58 +46,50 @@ describe('User Tests', () => { token = global.token; }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); - function postUserRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }, callback) { - chai + function postUserRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post('/user') .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function postPseudoUserRequest( - data, - { user_id = owner.user_id, farm_id = farm.farm_id }, - callback, - ) { - chai + function postPseudoUserRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post('/user/pseudo') .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } - function getRequest( - { user_id = owner.user_id, farm_id = farm.farm_id, params_user_id = undefined }, - callback, - ) { - chai + function getRequest({ + user_id = owner.user_id, + farm_id = farm.farm_id, + params_user_id = undefined, + }) { + return chai .request(server) .get(`/user/${params_user_id ? params_user_id : user_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - function putRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }, callback) { - chai + function putRequest(data, { user_id = owner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .put(`/user/${user_id}`) .set('farm_id', farm_id) .set('user_id', user_id) - .send(data) - .end(callback); + .send(data); } function validate(expected, res, status, received = undefined) { @@ -174,42 +166,32 @@ describe('User Tests', () => { ); }); - test('Workers should get user by user id', async (done) => { - getRequest({ user_id: worker.user_id }, (err, res) => { - expect(res.status).toBe(200); - validate({ ...worker, ...workerFarm }, res, 200); - done(); - }); + test('Workers should get user by user id', async () => { + const res = await getRequest({ user_id: worker.user_id }); + expect(res.status).toBe(200); + validate({ ...worker, ...workerFarm }, res, 200); }); - test('Owner should get user by user id', async (done) => { - getRequest({ user_id: owner.user_id }, (err, res) => { - validate({ ...owner, ...ownerFarm }, res, 200); - expect(res.body.gender).toBe(owner.gender); - expect(res.body.birth_year).toBe(owner.birth_year); - done(); - }); + test('Owner should get user by user id', async () => { + const res = await getRequest({ user_id: owner.user_id }); + validate({ ...owner, ...ownerFarm }, res, 200); + expect(res.body.gender).toBe(owner.gender); + expect(res.body.birth_year).toBe(owner.birth_year); }); - test('Manager should get user by user id', async (done) => { - getRequest({ user_id: manager.user_id }, (err, res) => { - validate({ ...manager, ...managerFarm }, res, 200); - done(); - }); + test('Manager should get user by user id', async () => { + const res = await getRequest({ user_id: manager.user_id }); + validate({ ...manager, ...managerFarm }, res, 200); }); - test('Should get status 403 if an unauthorizedUser tries to get user by user_id', async (done) => { - getRequest( - { - user_id: unAuthorizedUser.user_id, - farm_id: farmunAuthorizedUser, - params_user_id: owner.user_id, - }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Should get status 403 if an unauthorizedUser tries to get user by user_id', async () => { + const res = await getRequest({ + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser, + params_user_id: owner.user_id, + }); + + expect(res.status).toBe(403); }); }); }); @@ -261,55 +243,46 @@ describe('User Tests', () => { ); }); - test('should edit and the area_used field by owner', async (done) => { + test('should edit and the area_used field by owner', async () => { sampleData = fakeUser(owner.user_id); sampleData.email = owner.email; - putRequest(sampleData, { user_id: owner.user_id }, async (err, res) => { - const resUser = await userModel.query().findById(owner.user_id); - validate(sampleData, res, 200, resUser); - done(); - }); + const res = await putRequest(sampleData, { user_id: owner.user_id }); + const resUser = await userModel.query().findById(owner.user_id); + validate(sampleData, res, 200, resUser); }); - test('should edit and the area_used field by manager', async (done) => { + test('should edit and the area_used field by manager', async () => { sampleData = fakeUser(manager.user_id); sampleData.email = owner.email; sampleData.email = manager.email; - putRequest(sampleData, { user_id: manager.user_id }, async (err, res) => { - const resUser = await userModel.query().findById(manager.user_id); - validate(sampleData, res, 200, resUser); - done(); - }); + const res = await putRequest(sampleData, { user_id: manager.user_id }); + const resUser = await userModel.query().findById(manager.user_id); + validate(sampleData, res, 200, resUser); }); - test('should edit and the area_used field by worker', async (done) => { + test('should edit and the area_used field by worker', async () => { sampleData = fakeUser(worker.user_id); sampleData.email = worker.email; - putRequest(sampleData, { user_id: worker.user_id }, async (err, res) => { - const resUser = await userModel.query().findById(worker.user_id); - validate(sampleData, res, 200, resUser); - done(); - }); + const res = await putRequest(sampleData, { user_id: worker.user_id }); + const resUser = await userModel.query().findById(worker.user_id); + validate(sampleData, res, 200, resUser); }); - test('should return 403 when unauthorized user tries to edit another user', async (done) => { + test('should return 403 when unauthorized user tries to edit another user', async () => { sampleData = fakeUser(manager.user_id); - putRequest( - sampleData, - { user_id: unAuthorizedUser.user_id, farm_id: farmunAuthorizedUser }, - (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + + const res = await putRequest(sampleData, { + user_id: unAuthorizedUser.user_id, + farm_id: farmunAuthorizedUser, + }); + + expect(res.status).toBe(403); }); - test('should return 403 when a owner tries to edit another user', async (done) => { + test('should return 403 when a owner tries to edit another user', async () => { sampleData = fakeUser(manager.user_id); - putRequest(sampleData, { user_id: owner.user_id }, (err, res) => { - expect(res.status).toBe(403); - done(); - }); + const res = await putRequest(sampleData, { user_id: owner.user_id }); + expect(res.status).toBe(403); }); }); }); @@ -366,7 +339,7 @@ describe('User Tests', () => { ); }); - test('Should post then get a valid user and user spotlight', async (done) => { + test('Should post then get a valid user and user spotlight', async () => { const fakeUser = mocks.fakeUser(); // don't need user_id or phone number when signing up user delete fakeUser.user_id; @@ -374,85 +347,66 @@ describe('User Tests', () => { const password = 'test password'; fakeUser.password = password; - postUserRequest(fakeUser, { user_id: manager.user_id }, async (err, res) => { - const user_id = res.body.user.user_id; - const userSecret = await passwordModel - .query() - .select('*') - .where('user_id', user_id) - .first(); - const resUser = await userModel.query().select('*').where('user_id', user_id).first(); - validate(fakeUser, res, 201, resUser); - expect(userSecret.password_hash).not.toBe(password); - // check that the saved hash corresponds to the pw provided - const isMatch = await bcrypt.compare(password, userSecret.password_hash); - expect(isMatch).toBe(true); - const showedSpotlight = await showedSpotlightModel.query().findById(user_id); - expect(showedSpotlight.user_id).toBe(user_id); - - done(); - }); + const res = await postUserRequest(fakeUser, { user_id: manager.user_id }); + const user_id = res.body.user.user_id; + const userSecret = await passwordModel + .query() + .select('*') + .where('user_id', user_id) + .first(); + const resUser = await userModel.query().select('*').where('user_id', user_id).first(); + validate(fakeUser, res, 201, resUser); + expect(userSecret.password_hash).not.toBe(password); + // check that the saved hash corresponds to the pw provided + const isMatch = await bcrypt.compare(password, userSecret.password_hash); + expect(isMatch).toBe(true); + const showedSpotlight = await showedSpotlightModel.query().findById(user_id); + expect(showedSpotlight.user_id).toBe(user_id); }); - xtest('Owner should post a pseudo user', async (done) => { - postPseudoUserRequest(sampleData, {}, async (err, res) => { - const resUser = await userModel.query().where({ email: sampleData.email }).first(); - const resUserFarm = await userFarmModel - .query() - .where({ user_id: resUser.user_id, farm_id: farm.farm_id }) - .first(); - validate({ ...sampleData, role_id: 4 }, res, 201, { ...resUser, ...resUserFarm }); - done(); - }); + xtest('Owner should post a pseudo user', async () => { + const res = await postPseudoUserRequest(sampleData, {}); + const resUser = await userModel.query().where({ email: sampleData.email }).first(); + const resUserFarm = await userFarmModel + .query() + .where({ user_id: resUser.user_id, farm_id: farm.farm_id }) + .first(); + validate({ ...sampleData, role_id: 4 }, res, 201, { ...resUser, ...resUserFarm }); }); - xtest('Manager should post a pseudo user', async (done) => { - postPseudoUserRequest(sampleData, { user_id: manager.user_id }, async (err, res) => { - const resUser = await userModel.query().where({ email: sampleData.email }).first(); - const resUserFarm = await userFarmModel - .query() - .where({ user_id: resUser.user_id, farm_id: farm.farm_id }) - .first(); - validate({ ...sampleData, role_id: 4 }, res, 201, { ...resUser, ...resUserFarm }); - done(); - }); + xtest('Manager should post a pseudo user', async () => { + const res = await postPseudoUserRequest(sampleData, { user_id: manager.user_id }); + const resUser = await userModel.query().where({ email: sampleData.email }).first(); + const resUserFarm = await userFarmModel + .query() + .where({ user_id: resUser.user_id, farm_id: farm.farm_id }) + .first(); + validate({ ...sampleData, role_id: 4 }, res, 201, { ...resUser, ...resUserFarm }); }); - test('Should return status 403 when a worker tries to post a pseudo user', async (done) => { - postPseudoUserRequest(sampleData, { user_id: worker.user_id }, async (err, res) => { - expect(res.status).toBe(403); - done(); - }); + test('Should return status 403 when a worker tries to post a pseudo user', async () => { + const res = await postPseudoUserRequest(sampleData, { user_id: worker.user_id }); + expect(res.status).toBe(403); }); - test('Should return status 403 when a worker tries to post a pseudo user', async (done) => { - postPseudoUserRequest( - sampleData, - { user_id: unAuthorizedUser.user_id }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Should return status 403 when a worker tries to post a pseudo user', async () => { + const res = await postPseudoUserRequest(sampleData, { user_id: unAuthorizedUser.user_id }); + expect(res.status).toBe(403); }); - test('Circumvent authorization by modify farm_id', async (done) => { - postPseudoUserRequest( - sampleData, - { user_id: unAuthorizedUser.user_id, farm_id: unAuthorizedUser.farm_id }, - async (err, res) => { - expect(res.status).toBe(403); - done(); - }, - ); + test('Circumvent authorization by modify farm_id', async () => { + const res = await postPseudoUserRequest(sampleData, { + user_id: unAuthorizedUser.user_id, + farm_id: unAuthorizedUser.farm_id, + }); + + expect(res.status).toBe(403); }); - test('Should return 400 if user_id already exists', async (done) => { + test('Should return 400 if user_id already exists', async () => { sampleData.user_id = unAuthorizedUser.user_id; - postPseudoUserRequest(sampleData, {}, async (err, res) => { - expect(res.status).toBe(400); - done(); - }); + const res = await postPseudoUserRequest(sampleData, {}); + expect(res.status).toBe(400); }); }); }); diff --git a/packages/api/tests/userFarm.test.js b/packages/api/tests/userFarm.test.js index 408acc6902..147c3d7ec5 100644 --- a/packages/api/tests/userFarm.test.js +++ b/packages/api/tests/userFarm.test.js @@ -40,28 +40,24 @@ import userModel from '../src/models/userModel.js'; describe('User Farm Tests', () => { // let middleware; - function getUserFarmsOfUserRequest({ user_id }, callback) { - chai.request(server).get(`/user_farm/user/${user_id}`).end(callback); + function getUserFarmsOfUserRequest({ user_id }) { + return chai.request(server).get(`/user_farm/user/${user_id}`); } // note: the object that is sent should be adjusted to not include consent_version - function updateUserFarmConsentRequest( - { user_id, farm_id, params_user_id, params_farm_id }, - callback, - ) { - chai + function updateUserFarmConsentRequest({ user_id, farm_id, params_user_id, params_farm_id }) { + return chai .request(server) .patch( `/user_farm/consent/farm/${params_farm_id || farm_id}/user/${params_user_id || user_id}`, ) .set('user_id', user_id) .set('farm_id', farm_id) - .send({ has_consent: true, consent_version: '3.0' }) - .end(callback); + .send({ has_consent: true, consent_version: '3.0' }); } - function updateOnboarding(targetUser, { user_id, farm_id }, callback) { - chai + function updateOnboarding(targetUser, { user_id, farm_id }) { + return chai .request(server) .patch(`/user_farm/onboarding/farm/${farm_id}/user/${user_id}`) .send({ @@ -75,80 +71,68 @@ describe('User Farm Tests', () => { step_four_end: targetUser.step_four_end, step_five: targetUser.step_five, step_five_end: targetUser.step_five_end, - }) - .end(callback); + }); } - function getUserFarmsOfFarmRequest({ user_id, farm_id }, callback) { - chai + function getUserFarmsOfFarmRequest({ user_id, farm_id }) { + return chai .request(server) .get(`/user_farm/farm/${farm_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - function getActiveUserFarmsOfFarmRequest({ user_id, farm_id }, callback) { - chai + function getActiveUserFarmsOfFarmRequest({ user_id, farm_id }) { + return chai .request(server) .get(`/user_farm/active/farm/${farm_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } // TODO: eventually change how role is passed into endpoint - function updateRoleRequest(role_id, { user_id, farm_id }, target_user_id, callback) { - chai + function updateRoleRequest(role_id, { user_id, farm_id }, target_user_id) { + return chai .request(server) .patch(`/user_farm/role/farm/${farm_id}/user/${target_user_id}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send({ role_id }) - .end(callback); + .send({ role_id }); } - function updateStatusRequest(status, { user_id, farm_id }, target_user_id, callback) { - chai + function updateStatusRequest(status, { user_id, farm_id }, target_user_id) { + return chai .request(server) .patch(`/user_farm/status/farm/${farm_id}/user/${target_user_id}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send({ status }) - .end(callback); + .send({ status }); } - function updateWageRequest(wage, { user_id, farm_id }, target_user_id, callback) { - chai + function updateWageRequest(wage, { user_id, farm_id }, target_user_id) { + return chai .request(server) .patch(`/user_farm/wage/farm/${farm_id}/user/${target_user_id}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send({ wage }) - .end(callback); + .send({ wage }); } - function setWageDoNotAskAgainRequest({ user_id, farm_id }, target_user_id, callback) { - chai + function setWageDoNotAskAgainRequest({ user_id, farm_id }, target_user_id) { + return chai .request(server) .patch(`/user_farm/wage_do_not_ask_again/farm/${farm_id}/user/${target_user_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - function invitePseudoUserRequest( - data, - { user_id, farm_id, params_user_id, params_farm_id }, - callback, - ) { - chai + function invitePseudoUserRequest(data, { user_id, farm_id, params_user_id, params_farm_id }) { + return chai .request(server) .post(`/user_farm/invite/farm/${params_farm_id || farm_id}/user/${params_user_id || user_id}`) .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } // initialize a user and a farm @@ -202,7 +186,7 @@ describe('User Farm Tests', () => { return { owner, manager, worker, inactiveUser, farm }; } - afterAll(async (done) => { + afterAll(async () => { console.time('cleanup'); await tableCleanup(knex); console.timeEnd('cleanup'); @@ -210,40 +194,33 @@ describe('User Farm Tests', () => { await knex.destroy(); console.timeEnd('destroy'); - done(); }); - test('Get all user farms of a user', async (done) => { + test('Get all user farms of a user', async () => { const { user } = await setupUserFarm({}); await createUserFarmForUser({}, user); await createUserFarmForUser({}, user); - getUserFarmsOfUserRequest({ user_id: user.user_id }, async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - expect(res.body.length).toBe(3); - done(); - }); + const res = await getUserFarmsOfUserRequest({ user_id: user.user_id }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(3); }); - test('Update consent status for user farm', async (done) => { + test('Update consent status for user farm', async () => { const { farm } = await setupUserFarm({}); const noConsentUser = await createUserFarmAtFarm({ role_id: 3, has_consent: false }, farm); let targetUser = await userFarmModel.query().where('user_id', noConsentUser.user_id).first(); expect(targetUser.has_consent).toBe(false); - updateUserFarmConsentRequest( - { user_id: noConsentUser.user_id, farm_id: farm.farm_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - targetUser = await userFarmModel.query().where('user_id', noConsentUser.user_id).first(); - expect(targetUser.has_consent).toBe(true); - done(); - }, - ); + const res = await updateUserFarmConsentRequest({ + user_id: noConsentUser.user_id, + farm_id: farm.farm_id, + }); + expect(res.status).toBe(200); + targetUser = await userFarmModel.query().where('user_id', noConsentUser.user_id).first(); + expect(targetUser.has_consent).toBe(true); }); - test('Invited user should not update userFarm', async (done) => { + test('Invited user should not update userFarm', async () => { const { farm } = await setupUserFarm({}); const noConsentUser = await createUserFarmAtFarm( { role_id: 3, has_consent: false, status: 'Invited' }, @@ -251,17 +228,14 @@ describe('User Farm Tests', () => { ); const targetUser = await userFarmModel.query().where('user_id', noConsentUser.user_id).first(); expect(targetUser.has_consent).toBe(false); - updateUserFarmConsentRequest( - { user_id: noConsentUser.user_id, farm_id: farm.farm_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(403); - done(); - }, - ); + const res = await updateUserFarmConsentRequest({ + user_id: noConsentUser.user_id, + farm_id: farm.farm_id, + }); + expect(res.status).toBe(403); }); - test('Inactive user should not update userFarm', async (done) => { + test('Inactive user should not update userFarm', async () => { const { farm } = await setupUserFarm({}); const noConsentUser = await createUserFarmAtFarm( { role_id: 3, has_consent: false, status: 'Inactive' }, @@ -269,17 +243,14 @@ describe('User Farm Tests', () => { ); const targetUser = await userFarmModel.query().where('user_id', noConsentUser.user_id).first(); expect(targetUser.has_consent).toBe(false); - updateUserFarmConsentRequest( - { user_id: noConsentUser.user_id, farm_id: farm.farm_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(403); - done(); - }, - ); + const res = await updateUserFarmConsentRequest({ + user_id: noConsentUser.user_id, + farm_id: farm.farm_id, + }); + expect(res.status).toBe(403); }); - test('Owner should not accept/reject consent on behalf of another user', async (done) => { + test('Owner should not accept/reject consent on behalf of another user', async () => { const { user: owner, farm } = await setupUserFarm({}); const noConsentUser = await createUserFarmAtFarm( { role_id: 3, has_consent: false, status: 'Invited' }, @@ -287,259 +258,215 @@ describe('User Farm Tests', () => { ); const targetUser = await userFarmModel.query().where('user_id', noConsentUser.user_id).first(); expect(targetUser.has_consent).toBe(false); - updateUserFarmConsentRequest( - { user_id: owner.user_id, farm_id: farm.farm_id, params_user_id: noConsentUser }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(403); - done(); - }, - ); + + const res = await updateUserFarmConsentRequest({ + user_id: owner.user_id, + farm_id: farm.farm_id, + params_user_id: noConsentUser, + }); + + expect(res.status).toBe(403); }); - test('Update step_one of farm', async (done) => { + test('Update step_one of farm', async () => { const { user: owner, farm } = await setupUserFarm({}); const targetUser = await userFarmModel.query().where('user_id', owner.user_id).first(); expect(targetUser.step_one).toBe(false); targetUser.step_one = true; targetUser.step_one_end = '2020-10-21 14:43:06.718035-07'; - updateOnboarding( - targetUser, - { user_id: owner.user_id, farm_id: farm.farm_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - const targetUser1 = await userFarmModel.query().where('user_id', owner.user_id).first(); - expect(targetUser1.step_one).toBe(true); - expect(targetUser1.step_one_end).toBe(targetUser.step_one_end); - done(); - }, - ); + const res = await updateOnboarding(targetUser, { + user_id: owner.user_id, + farm_id: farm.farm_id, + }); + expect(res.status).toBe(200); + const targetUser1 = await userFarmModel.query().where('user_id', owner.user_id).first(); + expect(targetUser1.step_one).toBe(true); + expect(targetUser1.step_one_end).toBe(targetUser.step_one_end); }); - test('Update step_two of farm', async (done) => { + test('Update step_two of farm', async () => { const { user: owner, farm } = await setupUserFarm({}); const targetUser = await userFarmModel.query().where('user_id', owner.user_id).first(); expect(targetUser.step_two).toBe(false); targetUser.step_two = true; targetUser.step_two_end = '2020-10-21 14:43:06.718035-07'; - updateOnboarding( - targetUser, - { user_id: owner.user_id, farm_id: farm.farm_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - const targetUser1 = await userFarmModel.query().where('user_id', owner.user_id).first(); - expect(targetUser1.step_two).toBe(true); - expect(targetUser1.step_two_end).toBe(targetUser.step_two_end); - done(); - }, - ); + const res = await updateOnboarding(targetUser, { + user_id: owner.user_id, + farm_id: farm.farm_id, + }); + expect(res.status).toBe(200); + const targetUser1 = await userFarmModel.query().where('user_id', owner.user_id).first(); + expect(targetUser1.step_two).toBe(true); + expect(targetUser1.step_two_end).toBe(targetUser.step_two_end); }); - test('Update step_three of farm', async (done) => { + test('Update step_three of farm', async () => { const { user: owner, farm } = await setupUserFarm({}); const targetUser = await userFarmModel.query().where('user_id', owner.user_id).first(); expect(targetUser.step_three).toBe(false); targetUser.step_three = true; targetUser.step_three_end = '2020-10-21 14:43:06.718035-07'; - updateOnboarding( - targetUser, - { user_id: owner.user_id, farm_id: farm.farm_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - const targetUser1 = await userFarmModel.query().where('user_id', owner.user_id).first(); - expect(targetUser1.step_three).toBe(true); - expect(targetUser1.step_three_end).toBe(targetUser.step_three_end); - done(); - }, - ); + const res = await updateOnboarding(targetUser, { + user_id: owner.user_id, + farm_id: farm.farm_id, + }); + expect(res.status).toBe(200); + const targetUser1 = await userFarmModel.query().where('user_id', owner.user_id).first(); + expect(targetUser1.step_three).toBe(true); + expect(targetUser1.step_three_end).toBe(targetUser.step_three_end); }); - test('Update step_four of farm', async (done) => { + test('Update step_four of farm', async () => { const { user: owner, farm } = await setupUserFarm({}); const targetUser = await userFarmModel.query().where('user_id', owner.user_id).first(); expect(targetUser.step_four).toBe(false); targetUser.step_four = true; targetUser.step_four_end = '2020-10-21 14:43:06.718035-07'; - updateOnboarding( - targetUser, - { user_id: owner.user_id, farm_id: farm.farm_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - const targetUser1 = await userFarmModel.query().where('user_id', owner.user_id).first(); - expect(targetUser1.step_four).toBe(true); - expect(targetUser1.step_four_end).toBe(targetUser.step_four_end); - done(); - }, - ); + const res = await updateOnboarding(targetUser, { + user_id: owner.user_id, + farm_id: farm.farm_id, + }); + expect(res.status).toBe(200); + const targetUser1 = await userFarmModel.query().where('user_id', owner.user_id).first(); + expect(targetUser1.step_four).toBe(true); + expect(targetUser1.step_four_end).toBe(targetUser.step_four_end); }); - test('Update step_five of farm', async (done) => { + test('Update step_five of farm', async () => { const { user: owner, farm } = await setupUserFarm({}); const targetUser = await userFarmModel.query().where('user_id', owner.user_id).first(); expect(targetUser.step_five).toBe(false); targetUser.step_five = true; targetUser.step_five_end = '2020-10-21 14:43:06.718035-07'; - updateOnboarding( - targetUser, - { user_id: owner.user_id, farm_id: farm.farm_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - const targetUser1 = await userFarmModel.query().where('user_id', owner.user_id).first(); - expect(targetUser1.step_five).toBe(true); - expect(targetUser1.step_five_end).toBe(targetUser.step_five_end); - done(); - }, - ); + const res = await updateOnboarding(targetUser, { + user_id: owner.user_id, + farm_id: farm.farm_id, + }); + expect(res.status).toBe(200); + const targetUser1 = await userFarmModel.query().where('user_id', owner.user_id).first(); + expect(targetUser1.step_five).toBe(true); + expect(targetUser1.step_five_end).toBe(targetUser.step_five_end); }); describe('Get user farm info by farm: authorization tests', () => { describe('Get all user farm info', () => { - test('Owner should get all user farm info', async (done) => { + test('Owner should get all user farm info', async () => { const { owner, farm } = await setupFarmWithVariousUsers(); - getUserFarmsOfFarmRequest( - { user_id: owner.user_id, farm_id: farm.farm_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - expect(res.body.length).toBe(4); - // check if sensitive info can be accessed - expect(res.body[0].address).toBeDefined(); - for (const userFarm of res.body) { - if (userFarm.user_id === owner.user_id) { - expect(userFarm.gender).toBe(owner.gender); - expect(userFarm.birth_year).toBe(owner.birth_year); - } else { - expect(userFarm.gender).toBeUndefined(); - expect(userFarm.birth_year).toBeUndefined(); - } - } - done(); - }, - ); + const res = await getUserFarmsOfFarmRequest({ + user_id: owner.user_id, + farm_id: farm.farm_id, + }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(4); + // check if sensitive info can be accessed + expect(res.body[0].address).toBeDefined(); + for (const userFarm of res.body) { + if (userFarm.user_id === owner.user_id) { + expect(userFarm.gender).toBe(owner.gender); + expect(userFarm.birth_year).toBe(owner.birth_year); + } else { + expect(userFarm.gender).toBeUndefined(); + expect(userFarm.birth_year).toBeUndefined(); + } + } }); - test('Manager should get all user farm info', async (done) => { + test('Manager should get all user farm info', async () => { const { manager, farm } = await setupFarmWithVariousUsers(); - getUserFarmsOfFarmRequest( - { user_id: manager.user_id, farm_id: farm.farm_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - expect(res.body.length).toBe(4); - // check if sensitive info can be accessed - expect(res.body[0].address).toBeDefined(); - done(); - }, - ); + const res = await getUserFarmsOfFarmRequest({ + user_id: manager.user_id, + farm_id: farm.farm_id, + }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(4); + // check if sensitive info can be accessed + expect(res.body[0].address).toBeDefined(); }); - test('Worker should get all user farm limited info', async (done) => { + test('Worker should get all user farm limited info', async () => { const { worker, farm } = await setupFarmWithVariousUsers(); - getUserFarmsOfFarmRequest( - { user_id: worker.user_id, farm_id: farm.farm_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - expect(res.body.length).toBe(4); - // check if sensitive info can be accessed - expect(res.body[0].address).toBeUndefined(); - // check if worker can view appropriate info - expect(res.body[0].first_name).toBeDefined(); - expect(res.body[0].last_name).toBeDefined(); - expect(res.body[0].profile_picture).toBeDefined(); - expect(res.body[0].phone_number).toBeDefined(); - expect(res.body[0].email).toBeDefined(); - expect(res.body[0].role).toBeDefined(); - expect(res.body[0].status).toBeDefined(); - done(); - }, - ); + const res = await getUserFarmsOfFarmRequest({ + user_id: worker.user_id, + farm_id: farm.farm_id, + }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(4); + // check if sensitive info can be accessed + expect(res.body[0].address).toBeUndefined(); + // check if worker can view appropriate info + expect(res.body[0].first_name).toBeDefined(); + expect(res.body[0].last_name).toBeDefined(); + expect(res.body[0].profile_picture).toBeDefined(); + expect(res.body[0].phone_number).toBeDefined(); + expect(res.body[0].email).toBeDefined(); + expect(res.body[0].role).toBeDefined(); + expect(res.body[0].status).toBeDefined(); }); - test('Return 403 if unauthorized user tries to get any user farm info', async (done) => { + test('Return 403 if unauthorized user tries to get any user farm info', async () => { const { farm } = await setupFarmWithVariousUsers(); const { user: unauthorizedUser } = await setupUserFarm({ role_id: 1 }); - getUserFarmsOfFarmRequest( - { user_id: unauthorizedUser.user_id, farm_id: farm.farm_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(403); - done(); - }, - ); + const res = await getUserFarmsOfFarmRequest({ + user_id: unauthorizedUser.user_id, + farm_id: farm.farm_id, + }); + expect(res.status).toBe(403); }); }); describe('Get active user farm info', () => { - test('Owner should get active user farm info', async (done) => { + test('Owner should get active user farm info', async () => { const { owner, farm } = await setupFarmWithVariousUsers(); - getActiveUserFarmsOfFarmRequest( - { user_id: owner.user_id, farm_id: farm.farm_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - expect(res.body.length).toBe(3); - // check if sensitive info can be accessed - expect(res.body[0].address).toBeDefined(); - done(); - }, - ); + const res = await getActiveUserFarmsOfFarmRequest({ + user_id: owner.user_id, + farm_id: farm.farm_id, + }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(3); + // check if sensitive info can be accessed + expect(res.body[0].address).toBeDefined(); }); - test('Manager should get active user farm info', async (done) => { + test('Manager should get active user farm info', async () => { const { manager, farm } = await setupFarmWithVariousUsers(); - getActiveUserFarmsOfFarmRequest( - { user_id: manager.user_id, farm_id: farm.farm_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - expect(res.body.length).toBe(3); - // check if sensitive info can be accessed - expect(res.body[0].address).toBeDefined(); - done(); - }, - ); + const res = await getActiveUserFarmsOfFarmRequest({ + user_id: manager.user_id, + farm_id: farm.farm_id, + }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(3); + // check if sensitive info can be accessed + expect(res.body[0].address).toBeDefined(); }); - test('Worker should get active user farm limited info', async (done) => { + test('Worker should get active user farm limited info', async () => { const { worker, farm } = await setupFarmWithVariousUsers(); - getActiveUserFarmsOfFarmRequest( - { user_id: worker.user_id, farm_id: farm.farm_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - expect(res.body.length).toBe(3); - // check if sensitive info can be accessed - expect(res.body[0].address).toBeUndefined(); - // check if worker can view appropriate info - expect(res.body[0].first_name).toBeDefined(); - expect(res.body[0].last_name).toBeDefined(); - expect(res.body[0].profile_picture).toBeDefined(); - expect(res.body[0].phone_number).toBeDefined(); - expect(res.body[0].email).toBeDefined(); - expect(res.body[0].role).toBeDefined(); - expect(res.body[0].status).toBeDefined(); - done(); - }, - ); + const res = await getActiveUserFarmsOfFarmRequest({ + user_id: worker.user_id, + farm_id: farm.farm_id, + }); + expect(res.status).toBe(200); + expect(res.body.length).toBe(3); + // check if sensitive info can be accessed + expect(res.body[0].address).toBeUndefined(); + // check if worker can view appropriate info + expect(res.body[0].first_name).toBeDefined(); + expect(res.body[0].last_name).toBeDefined(); + expect(res.body[0].profile_picture).toBeDefined(); + expect(res.body[0].phone_number).toBeDefined(); + expect(res.body[0].email).toBeDefined(); + expect(res.body[0].role).toBeDefined(); + expect(res.body[0].status).toBeDefined(); }); - test('Return 403 if unauthorized user tries to get active user farm info', async (done) => { + test('Return 403 if unauthorized user tries to get active user farm info', async () => { const { farm } = await setupFarmWithVariousUsers(); const { user: unauthorizedUser } = await setupUserFarm({ role_id: 1 }); - getActiveUserFarmsOfFarmRequest( - { user_id: unauthorizedUser.user_id, farm_id: farm.farm_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(403); - done(); - }, - ); + const res = await getActiveUserFarmsOfFarmRequest({ + user_id: unauthorizedUser.user_id, + farm_id: farm.farm_id, + }); + expect(res.status).toBe(403); }); }); }); @@ -566,342 +493,309 @@ describe('User Farm Tests', () => { describe('Update user farm: authorization tests', () => { describe('Update user farm role', () => { // TODO: eventually change how role is passed into endpoint - test('Owner should update user farm role', async (done) => { + test('Owner should update user farm role', async () => { const { user: owner, farm } = await setupUserFarm({}); const worker = await createUserFarmAtFarm({ role_id: 3 }, farm); const target_role_id = 2; const target_user_id = worker.user_id; - updateRoleRequest( + + const res = await updateRoleRequest( target_role_id, { user_id: owner.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - const updatedUserFarm = await userFarmModel - .query() - .where('farm_id', farm.farm_id) - .andWhere('user_id', target_user_id) - .first(); - expect(updatedUserFarm.role_id).toBe(target_role_id); - done(); - }, ); + + expect(res.status).toBe(200); + const updatedUserFarm = await userFarmModel + .query() + .where('farm_id', farm.farm_id) + .andWhere('user_id', target_user_id) + .first(); + expect(updatedUserFarm.role_id).toBe(target_role_id); }); - test('Manager should update user farm role', async (done) => { + test('Manager should update user farm role', async () => { const { user: manager, farm } = await setupUserFarm({ role_id: 2 }); const worker = await createUserFarmAtFarm({ role_id: 3 }, farm); const target_role_id = 2; const target_user_id = worker.user_id; - updateRoleRequest( + + const res = await updateRoleRequest( target_role_id, { user_id: manager.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - const updatedUserFarm = await userFarmModel - .query() - .where('farm_id', farm.farm_id) - .andWhere('user_id', target_user_id) - .first(); - expect(updatedUserFarm.role_id).toBe(target_role_id); - done(); - }, ); + + expect(res.status).toBe(200); + const updatedUserFarm = await userFarmModel + .query() + .where('farm_id', farm.farm_id) + .andWhere('user_id', target_user_id) + .first(); + expect(updatedUserFarm.role_id).toBe(target_role_id); }); - test('Return 403 if worker tries to update user farm role', async (done) => { + test('Return 403 if worker tries to update user farm role', async () => { const { manager, worker, farm } = await setupFarmWithVariousUsers(); const target_role = 'Worker'; const target_user_id = manager.user_id; - updateRoleRequest( + + const res = await updateRoleRequest( target_role, { user_id: worker.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(403); - done(); - }, ); + + expect(res.status).toBe(403); }); - test('Return 403 if unauthorized user tries to update user farm role', async (done) => { + test('Return 403 if unauthorized user tries to update user farm role', async () => { const { manager, farm } = await setupFarmWithVariousUsers(); const { user: unauthorizedUser } = await setupUserFarm({ role_id: 1 }); const target_role = 'Worker'; const target_user_id = manager.user_id; - updateRoleRequest( + + const res = await updateRoleRequest( target_role, { user_id: unauthorizedUser.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(403); - done(); - }, ); + + expect(res.status).toBe(403); }); - test('Return 400 if last owner/Manager tries to set themselves as standard worker', async (done) => { + test('Return 400 if last owner/Manager tries to set themselves as standard worker', async () => { const { owner, manager, farm } = await setupFarmWithVariousUsers(); const target_role = 'Worker'; const target_role_id = 3; let target_user_id = manager.user_id; - // turn manager to worker - updateRoleRequest( + + const res = await updateRoleRequest( target_role_id, { user_id: owner.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - const updatedUserFarm = await userFarmModel - .query() - .where('farm_id', farm.farm_id) - .andWhere('user_id', target_user_id) - .first(); - expect(updatedUserFarm.role_id).toBe(target_role_id); - target_user_id = owner.user_id; - // try to turn owner to worker - updateRoleRequest( - target_role, - { user_id: owner.user_id, farm_id: farm.farm_id }, - target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(400); - done(); - }, - ); - }, ); + + expect(res.status).toBe(200); + const updatedUserFarm = await userFarmModel + .query() + .where('farm_id', farm.farm_id) + .andWhere('user_id', target_user_id) + .first(); + expect(updatedUserFarm.role_id).toBe(target_role_id); + target_user_id = owner.user_id; + + { + const res = await updateRoleRequest( + target_role, + { user_id: owner.user_id, farm_id: farm.farm_id }, + target_user_id, + ); + + expect(res.status).toBe(400); + } }); - test('Return 404 if owner tries to update user farm role that is not part of their farm', async (done) => { + test('Return 404 if owner tries to update user farm role that is not part of their farm', async () => { const { user: owner, farm } = await setupUserFarm({}); const { user: unauthorizedUser } = await setupUserFarm({}); const target_role_id = 2; const target_user_id = unauthorizedUser.user_id; - updateRoleRequest( + + const res = await updateRoleRequest( target_role_id, { user_id: owner.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(404); - done(); - }, ); + + expect(res.status).toBe(404); }); }); describe('Update user farm status', () => { - test('Owner should update user farm status', async (done) => { + test('Owner should update user farm status', async () => { const { user: owner, farm } = await setupUserFarm({ role_id: 1 }); const worker = await createUserFarmAtFarm({ role_id: 3 }, farm); const target_status = 'Inactive'; const target_user_id = worker.user_id; - updateStatusRequest( + + const res = await updateStatusRequest( target_status, { user_id: owner.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - const updatedUserFarm = await userFarmModel - .query() - .where('farm_id', farm.farm_id) - .andWhere('user_id', target_user_id) - .first(); - expect(updatedUserFarm.status).toBe(target_status); - done(); - }, ); + + expect(res.status).toBe(200); + const updatedUserFarm = await userFarmModel + .query() + .where('farm_id', farm.farm_id) + .andWhere('user_id', target_user_id) + .first(); + expect(updatedUserFarm.status).toBe(target_status); }); - test('Manager should update user farm status', async (done) => { + test('Manager should update user farm status', async () => { const { user: manager, farm } = await setupUserFarm({ role_id: 2 }); const worker = await createUserFarmAtFarm({ role_id: 3 }, farm); const target_status = 'Inactive'; const target_user_id = worker.user_id; - updateStatusRequest( + + const res = await updateStatusRequest( target_status, { user_id: manager.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - const updatedUserFarm = await userFarmModel - .query() - .where('farm_id', farm.farm_id) - .andWhere('user_id', target_user_id) - .first(); - expect(updatedUserFarm.status).toBe(target_status); - done(); - }, ); + + expect(res.status).toBe(200); + const updatedUserFarm = await userFarmModel + .query() + .where('farm_id', farm.farm_id) + .andWhere('user_id', target_user_id) + .first(); + expect(updatedUserFarm.status).toBe(target_status); }); - test('Return 403 if worker tries to update user farm status', async (done) => { + test('Return 403 if worker tries to update user farm status', async () => { const { user: manager, farm } = await setupUserFarm({ role_id: 2 }); const worker = await createUserFarmAtFarm({ role_id: 3 }, farm); const target_status = 'Inactive'; const target_user_id = manager.user_id; - updateStatusRequest( + + const res = await updateStatusRequest( target_status, { user_id: worker.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(403); - done(); - }, ); + + expect(res.status).toBe(403); }); - test('Return 403 if unauthorized user tries to update user farm status', async (done) => { + test('Return 403 if unauthorized user tries to update user farm status', async () => { const { user: owner, farm } = await setupUserFarm({ role_id: 1 }); const { user: unauthorizedUser } = await setupUserFarm({ role_id: 1 }); const target_status = 'Inactive'; const target_user_id = owner.user_id; - updateStatusRequest( + + const res = await updateStatusRequest( target_status, { user_id: unauthorizedUser.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(403); - done(); - }, ); + + expect(res.status).toBe(403); }); - test('Allowed status change: Inactive -> Invited', async (done) => { + test('Allowed status change: Inactive -> Invited', async () => { const { user: owner, farm } = await setupUserFarm({ role_id: 1 }); const inactiveUser = await createUserFarmAtFarm({ role_id: 3, status: 'Inactive' }, farm); const target_status = 'Invited'; const target_user_id = inactiveUser.user_id; - updateStatusRequest( + + const res = await updateStatusRequest( target_status, { user_id: owner.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - const updatedUserFarm = await userFarmModel - .query() - .where('farm_id', farm.farm_id) - .andWhere('user_id', target_user_id) - .first(); - expect(updatedUserFarm.status).toBe(target_status); - done(); - }, ); + + expect(res.status).toBe(200); + const updatedUserFarm = await userFarmModel + .query() + .where('farm_id', farm.farm_id) + .andWhere('user_id', target_user_id) + .first(); + expect(updatedUserFarm.status).toBe(target_status); }); - test('Allowed status change: Inactive -> Active', async (done) => { + test('Allowed status change: Inactive -> Active', async () => { const { user: owner, farm } = await setupUserFarm({ role_id: 1 }); const inactiveUser = await createUserFarmAtFarm({ role_id: 3, status: 'Inactive' }, farm); const target_status = 'Active'; const target_user_id = inactiveUser.user_id; - updateStatusRequest( + + const res = await updateStatusRequest( target_status, { user_id: owner.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - done(); - }, ); + + expect(res.status).toBe(200); }); }); - test('Allowed status change: Invited -> Inactive', async (done) => { + test('Allowed status change: Invited -> Inactive', async () => { const { user: owner, farm } = await setupUserFarm({ role_id: 1 }); const invitedUser = await createUserFarmAtFarm({ role_id: 3, status: 'Invited' }, farm); const target_status = 'Inactive'; const target_user_id = invitedUser.user_id; - updateStatusRequest( + + const res = await updateStatusRequest( target_status, { user_id: owner.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - const updatedUserFarm = await userFarmModel - .query() - .where('farm_id', farm.farm_id) - .andWhere('user_id', target_user_id) - .first(); - expect(updatedUserFarm.status).toBe(target_status); - done(); - }, ); + + expect(res.status).toBe(200); + const updatedUserFarm = await userFarmModel + .query() + .where('farm_id', farm.farm_id) + .andWhere('user_id', target_user_id) + .first(); + expect(updatedUserFarm.status).toBe(target_status); }); - test('Forbidden status change: Invited -> Active', async (done) => { + test('Forbidden status change: Invited -> Active', async () => { const { user: owner, farm } = await setupUserFarm({ role_id: 1 }); const invitedUser = await createUserFarmAtFarm({ role_id: 3, status: 'Invited' }, farm); const target_status = 'Active'; const target_user_id = invitedUser.user_id; - updateStatusRequest( + + const res = await updateStatusRequest( target_status, { user_id: owner.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(400); - done(); - }, ); + + expect(res.status).toBe(400); }); - test('Forbidden status change: Active -> Invited', async (done) => { + test('Forbidden status change: Active -> Invited', async () => { const { user: owner, farm } = await setupUserFarm({ role_id: 1 }); const worker = await createUserFarmAtFarm({ role_id: 3 }, farm); const target_status = 'Invited'; const target_user_id = worker.user_id; - updateStatusRequest( + + const res = await updateStatusRequest( target_status, { user_id: owner.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(400); - done(); - }, ); + + expect(res.status).toBe(400); }); - test('Allowed status change: Active -> Inactive', async (done) => { + test('Allowed status change: Active -> Inactive', async () => { const { user: owner, farm } = await setupUserFarm({ role_id: 1 }); const worker = await createUserFarmAtFarm({ role_id: 3 }, farm); const target_status = 'Inactive'; const target_user_id = worker.user_id; - updateStatusRequest( + + const res = await updateStatusRequest( target_status, { user_id: owner.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - const updatedUserFarm = await userFarmModel - .query() - .where('farm_id', farm.farm_id) - .andWhere('user_id', target_user_id) - .first(); - expect(updatedUserFarm.status).toBe(target_status); - done(); - }, ); + + expect(res.status).toBe(200); + const updatedUserFarm = await userFarmModel + .query() + .where('farm_id', farm.farm_id) + .andWhere('user_id', target_user_id) + .first(); + expect(updatedUserFarm.status).toBe(target_status); }); describe('Update user farm wage', () => { - test('Owner should update user farm wage', async (done) => { + test('Owner should update user farm wage', async () => { const { user: owner, farm } = await setupUserFarm({ role_id: 1 }); const worker = await createUserFarmAtFarm({ role_id: 3 }, farm); const wage = { @@ -909,25 +803,21 @@ describe('User Farm Tests', () => { amount: 23, }; const target_user_id = worker.user_id; - updateWageRequest( + const res = await updateWageRequest( wage, { user_id: owner.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - const updatedUserFarm = await userFarmModel - .query() - .where('farm_id', farm.farm_id) - .andWhere('user_id', target_user_id) - .first(); - expect(updatedUserFarm.wage).toEqual(wage); - done(); - }, ); + expect(res.status).toBe(200); + const updatedUserFarm = await userFarmModel + .query() + .where('farm_id', farm.farm_id) + .andWhere('user_id', target_user_id) + .first(); + expect(updatedUserFarm.wage).toEqual(wage); }); - test('Manager should update user farm wage', async (done) => { + test('Manager should update user farm wage', async () => { const { user: manager, farm } = await setupUserFarm({ role_id: 2 }); const worker = await createUserFarmAtFarm({ role_id: 3 }, farm); const wage = { @@ -935,25 +825,21 @@ describe('User Farm Tests', () => { amount: 50000, }; const target_user_id = worker.user_id; - updateWageRequest( + const res = await updateWageRequest( wage, { user_id: manager.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(200); - const updatedUserFarm = await userFarmModel - .query() - .where('farm_id', farm.farm_id) - .andWhere('user_id', target_user_id) - .first(); - expect(updatedUserFarm.wage).toEqual(wage); - done(); - }, ); + expect(res.status).toBe(200); + const updatedUserFarm = await userFarmModel + .query() + .where('farm_id', farm.farm_id) + .andWhere('user_id', target_user_id) + .first(); + expect(updatedUserFarm.wage).toEqual(wage); }); - test('Return 403 if worker tries to update user farm wage', async (done) => { + test('Return 403 if worker tries to update user farm wage', async () => { const { farm } = await setupUserFarm({ role_id: 1 }); const worker = await createUserFarmAtFarm({ role_id: 3 }, farm); const wage = { @@ -961,19 +847,15 @@ describe('User Farm Tests', () => { amount: 50000, }; const target_user_id = worker.user_id; - updateWageRequest( + const res = await updateWageRequest( wage, { user_id: worker.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(403); - done(); - }, ); + expect(res.status).toBe(403); }); - test('Return 403 if unauthorized user tries to update user farm wage', async (done) => { + test('Return 403 if unauthorized user tries to update user farm wage', async () => { const { farm } = await setupUserFarm({ role_id: 1 }); const worker = await createUserFarmAtFarm({ role_id: 3 }, farm); const { user: unauthorizedUser } = await setupUserFarm({ role_id: 1 }); @@ -982,67 +864,60 @@ describe('User Farm Tests', () => { amount: 23, }; const target_user_id = worker.user_id; - updateWageRequest( + + const res = await updateWageRequest( wage, { user_id: unauthorizedUser.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(403); - done(); - }, ); + + expect(res.status).toBe(403); }); }); describe('Set wage_do_not_ask_again', () => { - const testWithRole = async (userRoleId, targetUserRoleId, done) => { + const testWithRole = async (userRoleId, targetUserRoleId) => { const { user: owner, farm } = await setupUserFarm({ role_id: userRoleId }); const worker = await createUserFarmAtFarm({ role_id: targetUserRoleId }, farm); const target_user_id = worker.user_id; - setWageDoNotAskAgainRequest( + const res = await setWageDoNotAskAgainRequest( { user_id: owner.user_id, farm_id: farm.farm_id }, target_user_id, - async (err, res) => { - const adminRoles = [1, 2, 5]; - if (adminRoles.includes(userRoleId)) { - expect(err).toEqual(null); - expect(res.status).toBe(200); - const updatedUserFarm = await userFarmModel - .query() - .where('farm_id', farm.farm_id) - .andWhere('user_id', target_user_id) - .first(); - expect(updatedUserFarm.wage_do_not_ask_again).toEqual(true); - done(); - return; - } - - expect(res.status).toBe(403); - done(); - }, ); + const adminRoles = [1, 2, 5]; + if (adminRoles.includes(userRoleId)) { + expect(res.status).toBe(200); + const updatedUserFarm = await userFarmModel + .query() + .where('farm_id', farm.farm_id) + .andWhere('user_id', target_user_id) + .first(); + expect(updatedUserFarm.wage_do_not_ask_again).toEqual(true); + return; + } + + expect(res.status).toBe(403); }; - test('Owner should be able to set wage_do_not_ask_again', async (done) => { - testWithRole(1, 3, done); + test('Owner should be able to set wage_do_not_ask_again', async () => { + await testWithRole(1, 3); }); - test('Manager should be able to set wage_do_not_ask_again', async (done) => { - testWithRole(2, 3, done); + test('Manager should be able to set wage_do_not_ask_again', async () => { + await testWithRole(2, 3); }); - test('EO should be able to set wage_do_not_ask_again', async (done) => { - testWithRole(5, 3, done); + test('EO should be able to set wage_do_not_ask_again', async () => { + await testWithRole(5, 3); }); - test('Farm worker should not be able to set wage_do_not_ask_again', async (done) => { - testWithRole(3, 3, done); + test('Farm worker should not be able to set wage_do_not_ask_again', async () => { + await testWithRole(3, 3); }); }); describe('Invite pseudo user test', () => { - test('Should invite a pseudo user when email does not exist in user table', async (done) => { + test('Should invite a pseudo user when email does not exist in user table', async () => { const { user: owner, farm } = await setupUserFarm({ role_id: 1 }); const [psedoUserFarm] = await mocks.userFarmFactory( { promisedFarm: [farm] }, @@ -1050,26 +925,24 @@ describe('User Farm Tests', () => { ); const email = faker.internet.email().toLowerCase(); const { wage, role_id } = mocks.fakeUserFarm(); - invitePseudoUserRequest( + + const res = await invitePseudoUserRequest( { email, role_id, wage }, { user_id: owner.user_id, farm_id: farm.farm_id, params_user_id: psedoUserFarm.user_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(201); - const updatedUserFarm = await userFarmModel - .query() - .findById([psedoUserFarm.user_id, psedoUserFarm.farm_id]); - const updatedUser = await userModel.query().findById(psedoUserFarm.user_id); - expect(updatedUser.email).toBe(email); - expect(updatedUser.status_id).toBe(2); - expect(updatedUserFarm.wage).toEqual(wage); - expect(updatedUserFarm.role_id).toBe(role_id); - done(); - }, ); + + expect(res.status).toBe(201); + const updatedUserFarm = await userFarmModel + .query() + .findById([psedoUserFarm.user_id, psedoUserFarm.farm_id]); + const updatedUser = await userModel.query().findById(psedoUserFarm.user_id); + expect(updatedUser.email).toBe(email); + expect(updatedUser.status_id).toBe(2); + expect(updatedUserFarm.wage).toEqual(wage); + expect(updatedUserFarm.role_id).toBe(role_id); }); - test('Should give access of a pseudo farm to an account when email exists in user table', async (done) => { + test('Should give access of a pseudo farm to an account when email exists in user table', async () => { const { user: owner, farm } = await setupUserFarm({ role_id: 1 }); const [psedoUserFarm] = await mocks.userFarmFactory( { promisedFarm: [farm] }, @@ -1082,34 +955,32 @@ describe('User Farm Tests', () => { user_id: `existing user ${psedoUserFarm.user_id}`, }); const { wage, role_id } = mocks.fakeUserFarm(); - invitePseudoUserRequest( + + const res = await invitePseudoUserRequest( { email, role_id, wage }, { user_id: owner.user_id, farm_id: farm.farm_id, params_user_id: psedoUserFarm.user_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(201); - const oldUserFarm = await userFarmModel - .query() - .findById([psedoUserFarm.user_id, psedoUserFarm.farm_id]); - const oldUser = await userModel.query().findById(psedoUserFarm.user_id); - expect(oldUser).toBeUndefined(); - expect(oldUserFarm).toBeUndefined(); - const updatedUserFarm = await userModel - .query() - .join('userFarm', 'userFarm.user_id', 'users.user_id') - .where({ 'users.user_id': existingUser.user_id, 'userFarm.farm_id': farm.farm_id }) - .first() - .select('*'); - expect(updatedUserFarm.email).toBe(email); - expect(updatedUserFarm.status_id).toBe(1); - expect(updatedUserFarm.wage).toEqual(wage); - expect(updatedUserFarm.role_id).toBe(role_id); - done(); - }, ); + + expect(res.status).toBe(201); + const oldUserFarm = await userFarmModel + .query() + .findById([psedoUserFarm.user_id, psedoUserFarm.farm_id]); + const oldUser = await userModel.query().findById(psedoUserFarm.user_id); + expect(oldUser).toBeUndefined(); + expect(oldUserFarm).toBeUndefined(); + const updatedUserFarm = await userModel + .query() + .join('userFarm', 'userFarm.user_id', 'users.user_id') + .where({ 'users.user_id': existingUser.user_id, 'userFarm.farm_id': farm.farm_id }) + .first() + .select('*'); + expect(updatedUserFarm.email).toBe(email); + expect(updatedUserFarm.status_id).toBe(1); + expect(updatedUserFarm.wage).toEqual(wage); + expect(updatedUserFarm.role_id).toBe(role_id); }); - test('Should return 400 on attempt to convert pseudo user with email already in use', async (done) => { + test('Should return 400 on attempt to convert pseudo user with email already in use', async () => { const { user: owner, farm } = await setupUserFarm({ role_id: 1 }); const [psedoUserFarm] = await mocks.userFarmFactory( { promisedFarm: [farm] }, @@ -1122,18 +993,16 @@ describe('User Farm Tests', () => { promisedUser: [existingUser], }); const { wage, role_id } = mocks.fakeUserFarm(); - invitePseudoUserRequest( + + const res = await invitePseudoUserRequest( { email, role_id, wage }, { user_id: owner.user_id, farm_id: farm.farm_id, params_user_id: psedoUserFarm.user_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(400); - done(); - }, ); + + expect(res.status).toBe(400); }); - test('Should return 400 if user is not a pseudo User', async (done) => { + test('Should return 400 if user is not a pseudo User', async () => { const { user: owner, farm } = await setupUserFarm({ role_id: 1 }); const [managerFarm] = await mocks.userFarmFactory( { promisedFarm: [farm] }, @@ -1141,21 +1010,19 @@ describe('User Farm Tests', () => { ); const { email } = await userModel.query().findById(managerFarm.user_id); const { wage, role_id } = mocks.fakeUserFarm(); - invitePseudoUserRequest( + + const res = await invitePseudoUserRequest( { email, role_id, wage }, { user_id: owner.user_id, farm_id: farm.farm_id, params_user_id: managerFarm.user_id }, - async (err, res) => { - expect(err).toEqual(null); - expect(res.status).toBe(400); - const userFarm = await userFarmModel - .query() - .findById([managerFarm.user_id, managerFarm.farm_id]); - delete userFarm.created_at; - delete managerFarm.created_at; - expect(userFarm).toEqual(managerFarm); - done(); - }, ); + + expect(res.status).toBe(400); + const userFarm = await userFarmModel + .query() + .findById([managerFarm.user_id, managerFarm.farm_id]); + delete userFarm.created_at; + delete managerFarm.created_at; + expect(userFarm).toEqual(managerFarm); }); }); }); diff --git a/packages/api/tests/userFarmData.test.js b/packages/api/tests/userFarmData.test.js index b8d7d299c4..f11ac7bf53 100644 --- a/packages/api/tests/userFarmData.test.js +++ b/packages/api/tests/userFarmData.test.js @@ -42,32 +42,26 @@ describe('userFarm Tests', () => { token = global.token; }); - function postUserFarmDataRequest( - data, - { user_id = newOwner.user_id, farm_id = farm.farm_id }, - callback, - ) { - chai + function postUserFarmDataRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post(`/farmdata`) .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } function fakeUserFarm(role = 1) { return { ...mocks.fakeUserFarm(), role_id: role }; } - function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { - chai + function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .get(`/farmdata/${farm_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } function getFakeUserFarmData(farm_id, user_id) { @@ -101,137 +95,120 @@ describe('userFarm Tests', () => { [newOwner] = await mocks.usersFactory(); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); describe('Post userFarm tests', () => { - test('Owner should post farm data at their farm', async (done) => { + test('Owner should post farm data at their farm', async () => { const { mainFarm, user } = await returnUserFarms(1); const fakeUserFarmData = await getFakeUserFarmData(mainFarm.farm_id, user.user_id); - postUserFarmDataRequest( - fakeUserFarmData, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - const userFarmDatas = await userFarmModel - .query() - .where('farm_id', mainFarm.farm_id) - .andWhere('user_id', user.user_id); - expect(userFarmDatas.length).toBe(1); - expect(userFarmDatas[0].farm_id).toBe(fakeUserFarmData.farm_id); - expect(userFarmDatas[0].user_id).toBe(fakeUserFarmData.user_id); - done(); - }, - ); + const res = await postUserFarmDataRequest(fakeUserFarmData, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(200); + const userFarmDatas = await userFarmModel + .query() + .where('farm_id', mainFarm.farm_id) + .andWhere('user_id', user.user_id); + expect(userFarmDatas.length).toBe(1); + expect(userFarmDatas[0].farm_id).toBe(fakeUserFarmData.farm_id); + expect(userFarmDatas[0].user_id).toBe(fakeUserFarmData.user_id); }); - test('Manager should post farm data at their farm', async (done) => { + test('Manager should post farm data at their farm', async () => { const { mainFarm, user } = await returnUserFarms(2); const fakeUserFarmData = await getFakeUserFarmData(mainFarm.farm_id, user.user_id); - postUserFarmDataRequest( - fakeUserFarmData, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - const userFarmDatas = await userFarmModel - .query() - .where('farm_id', mainFarm.farm_id) - .andWhere('user_id', user.user_id); - expect(userFarmDatas.length).toBe(1); - expect(userFarmDatas[0].farm_id).toBe(fakeUserFarmData.farm_id); - expect(userFarmDatas[0].user_id).toBe(fakeUserFarmData.user_id); - done(); - }, - ); + const res = await postUserFarmDataRequest(fakeUserFarmData, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(200); + const userFarmDatas = await userFarmModel + .query() + .where('farm_id', mainFarm.farm_id) + .andWhere('user_id', user.user_id); + expect(userFarmDatas.length).toBe(1); + expect(userFarmDatas[0].farm_id).toBe(fakeUserFarmData.farm_id); + expect(userFarmDatas[0].user_id).toBe(fakeUserFarmData.user_id); }); - test('Should return 403 when worker tries to post farm data at their farm', async (done) => { + test('Should return 403 when worker tries to post farm data at their farm', async () => { const { mainFarm, user } = await returnUserFarms(3); const fakeUserFarmData = await getFakeUserFarmData(mainFarm.farm_id, user.user_id); - postUserFarmDataRequest( - fakeUserFarmData, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): add:farm_schedules', - ); - done(); - }, + const res = await postUserFarmDataRequest(fakeUserFarmData, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): add:farm_schedules', ); }); - test('Should return 403 when unauthorized user tries to post farm data', async (done) => { + test('Should return 403 when unauthorized user tries to post farm data', async () => { const { mainFarm, user } = await returnUserFarms(1); const fakeUserFarmData = await getFakeUserFarmData(mainFarm.farm_id, user.user_id); const [unAuthorizedUser] = await mocks.usersFactory(); - postUserFarmDataRequest( - fakeUserFarmData, - { user_id: unAuthorizedUser.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): add:farm_schedules', - ); - done(); - }, + const res = await postUserFarmDataRequest(fakeUserFarmData, { + user_id: unAuthorizedUser.user_id, + farm_id: mainFarm.farm_id, + }); + + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): add:farm_schedules', ); }); }); describe('Get userFarm tests', () => { - test('Owner should get user farm data by farm id', async (done) => { + test('Owner should get user farm data by farm id', async () => { const { mainFarm, user } = await returnUserFarms(1); const { user_farm_data } = await returnUserFarmData(user, mainFarm); - getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].farm_id).toBe(user_farm_data.farm_id); - done(); - }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + expect(res.status).toBe(200); + expect(res.body[0].farm_id).toBe(user_farm_data.farm_id); }); - test('Manager should get user farm data by farm id', async (done) => { + test('Manager should get user farm data by farm id', async () => { const { mainFarm, user } = await returnUserFarms(2); const { user_farm_data } = await returnUserFarmData(user, mainFarm); - getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].farm_id).toBe(user_farm_data.farm_id); - done(); - }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + expect(res.status).toBe(200); + expect(res.body[0].farm_id).toBe(user_farm_data.farm_id); }); - test('Worker should get 403 if they try to get user farm data by farm id', async (done) => { + test('Worker should get 403 if they try to get user farm data by farm id', async () => { const { mainFarm, user } = await returnUserFarms(3); const { user_farm_data } = await returnUserFarmData(user, mainFarm); - getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }, (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): get:farm_schedules', - ); - done(); - }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): get:farm_schedules', + ); }); - test('Should get status 403 if an unauthorizedUser tries to get user farm by farm id', async (done) => { + test('Should get status 403 if an unauthorizedUser tries to get user farm by farm id', async () => { const { mainFarm, user } = await returnUserFarms(1); const [unAuthorizedUser] = await mocks.usersFactory(); - getRequest({ user_id: unAuthorizedUser.user_id, farm_id: mainFarm.farm_id }, (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): get:farm_schedules', - ); - done(); + const res = await getRequest({ + user_id: unAuthorizedUser.user_id, + farm_id: mainFarm.farm_id, }); + expect(res.status).toBe(403); + expect(res.error.text).toBe( + 'User does not have the following permission(s): get:farm_schedules', + ); }); }); }); diff --git a/packages/api/tests/yield.test.js b/packages/api/tests/yield.test.js index 283109582c..c2432a51ce 100644 --- a/packages/api/tests/yield.test.js +++ b/packages/api/tests/yield.test.js @@ -43,53 +43,47 @@ describe('Yield Tests', () => { token = global.token; }); - function postYieldRequest( - data, - { user_id = newOwner.user_id, farm_id = farm.farm_id }, - callback, - ) { - chai + function postYieldRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .post('/yield') .set('Content-Type', 'application/json') .set('user_id', user_id) .set('farm_id', farm_id) - .send(data) - .end(callback); + .send(data); } function fakeUserFarm(role = 1) { return { ...mocks.fakeUserFarm(), role_id: role }; } - function putYieldRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { + function putYieldRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { const { yield_id } = data; - chai + + return chai .request(server) .put(`/yield/${yield_id}`) .set('farm_id', farm_id) .set('user_id', user_id) - .send(data) - .end(callback); + .send(data); } - function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { - chai + function getRequest({ user_id = newOwner.user_id, farm_id = farm.farm_id }) { + return chai .request(server) .get(`/yield/farm/${farm_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } - function deleteRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }, callback) { + function deleteRequest(data, { user_id = newOwner.user_id, farm_id = farm.farm_id }) { const { yield_id } = data; - chai + + return chai .request(server) .delete(`/yield/${yield_id}`) .set('user_id', user_id) - .set('farm_id', farm_id) - .end(callback); + .set('farm_id', farm_id); } async function returnUserFarms(role) { @@ -127,268 +121,220 @@ describe('Yield Tests', () => { [crop] = await mocks.cropFactory({ promisedFarm: [farm] }); }); - afterAll(async (done) => { + afterAll(async () => { await tableCleanup(knex); await knex.destroy(); - done(); }); // POST TESTS describe('Post yield tests', () => { - test('Owner should post yield', async (done) => { + test('Owner should post yield', async () => { const { mainFarm, user } = await returnUserFarms(1); const { crop } = await returnCrop(mainFarm); const cropYield = getFakeYield(crop.crop_id, mainFarm.farm_id); - postYieldRequest( - cropYield, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(201); - const yields = await yieldModel.query().where('farm_id', mainFarm.farm_id); - expect(yields.length).toBe(1); - expect(yields[0].yield_id).toBe(cropYield.yield_id); - done(); - }, - ); + const res = await postYieldRequest(cropYield, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(201); + const yields = await yieldModel.query().where('farm_id', mainFarm.farm_id); + expect(yields.length).toBe(1); + expect(yields[0].yield_id).toBe(cropYield.yield_id); }); - test('Manager should post yield', async (done) => { + test('Manager should post yield', async () => { const { mainFarm, user } = await returnUserFarms(2); const { crop } = await returnCrop(mainFarm); const cropYield = getFakeYield(crop.crop_id, mainFarm.farm_id); - postYieldRequest( - cropYield, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(201); - const yields = await yieldModel.query().where('farm_id', mainFarm.farm_id); - expect(yields.length).toBe(1); - expect(yields[0].yield_id).toBe(cropYield.yield_id); - done(); - }, - ); + const res = await postYieldRequest(cropYield, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(201); + const yields = await yieldModel.query().where('farm_id', mainFarm.farm_id); + expect(yields.length).toBe(1); + expect(yields[0].yield_id).toBe(cropYield.yield_id); }); - test('Should return 403 when worker tries to post yield', async (done) => { + test('Should return 403 when worker tries to post yield', async () => { const { mainFarm, user } = await returnUserFarms(3); const { crop } = await returnCrop(mainFarm); const cropYield = getFakeYield(crop.crop_id, mainFarm.farm_id); - postYieldRequest( - cropYield, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('User does not have the following permission(s): add:yields'); - done(); - }, - ); + const res = await postYieldRequest(cropYield, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): add:yields'); }); - test('Should return 403 when unauthorized user tries to post yield', async (done) => { + test('Should return 403 when unauthorized user tries to post yield', async () => { const { mainFarm, user } = await returnUserFarms(1); const { cropYield } = await returnYield(mainFarm); const [unAuthorizedUser] = await mocks.usersFactory(); - postYieldRequest( - cropYield, - { user_id: unAuthorizedUser.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('user not authorized to access farm'); - done(); - }, - ); + const res = await postYieldRequest(cropYield, { + user_id: unAuthorizedUser.user_id, + farm_id: mainFarm.farm_id, + }); + + expect(res.status).toBe(403); + expect(res.error.text).toBe('user not authorized to access farm'); }); }); // PUT TESTS describe('Put yield tests', () => { - test('Owner should update quantity_kg/m2', async (done) => { + test('Owner should update quantity_kg/m2', async () => { const { mainFarm, user } = await returnUserFarms(1); const { crop_yield } = await returnYield(mainFarm); crop_yield['quantity_kg/m2'] = 8; - putYieldRequest( - crop_yield, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0]['quantity_kg/m2']).toBe(8); - done(); - }, - ); + const res = await putYieldRequest(crop_yield, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(200); + expect(res.body[0]['quantity_kg/m2']).toBe(8); }); - test('Manager should update quantity_kg/m2', async (done) => { + test('Manager should update quantity_kg/m2', async () => { const { mainFarm, user } = await returnUserFarms(2); const { crop_yield } = await returnYield(mainFarm); crop_yield['quantity_kg/m2'] = 22; - putYieldRequest( - crop_yield, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0]['quantity_kg/m2']).toBe(22); - done(); - }, - ); + const res = await putYieldRequest(crop_yield, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(200); + expect(res.body[0]['quantity_kg/m2']).toBe(22); }); - test('Should return 403 when a worker tries to edit quantity_kg/m2', async (done) => { + test('Should return 403 when a worker tries to edit quantity_kg/m2', async () => { const { mainFarm, user } = await returnUserFarms(3); const { crop_yield } = await returnYield(mainFarm); crop_yield['quantity_kg/m2'] = 4; - putYieldRequest( - crop_yield, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): edit:yields', - ); - done(); - }, - ); + const res = await putYieldRequest(crop_yield, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): edit:yields'); }); - test('Should return 403 when a unauthorized user tries to edit quantity_kg/m2', async (done) => { + test('Should return 403 when a unauthorized user tries to edit quantity_kg/m2', async () => { const { mainFarm, user } = await returnUserFarms(1); const { crop_yield } = await returnYield(mainFarm); const [unAuthorizedUser] = await mocks.usersFactory(); crop_yield['quantity_kg/m2'] = 4; - putYieldRequest(crop_yield, { user_id: unAuthorizedUser.user_id }, async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('user not authorized to access farm'); - done(); - }); + const res = await putYieldRequest(crop_yield, { user_id: unAuthorizedUser.user_id }); + expect(res.status).toBe(403); + expect(res.error.text).toBe('user not authorized to access farm'); }); }); // GET TESTS describe('Get yield tests', () => { - test('Owner should get yield by farm id', async (done) => { + test('Owner should get yield by farm id', async () => { const { mainFarm, user } = await returnUserFarms(1); const { crop_yield } = await returnYield(mainFarm); - getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].farm_id).toBe(crop_yield.farm_id); - done(); - }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + expect(res.status).toBe(200); + expect(res.body[0].farm_id).toBe(crop_yield.farm_id); }); - test('Manager should get yield by farm id', async (done) => { + test('Manager should get yield by farm id', async () => { const { mainFarm, user } = await returnUserFarms(2); const { crop_yield } = await returnYield(mainFarm); - getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].farm_id).toBe(crop_yield.farm_id); - done(); - }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + expect(res.status).toBe(200); + expect(res.body[0].farm_id).toBe(crop_yield.farm_id); }); - test('Worker should get yield by farm id', async (done) => { + test('Worker should get yield by farm id', async () => { const { mainFarm, user } = await returnUserFarms(3); const { crop_yield } = await returnYield(mainFarm); - getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }, (err, res) => { - expect(res.status).toBe(200); - expect(res.body[0].farm_id).toBe(crop_yield.farm_id); - done(); - }); + const res = await getRequest({ user_id: user.user_id, farm_id: mainFarm.farm_id }); + expect(res.status).toBe(200); + expect(res.body[0].farm_id).toBe(crop_yield.farm_id); }); - test('Should get status 403 if an unauthorizedUser tries to get yield by farm id', async (done) => { + test('Should get status 403 if an unauthorizedUser tries to get yield by farm id', async () => { const { mainFarm, user } = await returnUserFarms(1); const [unAuthorizedUser] = await mocks.usersFactory(); - getRequest({ user_id: unAuthorizedUser.user_id, farm_id: mainFarm.farm_id }, (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe('User does not have the following permission(s): get:yields'); - done(); + const res = await getRequest({ + user_id: unAuthorizedUser.user_id, + farm_id: mainFarm.farm_id, }); + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): get:yields'); }); }); // DELETE TESTS describe('Delete yield tests', () => { - test('Owner should delete their yield', async (done) => { + test('Owner should delete their yield', async () => { const { mainFarm, user } = await returnUserFarms(1); const { crop_yield } = await returnYield(mainFarm); - deleteRequest( - crop_yield, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - const [deletedField] = await yieldModel.query().where('yield_id', crop_yield.yield_id); - expect(deletedField.deleted).toBe(true); - done(); - }, - ); + const res = await deleteRequest(crop_yield, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(200); + const [deletedField] = await yieldModel.query().where('yield_id', crop_yield.yield_id); + expect(deletedField.deleted).toBe(true); }); - test('Manager should delete their yield', async (done) => { + test('Manager should delete their yield', async () => { const { mainFarm, user } = await returnUserFarms(2); const { crop_yield } = await returnYield(mainFarm); - deleteRequest( - crop_yield, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(200); - const [deletedField] = await yieldModel.query().where('yield_id', crop_yield.yield_id); - expect(deletedField.deleted).toBe(true); - done(); - }, - ); + const res = await deleteRequest(crop_yield, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(200); + const [deletedField] = await yieldModel.query().where('yield_id', crop_yield.yield_id); + expect(deletedField.deleted).toBe(true); }); - test('Should return 403 if a worker tries to delete a yield', async (done) => { + test('Should return 403 if a worker tries to delete a yield', async () => { const { mainFarm, user } = await returnUserFarms(3); const { crop_yield } = await returnYield(mainFarm); - deleteRequest( - crop_yield, - { user_id: user.user_id, farm_id: mainFarm.farm_id }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): delete:yields', - ); - done(); - }, - ); + const res = await deleteRequest(crop_yield, { + user_id: user.user_id, + farm_id: mainFarm.farm_id, + }); + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): delete:yields'); }); - test('Should get status 403 if an unauthorizedUser tries to delete yield', async (done) => { + test('Should get status 403 if an unauthorizedUser tries to delete yield', async () => { const { mainFarm, user } = await returnUserFarms(1); const { crop_yield } = await returnYield(mainFarm); const [unAuthorizedUser] = await mocks.usersFactory(); - deleteRequest( - crop_yield, - { - user_id: unAuthorizedUser.user_id, - farm_id: mainFarm.farm_id, - }, - async (err, res) => { - expect(res.status).toBe(403); - expect(res.error.text).toBe( - 'User does not have the following permission(s): delete:yields', - ); - done(); - }, - ); + const res = await deleteRequest(crop_yield, { + user_id: unAuthorizedUser.user_id, + farm_id: mainFarm.farm_id, + }); + + expect(res.status).toBe(403); + expect(res.error.text).toBe('User does not have the following permission(s): delete:yields'); }); }); });