fix: unit tests not running

This commit is contained in:
montaghanmy
2023-04-07 09:23:58 +01:00
parent 86f46508f3
commit 4ed7a4c857
2 changed files with 0 additions and 62 deletions
@@ -1,31 +0,0 @@
import "reflect-metadata";
import { describe, expect, it } from "@jest/globals";
import {
fromMongoDbOrderable,
toMongoDbOrderable,
} from "../../../../../../src/core/platform/services/database/services/orm/utils";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import _ from "lodash";
import { v1 as uuidv1 } from "uuid";
describe("The MongoDb to Orderable module", () => {
describe("The to/from orderable function", () => {
it("should be unique", () => {
const uuid1 = toMongoDbOrderable(uuidv1());
const uuid2 = toMongoDbOrderable(uuidv1());
const uuid3 = toMongoDbOrderable(uuidv1());
const uuid4 = toMongoDbOrderable(uuidv1());
expect(_.uniq([uuid1, uuid2, uuid3, uuid4]).length).toBe(4);
});
it("should convert both ways", () => {
const uuid = uuidv1();
const orderable = toMongoDbOrderable(uuid);
expect(fromMongoDbOrderable(orderable)).toBe(uuid);
expect(orderable).toBe(toMongoDbOrderable(fromMongoDbOrderable(orderable)));
});
});
});
@@ -1,31 +0,0 @@
import { describe, expect, it } from "@jest/globals";
import { decrypt } from "../../../../../src/core/crypto/index";
import v2 from "../../../../../src/core/crypto/v2";
import v1 from "../../../../../src/core/crypto/v1";
import legacy from "../../../../../src/core/crypto/legacy";
describe("Encryption", () => {
const encryptionKey = "a7c06651a7c063bb3e90c0c9a17eab88ab8977665127196a";
describe("The encrypt/decrypt functions", () => {
it("should successfully describe legacy encrypted values", async () => {
const legacyEncrypted = "encrypted_DwMLnKhuFbIanqBJPA5rcw==";
expect(legacy.decrypt(legacyEncrypted, encryptionKey).data).toBe("My company");
expect(decrypt(legacyEncrypted, encryptionKey).data).toBe("My company");
});
it("should successfully describe all versions", async () => {
const myData = { key: "some data" };
const v1Encrypted = v1.encrypt(myData, encryptionKey);
const v2Encrypted = v2.encrypt(myData, encryptionKey);
expect(v1.decrypt(v1Encrypted.data, encryptionKey).data).toMatchObject(myData);
expect(v2.decrypt(v2Encrypted.data, encryptionKey).data).toMatchObject(myData);
expect(decrypt(v1Encrypted.data, encryptionKey).data).toMatchObject(myData);
expect(decrypt(v2Encrypted.data, encryptionKey).data).toMatchObject(myData);
});
});
});