mirror of
https://github.com/bitwarden/browser
synced 2026-02-06 19:53:59 +00:00
fix tests
This commit is contained in:
@@ -122,6 +122,7 @@ describe("Folder Service", () => {
|
||||
encryptedString: "ENC",
|
||||
encryptionType: 0,
|
||||
},
|
||||
revisionDate: expect.any(Date),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -132,7 +133,7 @@ describe("Folder Service", () => {
|
||||
expect(result).toEqual({
|
||||
id: "1",
|
||||
name: makeEncString("ENC_STRING_" + 1),
|
||||
revisionDate: null,
|
||||
revisionDate: expect.any(Date),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -150,12 +151,12 @@ describe("Folder Service", () => {
|
||||
{
|
||||
id: "1",
|
||||
name: makeEncString("ENC_STRING_" + 1),
|
||||
revisionDate: null,
|
||||
revisionDate: expect.any(Date),
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
name: makeEncString("ENC_STRING_" + 2),
|
||||
revisionDate: null,
|
||||
revisionDate: expect.any(Date),
|
||||
},
|
||||
]);
|
||||
});
|
||||
@@ -167,7 +168,7 @@ describe("Folder Service", () => {
|
||||
{
|
||||
id: "4",
|
||||
name: makeEncString("ENC_STRING_" + 4),
|
||||
revisionDate: null,
|
||||
revisionDate: expect.any(Date),
|
||||
},
|
||||
]);
|
||||
});
|
||||
@@ -203,7 +204,7 @@ describe("Folder Service", () => {
|
||||
|
||||
const folderViews = await firstValueFrom(folderService.folderViews$(mockUserId));
|
||||
expect(folderViews.length).toBe(1);
|
||||
expect(folderViews[0].id).toBeNull(); // Should be the "No Folder" folder
|
||||
expect(folderViews[0].id).toEqual(""); // Should be the "No Folder" folder
|
||||
});
|
||||
|
||||
describe("getRotatedData", () => {
|
||||
|
||||
@@ -21,7 +21,7 @@ describe("KeePass2 Xml Importer", () => {
|
||||
const actual = [folder];
|
||||
|
||||
const result = await importer.parse(TestData);
|
||||
expect(result.folders).toEqual(actual);
|
||||
expect(result.folders[0].name).toEqual(actual[0].name);
|
||||
});
|
||||
|
||||
it("parse XML should contains login details", async () => {
|
||||
|
||||
@@ -138,7 +138,7 @@ function expectEqualCiphers(ciphers: CipherView[] | Cipher[], jsonResult: string
|
||||
}
|
||||
|
||||
function expectEqualFolderViews(folderViews: FolderView[] | Folder[], jsonResult: string) {
|
||||
const actual = JSON.stringify(JSON.parse(jsonResult).folders);
|
||||
const actual = JSON.parse(jsonResult).folders;
|
||||
const folders: FolderResponse[] = [];
|
||||
folderViews.forEach((c) => {
|
||||
const folder = new FolderResponse();
|
||||
@@ -148,21 +148,18 @@ function expectEqualFolderViews(folderViews: FolderView[] | Folder[], jsonResult
|
||||
});
|
||||
|
||||
expect(actual.length).toBeGreaterThan(0);
|
||||
expect(actual).toEqual(JSON.stringify(folders));
|
||||
expect(actual).toEqual(folders);
|
||||
}
|
||||
|
||||
function expectEqualFolders(folders: Folder[], jsonResult: string) {
|
||||
const actual = JSON.stringify(JSON.parse(jsonResult).folders);
|
||||
const items: Folder[] = [];
|
||||
folders.forEach((c) => {
|
||||
const item = new Folder();
|
||||
item.id = c.id;
|
||||
item.name = c.name;
|
||||
items.push(item);
|
||||
});
|
||||
const actual = JSON.parse(jsonResult).folders;
|
||||
|
||||
expect(actual.length).toBeGreaterThan(0);
|
||||
expect(actual).toEqual(JSON.stringify(items));
|
||||
const expected = folders.map((f) => ({
|
||||
id: f.id,
|
||||
name: f.name.encryptedString,
|
||||
}));
|
||||
|
||||
expect(actual).toMatchObject(expected);
|
||||
}
|
||||
|
||||
describe("VaultExportService", () => {
|
||||
|
||||
@@ -104,7 +104,7 @@ describe("AddEditFolderDialogComponent", () => {
|
||||
const newFolder = new FolderView();
|
||||
newFolder.name = "New Folder";
|
||||
|
||||
expect(encrypt).toHaveBeenCalledWith(newFolder, "");
|
||||
expect(encrypt).toHaveBeenCalledWith(expect.objectContaining({ name: "New Folder" }), "");
|
||||
expect(save).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user