diff --git a/package-lock.json b/package-lock.json index 45c57dcdb6..90ce849cd0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,8 +19,8 @@ "@types/jest": "^29.5.13", "@types/lodash.clone": "^4.5.9", "@types/node": "^22.7.7", - "@typescript-eslint/eslint-plugin": "^8.10.0", - "@typescript-eslint/parser": "^8.10.0", + "@typescript-eslint/eslint-plugin": "^8.11.0", + "@typescript-eslint/parser": "^8.11.0", "cross-env": "^7.0.3", "dotenv-extended": "^2.9.0", "eslint": "^8.57.1", @@ -30,7 +30,7 @@ "formdata-node": "^6.0.3", "graphql": "^16.9.0", "jest": "^29.7.0", - "mongodb": "^6.9.0", + "mongodb": "^6.10.0", "npm-run-all": "^4.1.5", "prettier": "^3.3.3", "stripe": "^16.12.0", @@ -55,6 +55,7 @@ "@unchainedshop/core-payment": "^3.0.0-alpha3", "@unchainedshop/platform": "^3.0.0-alpha3", "@unchainedshop/plugins": "^3.0.0-alpha3", + "@unchainedshop/ticketing": "^3.0.0-alpha3", "bip32": "^4.0.0", "bitcoinjs-lib": "^6.1.6", "cookie-parser": "^1.4.7", @@ -2802,17 +2803,17 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.10.0.tgz", - "integrity": "sha512-phuB3hoP7FFKbRXxjl+DRlQDuJqhpOnm5MmtROXyWi3uS/Xg2ZXqiQfcG2BJHiN4QKyzdOJi3NEn/qTnjUlkmQ==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.11.0.tgz", + "integrity": "sha512-KhGn2LjW1PJT2A/GfDpiyOfS4a8xHQv2myUagTM5+zsormOmBlYsnQ6pobJ8XxJmh6hnHwa2Mbe3fPrDJoDhbA==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "8.10.0", - "@typescript-eslint/type-utils": "8.10.0", - "@typescript-eslint/utils": "8.10.0", - "@typescript-eslint/visitor-keys": "8.10.0", + "@typescript-eslint/scope-manager": "8.11.0", + "@typescript-eslint/type-utils": "8.11.0", + "@typescript-eslint/utils": "8.11.0", + "@typescript-eslint/visitor-keys": "8.11.0", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", @@ -2836,16 +2837,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.10.0.tgz", - "integrity": "sha512-E24l90SxuJhytWJ0pTQydFT46Nk0Z+bsLKo/L8rtQSL93rQ6byd1V/QbDpHUTdLPOMsBCcYXZweADNCfOCmOAg==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.11.0.tgz", + "integrity": "sha512-lmt73NeHdy1Q/2ul295Qy3uninSqi6wQI18XwSpm8w0ZbQXUpjCAWP1Vlv/obudoBiIjJVjlztjQ+d/Md98Yxg==", "dev": true, "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/scope-manager": "8.10.0", - "@typescript-eslint/types": "8.10.0", - "@typescript-eslint/typescript-estree": "8.10.0", - "@typescript-eslint/visitor-keys": "8.10.0", + "@typescript-eslint/scope-manager": "8.11.0", + "@typescript-eslint/types": "8.11.0", + "@typescript-eslint/typescript-estree": "8.11.0", + "@typescript-eslint/visitor-keys": "8.11.0", "debug": "^4.3.4" }, "engines": { @@ -2865,14 +2866,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.10.0.tgz", - "integrity": "sha512-AgCaEjhfql9MDKjMUxWvH7HjLeBqMCBfIaBbzzIcBbQPZE7CPh1m6FF+L75NUMJFMLYhCywJXIDEMa3//1A0dw==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.11.0.tgz", + "integrity": "sha512-Uholz7tWhXmA4r6epo+vaeV7yjdKy5QFCERMjs1kMVsLRKIrSdM6o21W2He9ftp5PP6aWOVpD5zvrvuHZC0bMQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.10.0", - "@typescript-eslint/visitor-keys": "8.10.0" + "@typescript-eslint/types": "8.11.0", + "@typescript-eslint/visitor-keys": "8.11.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2883,14 +2884,14 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.10.0.tgz", - "integrity": "sha512-PCpUOpyQSpxBn230yIcK+LeCQaXuxrgCm2Zk1S+PTIRJsEfU6nJ0TtwyH8pIwPK/vJoA+7TZtzyAJSGBz+s/dg==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.11.0.tgz", + "integrity": "sha512-ItiMfJS6pQU0NIKAaybBKkuVzo6IdnAhPFZA/2Mba/uBjuPQPet/8+zh5GtLHwmuFRShZx+8lhIs7/QeDHflOg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/typescript-estree": "8.10.0", - "@typescript-eslint/utils": "8.10.0", + "@typescript-eslint/typescript-estree": "8.11.0", + "@typescript-eslint/utils": "8.11.0", "debug": "^4.3.4", "ts-api-utils": "^1.3.0" }, @@ -2908,9 +2909,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.10.0.tgz", - "integrity": "sha512-k/E48uzsfJCRRbGLapdZgrX52csmWJ2rcowwPvOZ8lwPUv3xW6CcFeJAXgx4uJm+Ge4+a4tFOkdYvSpxhRhg1w==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.11.0.tgz", + "integrity": "sha512-tn6sNMHf6EBAYMvmPUaKaVeYvhUsrE6x+bXQTxjQRp360h1giATU0WvgeEys1spbvb5R+VpNOZ+XJmjD8wOUHw==", "dev": true, "license": "MIT", "engines": { @@ -2922,14 +2923,14 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.10.0.tgz", - "integrity": "sha512-3OE0nlcOHaMvQ8Xu5gAfME3/tWVDpb/HxtpUZ1WeOAksZ/h/gwrBzCklaGzwZT97/lBbbxJ16dMA98JMEngW4w==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.11.0.tgz", + "integrity": "sha512-yHC3s1z1RCHoCz5t06gf7jH24rr3vns08XXhfEqzYpd6Hll3z/3g23JRi0jM8A47UFKNc3u/y5KIMx8Ynbjohg==", "dev": true, "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/types": "8.10.0", - "@typescript-eslint/visitor-keys": "8.10.0", + "@typescript-eslint/types": "8.11.0", + "@typescript-eslint/visitor-keys": "8.11.0", "debug": "^4.3.4", "fast-glob": "^3.3.2", "is-glob": "^4.0.3", @@ -2951,16 +2952,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.10.0.tgz", - "integrity": "sha512-Oq4uZ7JFr9d1ZunE/QKy5egcDRXT/FrS2z/nlxzPua2VHFtmMvFNDvpq1m/hq0ra+T52aUezfcjGRIB7vNJF9w==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.11.0.tgz", + "integrity": "sha512-CYiX6WZcbXNJV7UNB4PLDIBtSdRmRI/nb0FMyqHPTQD1rMjA0foPLaPUV39C/MxkTd/QKSeX+Gb34PPsDVC35g==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "8.10.0", - "@typescript-eslint/types": "8.10.0", - "@typescript-eslint/typescript-estree": "8.10.0" + "@typescript-eslint/scope-manager": "8.11.0", + "@typescript-eslint/types": "8.11.0", + "@typescript-eslint/typescript-estree": "8.11.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2974,13 +2975,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.10.0.tgz", - "integrity": "sha512-k8nekgqwr7FadWk548Lfph6V3r9OVqjzAIVskE7orMZR23cGJjAOVazsZSJW+ElyjfTM4wx/1g88Mi70DDtG9A==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.11.0.tgz", + "integrity": "sha512-EaewX6lxSjRJnc+99+dqzTeoDZUfyrA52d2/HRrkI830kgovWsmIiTfmr0NZorzqic7ga+1bS60lRBUgR3n/Bw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.10.0", + "@typescript-eslint/types": "8.11.0", "eslint-visitor-keys": "^3.4.3" }, "engines": { @@ -4259,9 +4260,9 @@ "license": "MIT" }, "node_modules/browserslist": { - "version": "4.24.0", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.0.tgz", - "integrity": "sha512-Rmb62sR1Zpjql25eSanFGEhAxcFwfA1K0GuQcLoaJBAcENegrQut3hYdhXFF1obQfiDyqIW/cLM5HSJ/9k884A==", + "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": [ { @@ -4279,10 +4280,10 @@ ], "license": "MIT", "dependencies": { - "caniuse-lite": "^1.0.30001663", - "electron-to-chromium": "^1.5.28", + "caniuse-lite": "^1.0.30001669", + "electron-to-chromium": "^1.5.41", "node-releases": "^2.0.18", - "update-browserslist-db": "^1.1.0" + "update-browserslist-db": "^1.1.1" }, "bin": { "browserslist": "cli.js" @@ -4334,9 +4335,9 @@ } }, "node_modules/bson": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.8.0.tgz", - "integrity": "sha512-iOJg8pr7wq2tg/zSlCCHMi3hMm5JTOxLTagf3zxhcenHsFp+c6uOs6K7W5UE7A4QIJGtqh/ZovFNMP4mOPJynQ==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.9.0.tgz", + "integrity": "sha512-X9hJeyeM0//Fus+0pc5dSUMhhrrmWwQUtdavaQeF3Ta6m69matZkGWV/MrBcnwUeLC8W9kwwc2hfkZgUuCX3Ig==", "license": "Apache-2.0", "engines": { "node": ">=16.20.1" @@ -10877,9 +10878,9 @@ } }, "node_modules/mongodb": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.9.0.tgz", - "integrity": "sha512-UMopBVx1LmEUbW/QE0Hw18u583PEDVQmUmVzzBRH0o/xtE9DBRA5ZYLOjpLIa03i8FXjzvQECJcqoMvCXftTUA==", + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.10.0.tgz", + "integrity": "sha512-gP9vduuYWb9ZkDM546M+MP2qKVk5ZG2wPF63OvSRuUbqCR+11ZCAE1mOfllhlAG0wcoJY5yDL/rV3OmYEwXIzg==", "license": "Apache-2.0", "dependencies": { "@mongodb-js/saslprep": "^1.1.5", @@ -13497,9 +13498,9 @@ } }, "node_modules/set-cookie-parser": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.0.tgz", - "integrity": "sha512-lXLOiqpkUumhRdFF3k1osNXCy9akgx/dyPZ5p8qAg9seJzXr5ZrlqZuWIMuY6ejOsVLE6flJ5/h3lsn57fQ/PQ==", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.1.tgz", + "integrity": "sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ==", "license": "MIT" }, "node_modules/set-function-length": { @@ -16508,7 +16509,7 @@ }, "peerDependencies": { "@mongodb-js/zstd": "^1.2.2", - "mongodb": "^6.9.0" + "mongodb": "^6.10.0" } }, "packages/mongodb/node_modules/mongodb-memory-server": { diff --git a/package.json b/package.json index f0367828d8..aa7948cc04 100644 --- a/package.json +++ b/package.json @@ -52,8 +52,8 @@ "@types/jest": "^29.5.13", "@types/lodash.clone": "^4.5.9", "@types/node": "^22.7.7", - "@typescript-eslint/eslint-plugin": "^8.10.0", - "@typescript-eslint/parser": "^8.10.0", + "@typescript-eslint/eslint-plugin": "^8.11.0", + "@typescript-eslint/parser": "^8.11.0", "cross-env": "^7.0.3", "dotenv-extended": "^2.9.0", "eslint": "^8.57.1", @@ -63,7 +63,7 @@ "formdata-node": "^6.0.3", "graphql": "^16.9.0", "jest": "^29.7.0", - "mongodb": "^6.9.0", + "mongodb": "^6.10.0", "npm-run-all": "^4.1.5", "prettier": "^3.3.3", "stripe": "^16.12.0", diff --git a/packages/api/src/fastify/index.ts b/packages/api/src/fastify/index.ts index 503d32b14d..f2ffefc17f 100644 --- a/packages/api/src/fastify/index.ts +++ b/packages/api/src/fastify/index.ts @@ -24,8 +24,6 @@ const resolveUserRemoteAddress = (req: IncomingMessage) => { }; const { - BULK_IMPORT_API_PATH = '/bulk-import', - ERC_METADATA_API_PATH = '/erc-metadata', GRAPHQL_API_PATH = '/graphql', UNCHAINED_COOKIE_NAME = 'unchained_token', UNCHAINED_COOKIE_PATH = '/', @@ -50,11 +48,12 @@ const middlewareHook = async function middlewareHook(req: any, reply: any) { }; await emit(API_EVENTS.API_LOGIN_TOKEN_CREATED, { userId: user._id, ...tokenObject }); /* eslint-disable-next-line */ - (user as any)._inLoginMethodResponse = true; + (user as any)._inLoginMethodResponse = true; return { user, ...tokenObject }; } - async function logout(sessionId?: string) { /* eslint-disable-line */ + async function logout() { + /* eslint-disable-line */ if (!req.session?.userId) return false; const tokenObject = { _id: (req as any).session.sessionId, @@ -83,7 +82,6 @@ export const connect = ( { graphqlHandler, db, - unchainedAPI, }: { graphqlHandler: YogaServerInstance; db: mongodb.Db; unchainedAPI: UnchainedCore }, ) => { fastify.register(fastifyCookie); diff --git a/packages/core-assortments/src/module/buildFindSelector.test.ts b/packages/core-assortments/src/module/buildFindSelector.test.ts index b41cfa9f3f..2e47a3fcd3 100644 --- a/packages/core-assortments/src/module/buildFindSelector.test.ts +++ b/packages/core-assortments/src/module/buildFindSelector.test.ts @@ -1,91 +1,119 @@ -import { buildFindSelector } from "./configureAssortmentsModule.js"; +import { buildFindSelector } from './configureAssortmentsModule.js'; - - - - describe('buildFindSelector', () => { - it('Return the correct filter when passed no argument', async () => { - expect(buildFindSelector({})).toEqual({ isRoot: true, isActive: true, "deleted": null, }) - }); - it('Return the correct filter when passed queryString, assortmentId, assortmentSelector, includeInactive, includeLeaves, slugs, tags', async () => { - - expect(buildFindSelector({queryString: "hello world", assortmentIds: ['assortment-1', 'assortment-2'], assortmentSelector: {sequence: 1}, includeInactive: true, includeLeaves: true, slugs: ['assortment-slug-1', 'assortment-slug-2'], tags: ['assortment-tag']})).toEqual( { - sequence: 1, - _id: { '$in': [ 'assortment-1', 'assortment-2' ] }, - slugs: { '$in': [ 'assortment-slug-1', 'assortment-slug-2' ] }, - tags: { '$all': [ 'assortment-tag' ] }, - "deleted": null, - '$text': { '$search': 'hello world' } - } - ) +describe('buildFindSelector', () => { + it('Return the correct filter when passed no argument', () => { + expect(buildFindSelector({})).toEqual({ isRoot: true, isActive: true, deleted: null }); + }); + it('Return the correct filter when passed queryString, assortmentId, assortmentSelector, includeInactive, includeLeaves, slugs, tags', () => { + expect( + buildFindSelector({ + queryString: 'hello world', + assortmentIds: ['assortment-1', 'assortment-2'], + assortmentSelector: { sequence: 1 }, + includeInactive: true, + includeLeaves: true, + slugs: ['assortment-slug-1', 'assortment-slug-2'], + tags: ['assortment-tag'], + }), + ).toEqual({ + sequence: 1, + _id: { $in: ['assortment-1', 'assortment-2'] }, + slugs: { $in: ['assortment-slug-1', 'assortment-slug-2'] }, + tags: { $all: ['assortment-tag'] }, + deleted: null, + $text: { $search: 'hello world' }, }); + }); - it('Return the correct filter when passed queryString, assortmentId, assortmentSelector, includeInactive, includeLeaves, slugs', async () => { - - expect(buildFindSelector({queryString: "hello world", assortmentIds: ['assortment-1', 'assortment-2'], assortmentSelector: {sequence: 1}, includeInactive: true, includeLeaves: true, slugs: ['assortment-slug-1', 'assortment-slug-2']})).toEqual( { - sequence: 1, - "deleted": null, + it('Return the correct filter when passed queryString, assortmentId, assortmentSelector, includeInactive, includeLeaves, slugs', () => { + expect( + buildFindSelector({ + queryString: 'hello world', + assortmentIds: ['assortment-1', 'assortment-2'], + assortmentSelector: { sequence: 1 }, + includeInactive: true, + includeLeaves: true, + slugs: ['assortment-slug-1', 'assortment-slug-2'], + }), + ).toEqual({ + sequence: 1, + deleted: null, - _id: { '$in': [ 'assortment-1', 'assortment-2' ] }, - slugs: { '$in': [ 'assortment-slug-1', 'assortment-slug-2' ] }, - '$text': { '$search': 'hello world' } - } - ) + _id: { $in: ['assortment-1', 'assortment-2'] }, + slugs: { $in: ['assortment-slug-1', 'assortment-slug-2'] }, + $text: { $search: 'hello world' }, }); + }); - it('Return the correct filter when passed queryString, assortmentId, assortmentSelector, includeInactive, includeLeaves', async () => { - - expect(buildFindSelector({queryString: "hello world", assortmentIds: ['assortment-1', 'assortment-2'], assortmentSelector: {sequence: 1}, includeInactive: true, includeLeaves: true})).toEqual( { - sequence: 1, - "deleted": null, + it('Return the correct filter when passed queryString, assortmentId, assortmentSelector, includeInactive, includeLeaves', () => { + expect( + buildFindSelector({ + queryString: 'hello world', + assortmentIds: ['assortment-1', 'assortment-2'], + assortmentSelector: { sequence: 1 }, + includeInactive: true, + includeLeaves: true, + }), + ).toEqual({ + sequence: 1, + deleted: null, - _id: { '$in': [ 'assortment-1', 'assortment-2' ] }, - '$text': { '$search': 'hello world' } - } - ) + _id: { $in: ['assortment-1', 'assortment-2'] }, + $text: { $search: 'hello world' }, }); + }); - it('Return the correct filter when passed queryString, assortmentId, assortmentSelector, includeInactive', async () => { - - expect(buildFindSelector({queryString: "hello world", assortmentIds: ['assortment-1', 'assortment-2'], assortmentSelector: {sequence: 1}, includeInactive: true})).toEqual( { - sequence: 1, - "deleted": null, + it('Return the correct filter when passed queryString, assortmentId, assortmentSelector, includeInactive', () => { + expect( + buildFindSelector({ + queryString: 'hello world', + assortmentIds: ['assortment-1', 'assortment-2'], + assortmentSelector: { sequence: 1 }, + includeInactive: true, + }), + ).toEqual({ + sequence: 1, + deleted: null, - _id: { '$in': [ 'assortment-1', 'assortment-2' ] }, - '$text': { '$search': 'hello world' }, - } - ) + _id: { $in: ['assortment-1', 'assortment-2'] }, + $text: { $search: 'hello world' }, }); - it('Return the correct filter when passed queryString, assortmentId, assortmentSelector', async () => { - - expect(buildFindSelector({queryString: "hello world", assortmentIds: ['assortment-1', 'assortment-2'], assortmentSelector: {sequence: 1}})).toEqual( { - sequence: 1, - "deleted": null, + }); + it('Return the correct filter when passed queryString, assortmentId, assortmentSelector', () => { + expect( + buildFindSelector({ + queryString: 'hello world', + assortmentIds: ['assortment-1', 'assortment-2'], + assortmentSelector: { sequence: 1 }, + }), + ).toEqual({ + sequence: 1, + deleted: null, - _id: { '$in': [ 'assortment-1', 'assortment-2' ] }, - '$text': { '$search': 'hello world' }, - } - ) + _id: { $in: ['assortment-1', 'assortment-2'] }, + $text: { $search: 'hello world' }, }); + }); - it('Return the correct filter when passed assortmentId, assortmentSelector', async () => { - expect(buildFindSelector({ assortmentIds: ['assortment-1', 'assortment-2'], assortmentSelector: {sequence: 1}})).toEqual( { - sequence: 1, - "deleted": null, + it('Return the correct filter when passed assortmentId, assortmentSelector', () => { + expect( + buildFindSelector({ + assortmentIds: ['assortment-1', 'assortment-2'], + assortmentSelector: { sequence: 1 }, + }), + ).toEqual({ + sequence: 1, + deleted: null, - _id: { '$in': [ 'assortment-1', 'assortment-2' ] }, - } - ) + _id: { $in: ['assortment-1', 'assortment-2'] }, }); + }); - it('Return the correct filter when passed assortmentSelector', async () => { - expect(buildFindSelector({ assortmentSelector: {sequence: 1}})).toEqual( { - "deleted": null, + it('Return the correct filter when passed assortmentSelector', () => { + expect(buildFindSelector({ assortmentSelector: { sequence: 1 } })).toEqual({ + deleted: null, - sequence: 1 - } - ) + sequence: 1, }); - }) - - \ No newline at end of file + }); +}); diff --git a/packages/core-bookmarks/tests/bookmarks-index.test.ts b/packages/core-bookmarks/tests/bookmarks-index.test.ts index 9778d9fe8a..507f97a4cb 100644 --- a/packages/core-bookmarks/tests/bookmarks-index.test.ts +++ b/packages/core-bookmarks/tests/bookmarks-index.test.ts @@ -1,7 +1,5 @@ describe('Bookmark', () => { - - it('Check Bookmarks module', async () => { - expect(true).toBeTruthy() + it('Check Bookmarks module', () => { + expect(true).toBeTruthy(); }); - }); diff --git a/packages/core-countries/src/module/buildFindSelector.test.ts b/packages/core-countries/src/module/buildFindSelector.test.ts index 781525584a..3e5c44cc72 100644 --- a/packages/core-countries/src/module/buildFindSelector.test.ts +++ b/packages/core-countries/src/module/buildFindSelector.test.ts @@ -1,10 +1,16 @@ -import { buildFindSelector } from "./configureCountriesModule.js"; +import { buildFindSelector } from './configureCountriesModule.js'; describe('buildFindSelector', () => { - it('should return correct filter object', async () => { - expect(buildFindSelector({includeInactive: true, queryString: 'hello world'})).toEqual({ deleted: null, '$text': { '$search': 'hello world' } }) - expect(buildFindSelector({includeInactive: true})).toEqual({ deleted: null }) - expect(buildFindSelector({queryString: 'hello world'})).toEqual({ deleted: null, '$text': { '$search': 'hello world' }, isActive: true }) + it('should return correct filter object', () => { + expect(buildFindSelector({ includeInactive: true, queryString: 'hello world' })).toEqual({ + deleted: null, + $text: { $search: 'hello world' }, + }); + expect(buildFindSelector({ includeInactive: true })).toEqual({ deleted: null }); + expect(buildFindSelector({ queryString: 'hello world' })).toEqual({ + deleted: null, + $text: { $search: 'hello world' }, + isActive: true, + }); }); - }); diff --git a/packages/core-currencies/src/module/buildFindSelector.test.ts b/packages/core-currencies/src/module/buildFindSelector.test.ts index ebe653e4e3..c8acf45fb1 100644 --- a/packages/core-currencies/src/module/buildFindSelector.test.ts +++ b/packages/core-currencies/src/module/buildFindSelector.test.ts @@ -1,27 +1,35 @@ -import { buildFindSelector } from "./configureCurrenciesModule.js"; +import { buildFindSelector } from './configureCurrenciesModule.js'; describe('buildFindSelector', () => { - - it('should return correct filter object', async () => { - - expect(buildFindSelector({contractAddress: '0xf12EC0F79a8855d093DeCe22b24c0603f5b8E34A', includeInactive: true, queryString: 'hello world'})).toEqual({ + it('should return correct filter object', () => { + expect( + buildFindSelector({ + contractAddress: '0xf12EC0F79a8855d093DeCe22b24c0603f5b8E34A', + includeInactive: true, + queryString: 'hello world', + }), + ).toEqual({ deleted: null, contractAddress: '0xf12EC0F79a8855d093DeCe22b24c0603f5b8E34A', - '$text': { '$search': 'hello world' } - }) - expect(buildFindSelector({contractAddress: '0xf12EC0F79a8855d093DeCe22b24c0603f5b8E34A', includeInactive: true})).toEqual({ + $text: { $search: 'hello world' }, + }); + expect( + buildFindSelector({ + contractAddress: '0xf12EC0F79a8855d093DeCe22b24c0603f5b8E34A', + includeInactive: true, + }), + ).toEqual({ deleted: null, contractAddress: '0xf12EC0F79a8855d093DeCe22b24c0603f5b8E34A', - }) - expect(buildFindSelector({includeInactive: true, queryString: 'hello world'})).toEqual({ + }); + expect(buildFindSelector({ includeInactive: true, queryString: 'hello world' })).toEqual({ deleted: null, - '$text': { '$search': 'hello world' } - }) - expect(buildFindSelector({ queryString: 'hello world'})).toEqual({ + $text: { $search: 'hello world' }, + }); + expect(buildFindSelector({ queryString: 'hello world' })).toEqual({ deleted: null, isActive: true, - '$text': { '$search': 'hello world' } - }) + $text: { $search: 'hello world' }, + }); }); - }); diff --git a/packages/core-delivery/src/module/buildFindSelector.test.ts b/packages/core-delivery/src/module/buildFindSelector.test.ts index 08cc335fbc..cf4ac32b01 100644 --- a/packages/core-delivery/src/module/buildFindSelector.test.ts +++ b/packages/core-delivery/src/module/buildFindSelector.test.ts @@ -1,15 +1,17 @@ -import { DeliveryProviderType } from "../delivery-index.js"; -import { buildFindSelector } from "./configureDeliveryModule.js"; +import { DeliveryProviderType } from '../delivery-index.js'; +import { buildFindSelector } from './configureDeliveryModule.js'; describe('Delivery', () => { describe('buildFindSelector', () => { - it('Return correct filter object when passed no argument', async () => { - expect(buildFindSelector({})).toEqual({ deleted: null }) + it('Return correct filter object when passed no argument', () => { + expect(buildFindSelector({})).toEqual({ deleted: null }); }); - it('Return correct filter object when passed no argument', async () => { - expect(buildFindSelector({type: DeliveryProviderType.PICKUP})).toEqual({ type: 'PICKUP', deleted: null }) + it('Return correct filter object when passed no argument', () => { + expect(buildFindSelector({ type: DeliveryProviderType.PICKUP })).toEqual({ + type: 'PICKUP', + deleted: null, + }); }); - }) - + }); }); diff --git a/packages/core-enrollments/src/module/periodForReferenceDate.test.ts b/packages/core-enrollments/src/module/periodForReferenceDate.test.ts index 891f20719c..555cdd4ec7 100644 --- a/packages/core-enrollments/src/module/periodForReferenceDate.test.ts +++ b/packages/core-enrollments/src/module/periodForReferenceDate.test.ts @@ -1,15 +1,23 @@ -import { periodForReferenceDate } from "../director/EnrollmentAdapter.js"; +import { periodForReferenceDate } from '../director/EnrollmentAdapter.js'; - - describe('periodForReferenceDate', () => { - it('Should return 1 week interval from When passed a given date', async () => { - expect(periodForReferenceDate(new Date('2022-12-03T17:00:00.000Z'))).toEqual({ start: new Date( '2022-12-03T17:00:00.000Z'), end: new Date('2022-12-10T17:00:00.000Z') }) +describe('periodForReferenceDate', () => { + it('Should return 1 week interval from When passed a given date', () => { + expect(periodForReferenceDate(new Date('2022-12-03T17:00:00.000Z'))).toEqual({ + start: new Date('2022-12-03T17:00:00.000Z'), + end: new Date('2022-12-10T17:00:00.000Z'), }); - it('Should return 2 week interval from When passed 2 as interval', async () => { - expect(periodForReferenceDate(new Date('2022-12-03T17:00:00.000Z'), 2)).toEqual({ start: new Date( '2022-12-03T17:00:00.000Z'), end: new Date('2022-12-17T17:00:00.000Z') }) + }); + it('Should return 2 week interval from When passed 2 as interval', () => { + expect(periodForReferenceDate(new Date('2022-12-03T17:00:00.000Z'), 2)).toEqual({ + start: new Date('2022-12-03T17:00:00.000Z'), + end: new Date('2022-12-17T17:00:00.000Z'), }); + }); - it('Should return 2 HOURS when interval is set to HOURS', async () => { - expect(periodForReferenceDate(new Date('2022-12-03T17:00:00.000Z'), 2, 'HOURS')).toEqual({ start: new Date( '2022-12-03T17:00:00.000Z'), end: new Date('2022-12-03T19:00:00.000Z') }) - }); + it('Should return 2 HOURS when interval is set to HOURS', () => { + expect(periodForReferenceDate(new Date('2022-12-03T17:00:00.000Z'), 2, 'HOURS')).toEqual({ + start: new Date('2022-12-03T17:00:00.000Z'), + end: new Date('2022-12-03T19:00:00.000Z'), + }); }); +}); diff --git a/packages/core-files/tests/files-index.test.ts b/packages/core-files/tests/files-index.test.ts index 2b6e01f81f..512e7873f4 100644 --- a/packages/core-files/tests/files-index.test.ts +++ b/packages/core-files/tests/files-index.test.ts @@ -1,5 +1,5 @@ describe('Files', () => { - it('Init', async () => { - expect(true).toBeTruthy() + it('Init', () => { + expect(true).toBeTruthy(); }); }); diff --git a/packages/core-filters/src/filter-value-parsers/switch.test.ts b/packages/core-filters/src/filter-value-parsers/switch.test.ts index 68733d2444..a35d3176ef 100644 --- a/packages/core-filters/src/filter-value-parsers/switch.test.ts +++ b/packages/core-filters/src/filter-value-parsers/switch.test.ts @@ -1,4 +1,4 @@ -import _switch from "./switch.js"; +import _switch from './switch.js'; describe('switch', () => { it('returns undefined if no value is provided', () => { @@ -19,4 +19,3 @@ describe('switch', () => { expect(result).toEqual(['false']); }); }); - diff --git a/packages/core-filters/src/module/buildFindSelector.test.ts b/packages/core-filters/src/module/buildFindSelector.test.ts index 2a275bfa7b..5552cc6eef 100644 --- a/packages/core-filters/src/module/buildFindSelector.test.ts +++ b/packages/core-filters/src/module/buildFindSelector.test.ts @@ -1,35 +1,35 @@ -import { buildFindSelector } from "./configureFiltersModule.js"; +import { buildFindSelector } from './configureFiltersModule.js'; - describe('buildFindSelector', () => { - it('Return correct filter object when passed no argument', async () => { - expect(buildFindSelector({})).toEqual({ isActive: true }) - }); +describe('buildFindSelector', () => { + it('Return correct filter object when passed no argument', () => { + expect(buildFindSelector({})).toEqual({ isActive: true }); + }); - it('Return correct filter object when inactive is set to true', async () => { - expect(buildFindSelector({includeInactive: true})).toEqual({ }) - }); + it('Return correct filter object when inactive is set to true', () => { + expect(buildFindSelector({ includeInactive: true })).toEqual({}); + }); - it('Return correct filter object when passed filterIds and queryString', async () => { - expect(buildFindSelector({filterIds: ['filter-1', 'filter-2'], queryString: "Hello world"})).toEqual({ - isActive: true, - _id: { '$in': [ 'filter-1', 'filter-2' ] }, - '$text': { '$search': 'Hello world' } - }) + it('Return correct filter object when passed filterIds and queryString', () => { + expect( + buildFindSelector({ filterIds: ['filter-1', 'filter-2'], queryString: 'Hello world' }), + ).toEqual({ + isActive: true, + _id: { $in: ['filter-1', 'filter-2'] }, + $text: { $search: 'Hello world' }, }); + }); - it('Return correct filter object when passed filterIds', async () => { - expect(buildFindSelector({filterIds: ['filter-1', 'filter-2']})).toEqual({ - isActive: true, - _id: { '$in': [ 'filter-1', 'filter-2' ] }, - - }) + it('Return correct filter object when passed filterIds', () => { + expect(buildFindSelector({ filterIds: ['filter-1', 'filter-2'] })).toEqual({ + isActive: true, + _id: { $in: ['filter-1', 'filter-2'] }, }); + }); - it('Return correct filter object when passed queryString', async () => { - expect(buildFindSelector({ queryString: "Hello world"})).toEqual({ - isActive: true, - '$text': { '$search': 'Hello world' } - }) + it('Return correct filter object when passed queryString', () => { + expect(buildFindSelector({ queryString: 'Hello world' })).toEqual({ + isActive: true, + $text: { $search: 'Hello world' }, }); - - }) + }); +}); diff --git a/packages/core-languages/src/module/languages-index.test.ts b/packages/core-languages/src/module/languages-index.test.ts index bc25829fb3..2072e1f868 100644 --- a/packages/core-languages/src/module/languages-index.test.ts +++ b/packages/core-languages/src/module/languages-index.test.ts @@ -1,20 +1,26 @@ -import { buildFindSelector } from "./configureLanguagesModule.js"; +import { buildFindSelector } from './configureLanguagesModule.js'; - describe('buildFindSelector', () => { - it('Return correct filter object when passed no argument', async () => { - expect(buildFindSelector({})).toEqual({ deleted: null, isActive: true }) - }); +describe('buildFindSelector', () => { + it('Return correct filter object when passed no argument', () => { + expect(buildFindSelector({})).toEqual({ deleted: null, isActive: true }); + }); - it('Return correct filter object includeInactive is set to true', async () => { - expect(buildFindSelector({includeInactive: true})).toEqual({ deleted: null }) - }); + it('Return correct filter object includeInactive is set to true', () => { + expect(buildFindSelector({ includeInactive: true })).toEqual({ deleted: null }); + }); - it('Return correct filter object when passed includeInactive, queryString', async () => { - expect(buildFindSelector({ includeInactive: true,queryString: "hello world"})).toEqual({ deleted: null, '$text': { '$search': 'hello world' } }) + it('Return correct filter object when passed includeInactive, queryString', () => { + expect(buildFindSelector({ includeInactive: true, queryString: 'hello world' })).toEqual({ + deleted: null, + $text: { $search: 'hello world' }, }); + }); - it('Return correct filter object when passed queryString', async () => { - expect(buildFindSelector({ queryString: "hello world"})).toEqual({ deleted: null, isActive: true, '$text': { '$search': 'hello world' } }) + it('Return correct filter object when passed queryString', () => { + expect(buildFindSelector({ queryString: 'hello world' })).toEqual({ + deleted: null, + isActive: true, + $text: { $search: 'hello world' }, }); - - }) + }); +}); diff --git a/packages/core-languages/tests/languages-index.test.ts b/packages/core-languages/tests/languages-index.test.ts index f2d4ce2e32..a71c8e5c82 100644 --- a/packages/core-languages/tests/languages-index.test.ts +++ b/packages/core-languages/tests/languages-index.test.ts @@ -1,23 +1,28 @@ -import { buildFindSelector } from "../src/module/configureLanguagesModule.js"; +import { buildFindSelector } from '../src/module/configureLanguagesModule.js'; describe('Languages', () => { describe('buildFindSelector', () => { - it('Return correct filter object when passed no argument', async () => { - expect(buildFindSelector({})).toEqual({ deleted: null, isActive: true }) + it('Return correct filter object when passed no argument', () => { + expect(buildFindSelector({})).toEqual({ deleted: null, isActive: true }); }); - it('Return correct filter object includeInactive is set to true', async () => { - expect(buildFindSelector({includeInactive: true})).toEqual({ deleted: null }) + it('Return correct filter object includeInactive is set to true', () => { + expect(buildFindSelector({ includeInactive: true })).toEqual({ deleted: null }); }); - it('Return correct filter object when passed includeInactive, queryString', async () => { - expect(buildFindSelector({ includeInactive: true,queryString: "hello world"})).toEqual({ deleted: null, '$text': { '$search': 'hello world' } }) + it('Return correct filter object when passed includeInactive, queryString', () => { + expect(buildFindSelector({ includeInactive: true, queryString: 'hello world' })).toEqual({ + deleted: null, + $text: { $search: 'hello world' }, + }); }); - it('Return correct filter object when passed queryString', async () => { - expect(buildFindSelector({ queryString: "hello world"})).toEqual({ deleted: null, isActive: true, '$text': { '$search': 'hello world' } }) + it('Return correct filter object when passed queryString', () => { + expect(buildFindSelector({ queryString: 'hello world' })).toEqual({ + deleted: null, + isActive: true, + $text: { $search: 'hello world' }, + }); }); - - }) - + }); }); diff --git a/packages/core-messaging/src/director/MessagingDirector.test.ts b/packages/core-messaging/src/director/MessagingDirector.test.ts index 0f04035565..f0db2c659d 100644 --- a/packages/core-messaging/src/director/MessagingDirector.test.ts +++ b/packages/core-messaging/src/director/MessagingDirector.test.ts @@ -1,5 +1,5 @@ describe('MessagingDirector', () => { it('Stub', () => { - expect(true).toBe(true) - }); -}); \ No newline at end of file + expect(true).toBe(true); + }); +}); diff --git a/packages/core-orders/src/module/buildFindSelector.test.ts b/packages/core-orders/src/module/buildFindSelector.test.ts index 322d3bdf58..ae09e408f4 100644 --- a/packages/core-orders/src/module/buildFindSelector.test.ts +++ b/packages/core-orders/src/module/buildFindSelector.test.ts @@ -1,110 +1,110 @@ -import { OrderStatus } from "../types.js" -import {buildFindByIdSelector as buildFindByIdSelectorForDelivery} from "./configureOrderDeliveriesModule.js" -import {buildFindByIdSelector as buildFindByIdSelectorForDiscount } from "./configureOrderDiscountsModule.js" -import {buildFindByIdSelector as buildFindByIdSelectorForPayment, buildFindByContextDataSelector } from "./configureOrderPaymentsModule.js" -import {buildFindByIdSelector as buildFindByIdSelectorForPosition } from "./configureOrderPositionsModule.js" -import {buildFindSelector as buildFindSelectorForOrder} from "./configureOrdersModule-queries.js" - +import { OrderStatus } from '../types.js'; +import { buildFindByIdSelector as buildFindByIdSelectorForDelivery } from './configureOrderDeliveriesModule.js'; +import { buildFindByIdSelector as buildFindByIdSelectorForDiscount } from './configureOrderDiscountsModule.js'; +import { + buildFindByIdSelector as buildFindByIdSelectorForPayment, + buildFindByContextDataSelector, +} from './configureOrderPaymentsModule.js'; +import { buildFindByIdSelector as buildFindByIdSelectorForPosition } from './configureOrderPositionsModule.js'; +import { buildFindSelector as buildFindSelectorForOrder } from './configureOrdersModule-queries.js'; describe('OrderPosition', () => { - describe('buildFindSelector', () => { - it('Return filter object when passed no argument', async () => { - expect(buildFindSelectorForOrder({})).toEqual({ status: { '$ne': null } }) - + describe('buildFindSelector', () => { + it('Return filter object when passed no argument', () => { + expect(buildFindSelectorForOrder({})).toEqual({ status: { $ne: null } }); }); - it('Return filter object when passed no argument includeCarts, queryString, status, userId and (status should take precedence over includeCarts', async () => { - expect(buildFindSelectorForOrder({includeCarts: false, queryString: "hello world", status: [OrderStatus.CONFIRMED], userId: "admin-id"})).toEqual({ + it('Return filter object when passed no argument includeCarts, queryString, status, userId and (status should take precedence over includeCarts', () => { + expect( + buildFindSelectorForOrder({ + includeCarts: false, + queryString: 'hello world', + status: [OrderStatus.CONFIRMED], + userId: 'admin-id', + }), + ).toEqual({ userId: 'admin-id', - "status": { - "$in": [ - "CONFIRMED", - ], - }, - '$text': { '$search': 'hello world' } - } - ) - + status: { + $in: ['CONFIRMED'], + }, + $text: { $search: 'hello world' }, + }); }); - it('Return filter object when passed no argument includeCarts, queryString, userId ', async () => { - expect(buildFindSelectorForOrder({includeCarts: true, queryString: "hello world", userId: "admin-id"})).toEqual( { + it('Return filter object when passed no argument includeCarts, queryString, userId ', () => { + expect( + buildFindSelectorForOrder({ + includeCarts: true, + queryString: 'hello world', + userId: 'admin-id', + }), + ).toEqual({ userId: 'admin-id', - - '$text': { '$search': 'hello world' } - } - ) - + + $text: { $search: 'hello world' }, + }); }); - it('Return filter object when passed no argument queryString, userId ', async () => { - expect(buildFindSelectorForOrder({ queryString: "hello world", userId: "admin-id"})).toEqual( { + it('Return filter object when passed no argument queryString, userId ', () => { + expect(buildFindSelectorForOrder({ queryString: 'hello world', userId: 'admin-id' })).toEqual({ userId: 'admin-id', - '$text': { '$search': 'hello world' }, - status: { '$ne': null }, - } - ) - + $text: { $search: 'hello world' }, + status: { $ne: null }, + }); }); - it('Return filter object when passed no argument queryString ', async () => { - expect(buildFindSelectorForOrder({ queryString: "hello world"})).toEqual( { - '$text': { '$search': 'hello world' }, - status: { '$ne': null }, - }) - + it('Return filter object when passed no argument queryString ', () => { + expect(buildFindSelectorForOrder({ queryString: 'hello world' })).toEqual({ + $text: { $search: 'hello world' }, + status: { $ne: null }, + }); }); - - }) - + }); }); describe('OrderDelivery', () => { - - describe('buildFindByIdSelector', () => { - it('Return correct db _id selector', async () => { - - expect(buildFindByIdSelectorForDelivery('order-delivery-id')).toEqual({ _id: 'order-delivery-id' }) + describe('buildFindByIdSelector', () => { + it('Return correct db _id selector', () => { + expect(buildFindByIdSelectorForDelivery('order-delivery-id')).toEqual({ + _id: 'order-delivery-id', + }); }); - }) - + }); }); - describe('OrderDiscount', () => { - - describe('buildFindByIdSelector', () => { - it('Return correct db _id selector', async () => { - - expect(buildFindByIdSelectorForDiscount('order-discount-id')).toEqual({ _id: 'order-discount-id' }) + describe('buildFindByIdSelector', () => { + it('Return correct db _id selector', () => { + expect(buildFindByIdSelectorForDiscount('order-discount-id')).toEqual({ + _id: 'order-discount-id', + }); }); - }) - + }); }); describe('OrderPayment', () => { - - describe('buildFindByIdSelector', () => { - it('Return correct db _id selector', async () => { - - expect(buildFindByIdSelectorForPayment('order-payment-id')).toEqual({ _id: 'order-payment-id' }) + describe('buildFindByIdSelector', () => { + it('Return correct db _id selector', () => { + expect(buildFindByIdSelectorForPayment('order-payment-id')).toEqual({ _id: 'order-payment-id' }); }); - }) + }); - describe('buildFindByContextDataSelector', () => { - it('Return correct db context field selector object', async () => { - expect(buildFindByContextDataSelector({'first': 'first value', 'second': 'second value'})).toEqual({ 'context.first': 'first value', 'context.second': 'second value' }) + describe('buildFindByContextDataSelector', () => { + it('Return correct db context field selector object', () => { + expect(buildFindByContextDataSelector({ first: 'first value', second: 'second value' })).toEqual({ + 'context.first': 'first value', + 'context.second': 'second value', }); - }) - + }); + }); }); - describe('OrderPosition', () => { - describe('buildFindByIdSelector', () => { - it('Return correct db _id selector', async () => { - expect(buildFindByIdSelectorForPosition('order-position-id')).toEqual({ _id: 'order-position-id' }) + describe('buildFindByIdSelector', () => { + it('Return correct db _id selector', () => { + expect(buildFindByIdSelectorForPosition('order-position-id')).toEqual({ + _id: 'order-position-id', + }); }); - }) - + }); }); diff --git a/packages/core-payment/src/module/payment-index.test.ts b/packages/core-payment/src/module/payment-index.test.ts index f8832d7bfc..8c9afc8e07 100644 --- a/packages/core-payment/src/module/payment-index.test.ts +++ b/packages/core-payment/src/module/payment-index.test.ts @@ -1,17 +1,17 @@ -import { PaymentProviderType } from "../payment-index.js"; -import { buildFindSelector } from "./configurePaymentProvidersModule.js"; - - +import { PaymentProviderType } from '../payment-index.js'; +import { buildFindSelector } from './configurePaymentProvidersModule.js'; describe('Payment', () => { describe('buildFindSelector', () => { - it('Return correct filter object when passed no argument', async () => { - expect(buildFindSelector({})).toEqual({ deleted: null }) + it('Return correct filter object when passed no argument', () => { + expect(buildFindSelector({})).toEqual({ deleted: null }); }); - it('Return correct filter object when passed no argument', async () => { - expect(buildFindSelector({type: PaymentProviderType.GENERIC})).toEqual({ type: "GENERIC", deleted: null }) + it('Return correct filter object when passed no argument', () => { + expect(buildFindSelector({ type: PaymentProviderType.GENERIC })).toEqual({ + type: 'GENERIC', + deleted: null, + }); }); - }) - + }); }); diff --git a/packages/core-products/src/module/buildFindSelector.test.ts b/packages/core-products/src/module/buildFindSelector.test.ts index e441f1f142..e103d3960c 100644 --- a/packages/core-products/src/module/buildFindSelector.test.ts +++ b/packages/core-products/src/module/buildFindSelector.test.ts @@ -1,68 +1,98 @@ -import { buildFindSelector } from "./configureProductsModule"; +import { buildFindSelector } from './configureProductsModule'; describe('Product', () => { - describe("buildFindSelector", () => { - it('Return correct filter object object when no parameter is passed', async () => { - expect(buildFindSelector({}as any)).toEqual( { status: { '$eq': 'ACTIVE' } }) - }) - it('Return correct filter object object when passed includeDraft:true, productsIds, productSelector, queryString, slugs, tags ', async () => { - expect(buildFindSelector({ includeDrafts: true, productIds: ['product-1-id', 'product-id-2'], productSelector: {type: "SIMPLE_PRODUCT"}, queryString: "hello world", slugs: ['slug-1', 'slug-2'], tags: ['tag-1', 'tag-2'] } as any)).toEqual( { + describe('buildFindSelector', () => { + it('Return correct filter object object when no parameter is passed', () => { + expect(buildFindSelector({} as any)).toEqual({ status: { $eq: 'ACTIVE' } }); + }); + it('Return correct filter object object when passed includeDraft:true, productsIds, productSelector, queryString, slugs, tags ', () => { + expect( + buildFindSelector({ + includeDrafts: true, + productIds: ['product-1-id', 'product-id-2'], + productSelector: { type: 'SIMPLE_PRODUCT' }, + queryString: 'hello world', + slugs: ['slug-1', 'slug-2'], + tags: ['tag-1', 'tag-2'], + } as any), + ).toEqual({ type: 'SIMPLE_PRODUCT', - _id: { '$in': [ 'product-1-id', 'product-id-2' ] }, - slugs: { '$in': [ 'slug-1', 'slug-2' ] }, - tags: { '$all': [ 'tag-1', 'tag-2' ] }, - '$text': { '$search': 'hello world' }, - status: { '$in': [ 'ACTIVE', null ] } - } -) - }); + _id: { $in: ['product-1-id', 'product-id-2'] }, + slugs: { $in: ['slug-1', 'slug-2'] }, + tags: { $all: ['tag-1', 'tag-2'] }, + $text: { $search: 'hello world' }, + status: { $in: ['ACTIVE', null] }, + }); + }); - it('Return correct filter object object when passed includeDraft:true, productsIds, productSelector, queryString, slugs ', async () => { - expect(buildFindSelector({includeDrafts: true, productIds: ['product-1-id', 'product-id-2'], productSelector: {type: "SIMPLE_PRODUCT"}, queryString: "hello world", slugs: ['slug-1', 'slug-2']}as any)).toEqual( { + it('Return correct filter object object when passed includeDraft:true, productsIds, productSelector, queryString, slugs ', () => { + expect( + buildFindSelector({ + includeDrafts: true, + productIds: ['product-1-id', 'product-id-2'], + productSelector: { type: 'SIMPLE_PRODUCT' }, + queryString: 'hello world', + slugs: ['slug-1', 'slug-2'], + } as any), + ).toEqual({ type: 'SIMPLE_PRODUCT', - _id: { '$in': [ 'product-1-id', 'product-id-2' ] }, - slugs: { '$in': [ 'slug-1', 'slug-2' ] }, - '$text': { '$search': 'hello world' }, - status: { '$in': [ 'ACTIVE', null ] }, - - }) + _id: { $in: ['product-1-id', 'product-id-2'] }, + slugs: { $in: ['slug-1', 'slug-2'] }, + $text: { $search: 'hello world' }, + status: { $in: ['ACTIVE', null] }, + }); }); - it('Return correct filter object object when passed includeDraft:true, productsIds, productSelector, queryString ', async () => { - expect(buildFindSelector({includeDrafts: true, productIds: ['product-1-id', 'product-id-2'], productSelector: {type: "SIMPLE_PRODUCT"}, queryString: "hello world"}as any)).toEqual( { + it('Return correct filter object object when passed includeDraft:true, productsIds, productSelector, queryString ', () => { + expect( + buildFindSelector({ + includeDrafts: true, + productIds: ['product-1-id', 'product-id-2'], + productSelector: { type: 'SIMPLE_PRODUCT' }, + queryString: 'hello world', + } as any), + ).toEqual({ type: 'SIMPLE_PRODUCT', - _id: { '$in': [ 'product-1-id', 'product-id-2' ] }, - '$text': { '$search': 'hello world' }, - status: { '$in': [ 'ACTIVE', null ] }, - - }) + _id: { $in: ['product-1-id', 'product-id-2'] }, + $text: { $search: 'hello world' }, + status: { $in: ['ACTIVE', null] }, + }); }); - it('Return correct filter object object when passed includeDraft:true, productsIds, productSelector ', async () => { - expect(buildFindSelector({includeDrafts: true, productIds: ['product-1-id', 'product-id-2'], productSelector: {type: "SIMPLE_PRODUCT"}}as any)).toEqual( { + it('Return correct filter object object when passed includeDraft:true, productsIds, productSelector ', () => { + expect( + buildFindSelector({ + includeDrafts: true, + productIds: ['product-1-id', 'product-id-2'], + productSelector: { type: 'SIMPLE_PRODUCT' }, + } as any), + ).toEqual({ type: 'SIMPLE_PRODUCT', - _id: { '$in': [ 'product-1-id', 'product-id-2' ] }, - status: { '$in': [ 'ACTIVE', null ] }, - - }) + _id: { $in: ['product-1-id', 'product-id-2'] }, + status: { $in: ['ACTIVE', null] }, + }); }); - it('Return correct filter object object when passed includeDraft:true, productsIds ', async () => { - expect(buildFindSelector({includeDrafts: true, productIds: ['product-1-id', 'product-id-2']}as any)).toEqual( { - _id: { '$in': [ 'product-1-id', 'product-id-2' ] }, - status: { '$in': [ 'ACTIVE', null ] }, - - }) + it('Return correct filter object object when passed includeDraft:true, productsIds ', () => { + expect( + buildFindSelector({ includeDrafts: true, productIds: ['product-1-id', 'product-id-2'] } as any), + ).toEqual({ + _id: { $in: ['product-1-id', 'product-id-2'] }, + status: { $in: ['ACTIVE', null] }, + }); }); - it('Return filter tags if passed as a string ', async () => { - expect(buildFindSelector({tags: "string-tag"}as any)).toEqual({ tags: 'string-tag', status: { '$eq': 'ACTIVE' } }) + it('Return filter tags if passed as a string ', () => { + expect(buildFindSelector({ tags: 'string-tag' } as any)).toEqual({ + tags: 'string-tag', + status: { $eq: 'ACTIVE' }, + }); }); - it('includeDrafts true should add null to status filter array as null ', async () => { - expect(buildFindSelector({includeDrafts: true}as any)).toEqual({status: { '$in': [ 'ACTIVE', null ] }} ) + it('includeDrafts true should add null to status filter array as null ', () => { + expect(buildFindSelector({ includeDrafts: true } as any)).toEqual({ + status: { $in: ['ACTIVE', null] }, + }); }); - }); }); - diff --git a/packages/core-products/tests/product-index.test.ts b/packages/core-products/tests/product-index.test.ts index 0b9466fbb9..aa5a581b82 100644 --- a/packages/core-products/tests/product-index.test.ts +++ b/packages/core-products/tests/product-index.test.ts @@ -1,7 +1,5 @@ describe('Product', () => { - - it('Product', async () => { - expect(true).toBeTruthy() + it('Product', () => { + expect(true).toBeTruthy(); }); - }); diff --git a/packages/core-quotations/src/module/quotations-index.test.ts b/packages/core-quotations/src/module/quotations-index.test.ts index 1c6d310250..53cc0052e2 100644 --- a/packages/core-quotations/src/module/quotations-index.test.ts +++ b/packages/core-quotations/src/module/quotations-index.test.ts @@ -1,21 +1,25 @@ -import { buildFindSelector } from "./configureQuotationsModule.js"; +import { buildFindSelector } from './configureQuotationsModule.js'; describe('Quotation', () => { - describe("buildFindSelector", () => { - it('Return correct filter object when passed no argument', async () => { - expect(buildFindSelector({})).toEqual({}) + describe('buildFindSelector', () => { + it('Return correct filter object when passed no argument', () => { + expect(buildFindSelector({})).toEqual({}); }); - it('Return correct filter object when passed queryString and userId', async () => { - expect(buildFindSelector({queryString: "hello world", userId: "admin-id"})).toEqual({ userId: 'admin-id', '$text': { '$search': 'hello world' } }) + it('Return correct filter object when passed queryString and userId', () => { + expect(buildFindSelector({ queryString: 'hello world', userId: 'admin-id' })).toEqual({ + userId: 'admin-id', + $text: { $search: 'hello world' }, + }); }); - it('Return correct filter object when passed userId', async () => { - expect(buildFindSelector({ userId: "admin-id"})).toEqual({ userId: 'admin-id' }) + it('Return correct filter object when passed userId', () => { + expect(buildFindSelector({ userId: 'admin-id' })).toEqual({ userId: 'admin-id' }); }); - it('Return correct filter object when passed queryString', async () => { - expect(buildFindSelector({queryString: "hello world"})).toEqual({ '$text': { '$search': 'hello world' } }) + it('Return correct filter object when passed queryString', () => { + expect(buildFindSelector({ queryString: 'hello world' })).toEqual({ + $text: { $search: 'hello world' }, + }); }); - }) - + }); }); diff --git a/packages/core-users/src/module/buildFindSelector.test.ts b/packages/core-users/src/module/buildFindSelector.test.ts index 21385fd719..7768a40bc4 100644 --- a/packages/core-users/src/module/buildFindSelector.test.ts +++ b/packages/core-users/src/module/buildFindSelector.test.ts @@ -1,23 +1,28 @@ -import { buildFindSelector } from "./configureUsersModule.js"; +import { buildFindSelector } from './configureUsersModule.js'; - - - describe('buildFindSelector', () => { - it('Return the correct filter when no parameter is passed', async () => { - expect(buildFindSelector({})).toEqual({ "deleted": null, guest: { '$in': [false, null] }, - }) - }); - it('Return the correct filter when no parameter is passed queryString and includeGuest: true', async () => { - expect(buildFindSelector({queryString: "Hello world", includeGuests: true})).toEqual({ "deleted": null,'$text': { '$search': 'Hello world' } }) +describe('buildFindSelector', () => { + it('Return the correct filter when no parameter is passed', () => { + expect(buildFindSelector({})).toEqual({ deleted: null, guest: { $in: [false, null] } }); + }); + it('Return the correct filter when no parameter is passed queryString and includeGuest: true', () => { + expect(buildFindSelector({ queryString: 'Hello world', includeGuests: true })).toEqual({ + deleted: null, + $text: { $search: 'Hello world' }, }); + }); - it('Should include additional user field selector in addition too queryString and includeGuests', async () => { - expect(buildFindSelector({queryString: "Hello world", includeGuests: false, "profile.displayName": "mikael"})).toEqual({ + it('Should include additional user field selector in addition too queryString and includeGuests', () => { + expect( + buildFindSelector({ + queryString: 'Hello world', + includeGuests: false, 'profile.displayName': 'mikael', - "deleted": null, - guest: { '$in': [false, null] }, - '$text': { '$search': 'Hello world' } - }) + }), + ).toEqual({ + 'profile.displayName': 'mikael', + deleted: null, + guest: { $in: [false, null] }, + $text: { $search: 'Hello world' }, }); - }) - \ No newline at end of file + }); +}); diff --git a/packages/core-users/src/module/removeConfidentialServiceHashes.test.ts b/packages/core-users/src/module/removeConfidentialServiceHashes.test.ts index 94f4565f08..e96a5d5e23 100644 --- a/packages/core-users/src/module/removeConfidentialServiceHashes.test.ts +++ b/packages/core-users/src/module/removeConfidentialServiceHashes.test.ts @@ -3,7 +3,7 @@ import { removeConfidentialServiceHashes } from './configureUsersModule.js'; import user from '../../tests/mock/user-mock.js'; describe('removeConfidentialServiceHashes', () => { - it('Should remove sensitive user credentials ', async () => { + it('Should remove sensitive user credentials ', () => { expect(user.services).not.toBeUndefined(); removeConfidentialServiceHashes(user as unknown as User); expect(user.services).toBeUndefined(); diff --git a/packages/core-warehousing/src/module/buildFindSelector.test.ts b/packages/core-warehousing/src/module/buildFindSelector.test.ts index 57a5ec7292..0fecc0588d 100644 --- a/packages/core-warehousing/src/module/buildFindSelector.test.ts +++ b/packages/core-warehousing/src/module/buildFindSelector.test.ts @@ -1,15 +1,17 @@ -import { WarehousingProviderType } from "../warehousing-index.js"; -import { buildFindSelector } from "./configureWarehousingModule.js"; +import { WarehousingProviderType } from '../warehousing-index.js'; +import { buildFindSelector } from './configureWarehousingModule.js'; describe('Warehousing', () => { describe('buildFindSelector', () => { - it('Return correct filter object when passed no argument', async () => { - expect(buildFindSelector({})).toEqual({ deleted: null }) + it('Return correct filter object when passed no argument', () => { + expect(buildFindSelector({})).toEqual({ deleted: null }); }); - it('Return correct filter object when passed no argument', async () => { - expect(buildFindSelector({type: WarehousingProviderType.PHYSICAL})).toEqual({ type: "PHYSICAL", deleted: null }) + it('Return correct filter object when passed no argument', () => { + expect(buildFindSelector({ type: WarehousingProviderType.PHYSICAL })).toEqual({ + type: 'PHYSICAL', + deleted: null, + }); }); - }) - + }); }); diff --git a/packages/core-worker/src/module/buildQuerySelector.test.ts b/packages/core-worker/src/module/buildQuerySelector.test.ts index b480c64e49..f348611435 100644 --- a/packages/core-worker/src/module/buildQuerySelector.test.ts +++ b/packages/core-worker/src/module/buildQuerySelector.test.ts @@ -1,189 +1,209 @@ -import { WorkStatus } from "../worker-index.js"; -import { buildQuerySelector } from "./configureWorkerModule.js"; - +import { WorkStatus } from '../worker-index.js'; +import { buildQuerySelector } from './configureWorkerModule.js'; describe('Worker', () => { - - describe("buildQuerySelector", () => { - it('Return correct filter object when passed no argument', async () => { - expect(buildQuerySelector({})).toEqual({ deleted: { '$exists': false } }) + describe('buildQuerySelector', () => { + it('Return correct filter object when passed no argument', () => { + expect(buildQuerySelector({})).toEqual({ deleted: { $exists: false } }); }); - it('Return correct filter object when passed create, queryString, scheduled, status, types & workId', async () => { - const selector = buildQuerySelector({created: {start: new Date("2022-12-04T17:13:09.285Z"), end: new Date("2022-12-04T17:13:09.285Z") }, queryString: "hello world", scheduled: {end: new Date("2022-12-04T17:13:09.285Z"), start: new Date("2022-12-04T17:13:09.285Z")}, status: [WorkStatus.ALLOCATED], types: ['EMAIL'], workId: 'work-id'}) + it('Return correct filter object when passed create, queryString, scheduled, status, types & workId', () => { + const selector = buildQuerySelector({ + created: { + start: new Date('2022-12-04T17:13:09.285Z'), + end: new Date('2022-12-04T17:13:09.285Z'), + }, + queryString: 'hello world', + scheduled: { + end: new Date('2022-12-04T17:13:09.285Z'), + start: new Date('2022-12-04T17:13:09.285Z'), + }, + status: [WorkStatus.ALLOCATED], + types: ['EMAIL'], + workId: 'work-id', + }); expect(selector).toEqual({ _id: 'work-id', - '$or': [ + $or: [ { - started: { '$exists': true }, - finished: { '$exists': false }, - deleted: { '$exists': false } - } + started: { $exists: true }, + finished: { $exists: false }, + deleted: { $exists: false }, + }, ], created: { - '$gte': new Date("2022-12-04T17:13:09.285Z"), - '$lte': new Date("2022-12-04T17:13:09.285Z") + $gte: new Date('2022-12-04T17:13:09.285Z'), + $lte: new Date('2022-12-04T17:13:09.285Z'), }, scheduled: { - '$gte': new Date("2022-12-04T17:13:09.285Z"), - '$lte': new Date("2022-12-04T17:13:09.285Z") + $gte: new Date('2022-12-04T17:13:09.285Z'), + $lte: new Date('2022-12-04T17:13:09.285Z'), }, - type: { '$in': [ 'EMAIL' ] }, - '$text': { '$search': 'hello world' } - } - ) - + type: { $in: ['EMAIL'] }, + $text: { $search: 'hello world' }, + }); }); - it('Return correct filter object when passed queryString, scheduled, status, types & workId', async () => { - const selector = buildQuerySelector({ queryString: "hello world", scheduled: {end: new Date("2022-12-04T17:13:09.285Z"), start: new Date("2022-12-04T17:13:09.285Z")}, status: [WorkStatus.ALLOCATED], types: ['EMAIL'], workId: 'work-id'}) + it('Return correct filter object when passed queryString, scheduled, status, types & workId', () => { + const selector = buildQuerySelector({ + queryString: 'hello world', + scheduled: { + end: new Date('2022-12-04T17:13:09.285Z'), + start: new Date('2022-12-04T17:13:09.285Z'), + }, + status: [WorkStatus.ALLOCATED], + types: ['EMAIL'], + workId: 'work-id', + }); expect(selector).toEqual({ _id: 'work-id', - '$or': [ + $or: [ { - started: { '$exists': true }, - finished: { '$exists': false }, - deleted: { '$exists': false } - } + started: { $exists: true }, + finished: { $exists: false }, + deleted: { $exists: false }, + }, ], scheduled: { - '$gte': new Date("2022-12-04T17:13:09.285Z"), - '$lte': new Date("2022-12-04T17:13:09.285Z") + $gte: new Date('2022-12-04T17:13:09.285Z'), + $lte: new Date('2022-12-04T17:13:09.285Z'), }, - type: { '$in': [ 'EMAIL' ] }, - '$text': { '$search': 'hello world' } - } - ) - + type: { $in: ['EMAIL'] }, + $text: { $search: 'hello world' }, + }); }); - it('Return correct filter object when passed scheduled, status, types & workId', async () => { - const selector = buildQuerySelector({ scheduled: {end: new Date("2022-12-04T17:13:09.285Z"), start: new Date("2022-12-04T17:13:09.285Z")}, status: [WorkStatus.ALLOCATED], types: ['EMAIL'], workId: 'work-id'}) + it('Return correct filter object when passed scheduled, status, types & workId', () => { + const selector = buildQuerySelector({ + scheduled: { + end: new Date('2022-12-04T17:13:09.285Z'), + start: new Date('2022-12-04T17:13:09.285Z'), + }, + status: [WorkStatus.ALLOCATED], + types: ['EMAIL'], + workId: 'work-id', + }); expect(selector).toEqual({ _id: 'work-id', - '$or': [ + $or: [ { - started: { '$exists': true }, - finished: { '$exists': false }, - deleted: { '$exists': false } - } + started: { $exists: true }, + finished: { $exists: false }, + deleted: { $exists: false }, + }, ], scheduled: { - '$gte': new Date("2022-12-04T17:13:09.285Z"), - '$lte': new Date("2022-12-04T17:13:09.285Z") + $gte: new Date('2022-12-04T17:13:09.285Z'), + $lte: new Date('2022-12-04T17:13:09.285Z'), }, - type: { '$in': [ 'EMAIL' ] }, - } - ) - + type: { $in: ['EMAIL'] }, + }); }); - it('Return correct filter object when passed status, types & workId', async () => { - const selector = buildQuerySelector({ status: [WorkStatus.ALLOCATED], types: ['EMAIL'], workId: 'work-id'}) + it('Return correct filter object when passed status, types & workId', () => { + const selector = buildQuerySelector({ + status: [WorkStatus.ALLOCATED], + types: ['EMAIL'], + workId: 'work-id', + }); expect(selector).toEqual({ _id: 'work-id', - '$or': [ + $or: [ { - started: { '$exists': true }, - finished: { '$exists': false }, - deleted: { '$exists': false } - } + started: { $exists: true }, + finished: { $exists: false }, + deleted: { $exists: false }, + }, ], - type: { '$in': [ 'EMAIL' ] }, - } - ) - + type: { $in: ['EMAIL'] }, + }); }); - it('Return correct filter object when passed types & workId', async () => { - const selector = buildQuerySelector({ types: ['EMAIL'], workId: 'work-id'}) + it('Return correct filter object when passed types & workId', () => { + const selector = buildQuerySelector({ types: ['EMAIL'], workId: 'work-id' }); expect(selector).toEqual({ _id: 'work-id', - deleted: { '$exists': false }, - type: { '$in': [ 'EMAIL' ] }, - } - ) - + deleted: { $exists: false }, + type: { $in: ['EMAIL'] }, + }); }); - it('Return correct filter object when passed workId', async () => { - const selector = buildQuerySelector({ workId: 'work-id'}) + it('Return correct filter object when passed workId', () => { + const selector = buildQuerySelector({ workId: 'work-id' }); expect(selector).toEqual({ _id: 'work-id', - deleted: { '$exists': false }, - } - ) + deleted: { $exists: false }, + }); }); - it('Create start should be set to start of unix timestamp if created.start not provided', async () => { - const selector = buildQuerySelector({ workId: 'work-id', created: {end: new Date("2022-12-04T17:13:09.285Z")}}) - + it('Create start should be set to start of unix timestamp if created.start not provided', () => { + const selector = buildQuerySelector({ + workId: 'work-id', + created: { end: new Date('2022-12-04T17:13:09.285Z') }, + }); + expect(selector).toEqual({ _id: 'work-id', - deleted: { '$exists': false }, + deleted: { $exists: false }, created: { - '$gte': new Date(0), - '$lte': new Date("2022-12-04T17:13:09.285Z") - } - } - ) + $gte: new Date(0), + $lte: new Date('2022-12-04T17:13:09.285Z'), + }, + }); }); - - it('Create start should be set to start or unix timestamp if created.end not provided', async () => { - const selector = buildQuerySelector({ workId: 'work-id', created: {start: new Date("2022-12-04T17:13:09.285Z")}}) + it('Create start should be set to start or unix timestamp if created.end not provided', () => { + const selector = buildQuerySelector({ + workId: 'work-id', + created: { start: new Date('2022-12-04T17:13:09.285Z') }, + }); expect(selector).toEqual({ _id: 'work-id', - deleted: { '$exists': false }, - created: { '$gte': new Date("2022-12-04T17:13:09.285Z")} - } - ) - - expect(buildQuerySelector({ workId: 'work-id', created: {}})).toEqual({ - _id: 'work-id', - deleted: { '$exists': false }, - created: { '$gte': new Date(0)} - } - ) + deleted: { $exists: false }, + created: { $gte: new Date('2022-12-04T17:13:09.285Z') }, + }); + + expect(buildQuerySelector({ workId: 'work-id', created: {} })).toEqual({ + _id: 'work-id', + deleted: { $exists: false }, + created: { $gte: new Date(0) }, + }); }); + it('scheduled start should be set to start of unix timestamp if scheduled.start not provided', () => { + const selector = buildQuerySelector({ + workId: 'work-id', + scheduled: { end: new Date('2022-12-04T17:13:09.285Z') }, + }); - it('scheduled start should be set to start of unix timestamp if scheduled.start not provided', async () => { - const selector = buildQuerySelector({ workId: 'work-id', scheduled: {end: new Date("2022-12-04T17:13:09.285Z")}}) - expect(selector).toEqual({ _id: 'work-id', - deleted: { '$exists': false }, + deleted: { $exists: false }, scheduled: { - '$gte': new Date(0), - '$lte': new Date("2022-12-04T17:13:09.285Z") - } - } - ) + $gte: new Date(0), + $lte: new Date('2022-12-04T17:13:09.285Z'), + }, + }); }); - - it('Scheduled start should be set to start or unix timestamp if scheduled.end not provided', async () => { - const selector = buildQuerySelector({ workId: 'work-id', scheduled: {start: new Date("2022-12-04T17:13:09.285Z")}}) + it('Scheduled start should be set to start or unix timestamp if scheduled.end not provided', () => { + const selector = buildQuerySelector({ + workId: 'work-id', + scheduled: { start: new Date('2022-12-04T17:13:09.285Z') }, + }); expect(selector).toEqual({ _id: 'work-id', - deleted: { '$exists': false }, - scheduled: { '$gte': new Date("2022-12-04T17:13:09.285Z")} - } - ) - - expect(buildQuerySelector({ workId: 'work-id', scheduled: {}})).toEqual({ - _id: 'work-id', - deleted: { '$exists': false }, - scheduled: { '$gte': new Date(0)} - } - ) - }); - + deleted: { $exists: false }, + scheduled: { $gte: new Date('2022-12-04T17:13:09.285Z') }, + }); - - }) - + expect(buildQuerySelector({ workId: 'work-id', scheduled: {} })).toEqual({ + _id: 'work-id', + deleted: { $exists: false }, + scheduled: { $gte: new Date(0) }, + }); + }); + }); }); diff --git a/packages/core/tests/core.test.ts b/packages/core/tests/core.test.ts index 9778d9fe8a..507f97a4cb 100644 --- a/packages/core/tests/core.test.ts +++ b/packages/core/tests/core.test.ts @@ -1,7 +1,5 @@ describe('Bookmark', () => { - - it('Check Bookmarks module', async () => { - expect(true).toBeTruthy() + it('Check Bookmarks module', () => { + expect(true).toBeTruthy(); }); - }); diff --git a/packages/events/tests/events-index.test.ts b/packages/events/tests/events-index.test.ts index 0d8225eaa1..7549622d3d 100644 --- a/packages/events/tests/events-index.test.ts +++ b/packages/events/tests/events-index.test.ts @@ -1,5 +1,5 @@ describe('Worker', () => { - it('Init', async () => { - expect(true).toBeTruthy() + it('Init', () => { + expect(true).toBeTruthy(); }); }); diff --git a/packages/file-upload/src/file-upload-index.test.ts b/packages/file-upload/src/file-upload-index.test.ts index a8361800c2..b130114964 100644 --- a/packages/file-upload/src/file-upload-index.test.ts +++ b/packages/file-upload/src/file-upload-index.test.ts @@ -1,8 +1,9 @@ -import buildHashedFilename from "./build-hashed-filename.js"; - +import buildHashedFilename from './build-hashed-filename.js'; describe('File Uploader', () => { - it('Generate unique file name', async () => { - expect(buildHashedFilename('root', 'file1.jpg', new Date(new Date("2022-12-04T17:13:09.285Z")))).toEqual("4hI2YuPDacR8ERoR7iM6cQ-file1.jpg") + it('Generate unique file name', () => { + expect( + buildHashedFilename('root', 'file1.jpg', new Date(new Date('2022-12-04T17:13:09.285Z'))), + ).toEqual('4hI2YuPDacR8ERoR7iM6cQ-file1.jpg'); }); }); diff --git a/packages/logger/tests/logger-index.test.ts b/packages/logger/tests/logger-index.test.ts index 5999cfc97d..8fd18d8c76 100644 --- a/packages/logger/tests/logger-index.test.ts +++ b/packages/logger/tests/logger-index.test.ts @@ -1,5 +1,5 @@ describe('Logger', () => { - it('Init', async () => { - expect(true).toBeTruthy() + it('Init', () => { + expect(true).toBeTruthy(); }); }); diff --git a/packages/mongodb/package.json b/packages/mongodb/package.json index 5c59897275..5c0c77f516 100644 --- a/packages/mongodb/package.json +++ b/packages/mongodb/package.json @@ -35,7 +35,7 @@ }, "peerDependencies": { "@mongodb-js/zstd": "^1.2.2", - "mongodb": "^6.9.0" + "mongodb": "^6.10.0" }, "optionalDependencies": { "mongodb-memory-server": "^10.0.0" diff --git a/packages/mongodb/src/mongodb-index.test.ts b/packages/mongodb/src/mongodb-index.test.ts index fbc3be4f68..6d9af8ba9b 100644 --- a/packages/mongodb/src/mongodb-index.test.ts +++ b/packages/mongodb/src/mongodb-index.test.ts @@ -1,41 +1,38 @@ import { SortDirection } from '@unchainedshop/utils'; -import { - buildSortOptions, - generateDbObjectId, -} from './mongodb-index.js'; +import { buildSortOptions, generateDbObjectId } from './mongodb-index.js'; describe('Mongo', () => { - it('Init', async () => { - expect(true).toBeTruthy() + it('Init', () => { + expect(true).toBeTruthy(); }); describe('buildSortOptions', () => { it('should return the correct db sort format', () => { - const sort = [ { key: 'name', value: SortDirection.ASC }, { key: 'age', value: SortDirection.DESC }, ]; + const sort = [ + { key: 'name', value: SortDirection.ASC }, + { key: 'age', value: SortDirection.DESC }, + ]; expect(buildSortOptions(sort)).toEqual({ name: 1, age: -1 }); - }) - + }); }); - + describe('generateDbObjectId', () => { - it('generateDbObjectId with default digits', () => { - const result = generateDbObjectId(); - expect(typeof result).toBe('string'); - expect(result.length).toBe(24); - }); - - it('generateDbObjectId with odd digits', () => { - const result = generateDbObjectId(23); - expect(typeof result).toBe('string'); - expect(result.length).toBe(23); - }); - - it('generateDbObjectId with even digits', () => { - const result = generateDbObjectId(24); - expect(typeof result).toBe('string'); - expect(result.length).toBe(24); + it('generateDbObjectId with default digits', () => { + const result = generateDbObjectId(); + expect(typeof result).toBe('string'); + expect(result.length).toBe(24); + }); + + it('generateDbObjectId with odd digits', () => { + const result = generateDbObjectId(23); + expect(typeof result).toBe('string'); + expect(result.length).toBe(23); + }); + + it('generateDbObjectId with even digits', () => { + const result = generateDbObjectId(24); + expect(typeof result).toBe('string'); + expect(result.length).toBe(24); + }); }); - - }) }); - diff --git a/packages/platform/tests/platform-index.test.ts b/packages/platform/tests/platform-index.test.ts index 8b7f0a9438..fd727c0496 100644 --- a/packages/platform/tests/platform-index.test.ts +++ b/packages/platform/tests/platform-index.test.ts @@ -1,5 +1,5 @@ describe('Platform', () => { - it('Init', async () => { - expect(true).toBeTruthy() + it('Init', () => { + expect(true).toBeTruthy(); }); }); diff --git a/packages/plugins/src/pricing/plugins-index.test.ts b/packages/plugins/src/pricing/plugins-index.test.ts index a8a79b13af..8334827993 100644 --- a/packages/plugins/src/pricing/plugins-index.test.ts +++ b/packages/plugins/src/pricing/plugins-index.test.ts @@ -1,3 +1,3 @@ describe('Plugins', () => { - it.todo("Plugins Tests") + it.todo('Plugins Tests'); }); diff --git a/packages/utils/src/director/base-discount-adapter.test.ts b/packages/utils/src/director/base-discount-adapter.test.ts index 9c444cab89..696123c886 100644 --- a/packages/utils/src/director/base-discount-adapter.test.ts +++ b/packages/utils/src/director/base-discount-adapter.test.ts @@ -1,14 +1,14 @@ -import { BaseDiscountAdapter } from "./BaseDiscountAdapter.js"; +import { BaseDiscountAdapter } from './BaseDiscountAdapter.js'; -describe("BaseDiscountAdapter instantiation", () => { +describe('BaseDiscountAdapter instantiation', () => { const adapter = BaseDiscountAdapter; - const context = null - it("should initialize with default values", () => { + const context = null; + it('should initialize with default values', () => { expect(adapter.orderIndex).toEqual(0); expect(adapter.log).toEqual(expect.any(Function)); expect(adapter.isManualAdditionAllowed('')).resolves.toEqual(false); expect(adapter.isManualRemovalAllowed()).resolves.toEqual(false); - + expect(adapter.actions(context)).resolves.toEqual({ isValidForSystemTriggering: expect.any(Function), reserve: expect.any(Function), @@ -18,35 +18,36 @@ describe("BaseDiscountAdapter instantiation", () => { }); }); - describe('actions', ()=> { - const actions = adapter.actions(context) - + describe('actions', () => { + const actions = adapter.actions(context); + it('isValidForSystemTriggering', async () => { const result = await adapter.actions(context); - - expect(await result.isValidForSystemTriggering()).toEqual(false) - }) + + expect(await result.isValidForSystemTriggering()).toEqual(false); + }); it('reserve', async () => { const result = await adapter.actions(context); - expect(await result.reserve({code: ''})).toEqual({}) - }) + expect(await result.reserve({ code: '' })).toEqual({}); + }); it('release', async () => { const result = await adapter.actions(context); - expect(await result.release()).toEqual(null) - }) + expect(await result.release()).toEqual(null); + }); it('isValidForCodeTriggering', async () => { const result = await adapter.actions(context); - expect(await result.isValidForCodeTriggering({code: ''})).toEqual(false) - }) + expect(await result.isValidForCodeTriggering({ code: '' })).toEqual(false); + }); it('discountForPricingAdapterKey', async () => { const result = await adapter.actions(context); - const calculationSheet = {} - expect(await result.discountForPricingAdapterKey({calculationSheet, pricingAdapterKey: 'key'} as any)).toEqual(null) - }) - - }) + const calculationSheet = {}; + expect( + await result.discountForPricingAdapterKey({ calculationSheet, pricingAdapterKey: 'key' } as any), + ).toEqual(null); + }); + }); });