fix: unit tests not running
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user