mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-10 19:38:11 +01:00
[PM-5189] Adding jest tests for added methods in AutofillInit
This commit is contained in:
parent
4b241fe47f
commit
873cfa51cd
@ -155,6 +155,24 @@ describe("AutofillInit", () => {
|
||||
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", () => {
|
||||
it("sends the collected page details for autofill using a background script message", async () => {
|
||||
const pageDetails: AutofillPageDetails = {
|
||||
|
@ -190,6 +190,11 @@ class AutofillInit implements AutofillInitInterface {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the extension message handler for the given command.
|
||||
*
|
||||
* @param command - The extension message command.
|
||||
*/
|
||||
private getExtensionMessageHandler(command: string): CallableFunction | undefined {
|
||||
if (this.autofillOverlayContentService?.extensionMessageHandlers?.[command]) {
|
||||
return this.autofillOverlayContentService.extensionMessageHandlers[command];
|
||||
|
Loading…
Reference in New Issue
Block a user