mirror of
https://github.com/bitwarden/browser
synced 2026-02-04 18:53:20 +00:00
add extra checks for folders. add specs
This commit is contained in:
@@ -552,11 +552,7 @@ export class VaultPopupListFiltersService {
|
||||
|
||||
// When the organization filter changes and a folder is already selected,
|
||||
// reset the folder filter if the folder does not belong to the new organization filter
|
||||
if (
|
||||
currentFilters.folder &&
|
||||
currentFilters.folder.id !== null &&
|
||||
organization.id !== MY_VAULT_ID
|
||||
) {
|
||||
if (currentFilters.folder && currentFilters.folder.id && organization.id !== MY_VAULT_ID) {
|
||||
// Get all ciphers that belong to the new organization
|
||||
const orgCiphers = this.cipherViews.filter((c) => c.organizationId === organization.id);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ export class FolderData {
|
||||
constructor(response: Partial<FolderResponse>) {
|
||||
this.name = response.name ?? "";
|
||||
this.id = response.id ?? "";
|
||||
this.revisionDate = response.revisionDate ?? "";
|
||||
this.revisionDate = response.revisionDate ?? new Date().toISOString();
|
||||
}
|
||||
|
||||
static fromJSON(obj: Jsonify<FolderData | null>) {
|
||||
|
||||
@@ -42,6 +42,31 @@ describe("Folder", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("constructor", () => {
|
||||
it("initializes properties from FolderData", () => {
|
||||
const revisionDate = new Date("2022-08-04T01:06:40.441Z");
|
||||
const folder = new Folder({
|
||||
id: "id",
|
||||
name: "name",
|
||||
revisionDate: revisionDate.toISOString(),
|
||||
});
|
||||
|
||||
expect(folder.id).toBe("id");
|
||||
expect(folder.revisionDate).toEqual(revisionDate);
|
||||
expect(folder.name).toBeInstanceOf(EncString);
|
||||
expect((folder.name as EncString).encryptedString).toBe("name");
|
||||
});
|
||||
|
||||
it("initializes empty properties when no FolderData is provided", () => {
|
||||
const folder = new Folder();
|
||||
|
||||
expect(folder.id).toBe("");
|
||||
expect(folder.name).toBeInstanceOf(EncString);
|
||||
expect((folder.name as EncString).encryptedString).toBe("");
|
||||
expect(folder.revisionDate).toBeInstanceOf(Date);
|
||||
});
|
||||
});
|
||||
|
||||
describe("fromJSON", () => {
|
||||
jest.mock("../../../key-management/crypto/models/enc-string");
|
||||
jest.spyOn(EncString, "fromJSON").mockImplementation(mockFromJson);
|
||||
|
||||
@@ -7,12 +7,6 @@ import { SymmetricCryptoKey } from "../../../platform/models/domain/symmetric-cr
|
||||
import { FolderData } from "../data/folder.data";
|
||||
import { FolderView } from "../view/folder.view";
|
||||
|
||||
export class Test extends Domain {
|
||||
id: string = "";
|
||||
name: EncString = new EncString("");
|
||||
revisionDate: Date = new Date();
|
||||
}
|
||||
|
||||
export class Folder extends Domain {
|
||||
id: string = "";
|
||||
name: EncString = new EncString("");
|
||||
|
||||
Reference in New Issue
Block a user