mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
[PM-5189] Adding jest tests for added methods in AutofillInit
This commit is contained in:
@@ -155,6 +155,24 @@ describe("AutofillInit", () => {
|
|||||||
autofillInit.init();
|
autofillInit.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("triggers extension message handlers from the AutofillOverlayContentService", () => {
|
||||||
|
autofillOverlayContentService.extensionMessageHandlers.messageHandler = jest.fn();
|
||||||
|
|
||||||
|
sendMockExtensionMessage({ command: "messageHandler" }, sender, sendResponse);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
autofillOverlayContentService.extensionMessageHandlers.messageHandler,
|
||||||
|
).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("triggers extension message handlers from the AutofillInlineMenuContentService", () => {
|
||||||
|
inlineMenuElements.extensionMessageHandlers.messageHandler = jest.fn();
|
||||||
|
|
||||||
|
sendMockExtensionMessage({ command: "messageHandler" }, sender, sendResponse);
|
||||||
|
|
||||||
|
expect(inlineMenuElements.extensionMessageHandlers.messageHandler).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
describe("collectPageDetails", () => {
|
describe("collectPageDetails", () => {
|
||||||
it("sends the collected page details for autofill using a background script message", async () => {
|
it("sends the collected page details for autofill using a background script message", async () => {
|
||||||
const pageDetails: AutofillPageDetails = {
|
const pageDetails: AutofillPageDetails = {
|
||||||
|
|||||||
@@ -190,6 +190,11 @@ class AutofillInit implements AutofillInitInterface {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the extension message handler for the given command.
|
||||||
|
*
|
||||||
|
* @param command - The extension message command.
|
||||||
|
*/
|
||||||
private getExtensionMessageHandler(command: string): CallableFunction | undefined {
|
private getExtensionMessageHandler(command: string): CallableFunction | undefined {
|
||||||
if (this.autofillOverlayContentService?.extensionMessageHandlers?.[command]) {
|
if (this.autofillOverlayContentService?.extensionMessageHandlers?.[command]) {
|
||||||
return this.autofillOverlayContentService.extensionMessageHandlers[command];
|
return this.autofillOverlayContentService.extensionMessageHandlers[command];
|
||||||
|
|||||||
Reference in New Issue
Block a user