1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-27 23:03:45 +00:00

Improves coverage.

This commit is contained in:
Miles Blackwood
2026-01-23 18:08:51 -05:00
parent 558b4ae7ae
commit ac9440cfe7

View File

@@ -170,6 +170,44 @@ describe("NotificationBackground", () => {
expect(cipherView.folderId).toEqual(folderId);
});
it("removes 'www.' prefix from hostname when generating cipher name", () => {
const message: AddLoginQueueMessage = {
type: "add",
data: {
username: "test",
password: "password",
uri: "https://www.example.com",
},
domain: "www.example.com",
tab: createChromeTabMock(),
expires: new Date(),
wasVaultLocked: false,
launchTimestamp: 0,
};
const cipherView = notificationBackground["convertAddLoginQueueMessageToCipherView"](message);
expect(cipherView.name).toEqual("example.com");
});
it("uses domain as fallback when hostname cannot be extracted from uri", () => {
const message: AddLoginQueueMessage = {
type: "add",
data: {
username: "test",
password: "password",
uri: "",
},
domain: "fallback-domain.com",
tab: createChromeTabMock(),
expires: new Date(),
wasVaultLocked: false,
launchTimestamp: 0,
};
const cipherView = notificationBackground["convertAddLoginQueueMessageToCipherView"](message);
expect(cipherView.name).toEqual("fallback-domain.com");
});
});
describe("notification bar extension message handlers and triggers", () => {