mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-05 23:53:21 +00:00
* Unpackage-ify jslib * Adjust .tsconfig path for root and apply to jslib * Rebuild package-lock.json * Disable husky in CI * Revert an incorrect find/replace * Add jslib/shared/.eslintrc rules to root eslintrc * Revert package.json change to ignore spec files when linting * Ensure custom matcher gets imported in jslib tests * Fix small workflow bugs from merging * Try and get CI builds moving again * Always sign and notorize builds in CI * Revert erroneous verion bump
58 lines
1.2 KiB
TypeScript
58 lines
1.2 KiB
TypeScript
import { SendFileData } from "@/jslib/common/src/models/data/sendFileData";
|
|
import { SendFile } from "@/jslib/common/src/models/domain/sendFile";
|
|
|
|
import { mockEnc } from "../utils";
|
|
|
|
describe("SendFile", () => {
|
|
let data: SendFileData;
|
|
|
|
beforeEach(() => {
|
|
data = {
|
|
id: "id",
|
|
size: "1100",
|
|
sizeName: "1.1 KB",
|
|
fileName: "encFileName",
|
|
};
|
|
});
|
|
|
|
it("Convert from empty", () => {
|
|
const data = new SendFileData();
|
|
const sendFile = new SendFile(data);
|
|
|
|
expect(sendFile).toEqual({
|
|
fileName: null,
|
|
id: null,
|
|
size: undefined,
|
|
sizeName: null,
|
|
});
|
|
});
|
|
|
|
it("Convert", () => {
|
|
const sendFile = new SendFile(data);
|
|
|
|
expect(sendFile).toEqual({
|
|
id: "id",
|
|
size: "1100",
|
|
sizeName: "1.1 KB",
|
|
fileName: { encryptedString: "encFileName", encryptionType: 0 },
|
|
});
|
|
});
|
|
|
|
it("Decrypt", async () => {
|
|
const sendFile = new SendFile();
|
|
sendFile.id = "id";
|
|
sendFile.size = "1100";
|
|
sendFile.sizeName = "1.1 KB";
|
|
sendFile.fileName = mockEnc("fileName");
|
|
|
|
const view = await sendFile.decrypt(null);
|
|
|
|
expect(view).toEqual({
|
|
fileName: "fileName",
|
|
id: "id",
|
|
size: "1100",
|
|
sizeName: "1.1 KB",
|
|
});
|
|
});
|
|
});
|