mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-03 23:21:29 +01:00
[PM-5189] Refactoring implementation
This commit is contained in:
parent
45a17b1cb8
commit
a599679563
@ -16,7 +16,7 @@ import { InitAutofillInlineMenuButtonMessage } from "../overlay/inline-menu/abst
|
|||||||
import { InitAutofillInlineMenuListMessage } from "../overlay/inline-menu/abstractions/autofill-inline-menu-list";
|
import { InitAutofillInlineMenuListMessage } from "../overlay/inline-menu/abstractions/autofill-inline-menu-list";
|
||||||
import { GenerateFillScriptOptions, PageDetail } from "../services/abstractions/autofill.service";
|
import { GenerateFillScriptOptions, PageDetail } from "../services/abstractions/autofill.service";
|
||||||
|
|
||||||
function createAutofillFormMock(customFields = {}): AutofillForm {
|
export function createAutofillFormMock(customFields = {}): AutofillForm {
|
||||||
return {
|
return {
|
||||||
opid: "default-form-opid",
|
opid: "default-form-opid",
|
||||||
htmlID: "default-htmlID",
|
htmlID: "default-htmlID",
|
||||||
@ -27,7 +27,7 @@ function createAutofillFormMock(customFields = {}): AutofillForm {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createAutofillFieldMock(customFields = {}): AutofillField {
|
export function createAutofillFieldMock(customFields = {}): AutofillField {
|
||||||
return {
|
return {
|
||||||
opid: "default-input-field-opid",
|
opid: "default-input-field-opid",
|
||||||
elementNumber: 0,
|
elementNumber: 0,
|
||||||
@ -57,7 +57,7 @@ function createAutofillFieldMock(customFields = {}): AutofillField {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPageDetailMock(customFields = {}): PageDetail {
|
export function createPageDetailMock(customFields = {}): PageDetail {
|
||||||
return {
|
return {
|
||||||
frameId: 0,
|
frameId: 0,
|
||||||
tab: createChromeTabMock(),
|
tab: createChromeTabMock(),
|
||||||
@ -66,7 +66,7 @@ function createPageDetailMock(customFields = {}): PageDetail {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createAutofillPageDetailsMock(customFields = {}): AutofillPageDetails {
|
export function createAutofillPageDetailsMock(customFields = {}): AutofillPageDetails {
|
||||||
return {
|
return {
|
||||||
title: "title",
|
title: "title",
|
||||||
url: "url",
|
url: "url",
|
||||||
@ -86,7 +86,7 @@ function createAutofillPageDetailsMock(customFields = {}): AutofillPageDetails {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createChromeTabMock(customFields = {}): chrome.tabs.Tab {
|
export function createChromeTabMock(customFields = {}): chrome.tabs.Tab {
|
||||||
return {
|
return {
|
||||||
id: 1,
|
id: 1,
|
||||||
index: 1,
|
index: 1,
|
||||||
@ -104,7 +104,7 @@ function createChromeTabMock(customFields = {}): chrome.tabs.Tab {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createGenerateFillScriptOptionsMock(customFields = {}): GenerateFillScriptOptions {
|
export function createGenerateFillScriptOptionsMock(customFields = {}): GenerateFillScriptOptions {
|
||||||
return {
|
return {
|
||||||
skipUsernameOnlyFill: false,
|
skipUsernameOnlyFill: false,
|
||||||
onlyEmptyFields: false,
|
onlyEmptyFields: false,
|
||||||
@ -118,7 +118,7 @@ function createGenerateFillScriptOptionsMock(customFields = {}): GenerateFillScr
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createAutofillScriptMock(
|
export function createAutofillScriptMock(
|
||||||
customFields = {},
|
customFields = {},
|
||||||
scriptTypes?: Record<string, string>,
|
scriptTypes?: Record<string, string>,
|
||||||
): AutofillScript {
|
): AutofillScript {
|
||||||
@ -165,7 +165,7 @@ const overlayPagesTranslations = {
|
|||||||
newItem: "newItem",
|
newItem: "newItem",
|
||||||
addNewVaultItem: "addNewVaultItem",
|
addNewVaultItem: "addNewVaultItem",
|
||||||
};
|
};
|
||||||
function createInitAutofillInlineMenuButtonMessageMock(
|
export function createInitAutofillInlineMenuButtonMessageMock(
|
||||||
customFields = {},
|
customFields = {},
|
||||||
): InitAutofillInlineMenuButtonMessage {
|
): InitAutofillInlineMenuButtonMessage {
|
||||||
return {
|
return {
|
||||||
@ -177,7 +177,7 @@ function createInitAutofillInlineMenuButtonMessageMock(
|
|||||||
...customFields,
|
...customFields,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function createAutofillOverlayCipherDataMock(
|
export function createAutofillOverlayCipherDataMock(
|
||||||
index: number,
|
index: number,
|
||||||
customFields = {},
|
customFields = {},
|
||||||
): InlineMenuCipherData {
|
): InlineMenuCipherData {
|
||||||
@ -198,7 +198,7 @@ function createAutofillOverlayCipherDataMock(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createInitAutofillInlineMenuListMessageMock(
|
export function createInitAutofillInlineMenuListMessageMock(
|
||||||
customFields = {},
|
customFields = {},
|
||||||
): InitAutofillInlineMenuListMessage {
|
): InitAutofillInlineMenuListMessage {
|
||||||
return {
|
return {
|
||||||
@ -242,7 +242,7 @@ function createInitAutofillInlineMenuListMessageMock(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createFocusedFieldDataMock(customFields = {}) {
|
export function createFocusedFieldDataMock(customFields = {}) {
|
||||||
return {
|
return {
|
||||||
focusedFieldRects: {
|
focusedFieldRects: {
|
||||||
top: 1,
|
top: 1,
|
||||||
@ -260,7 +260,7 @@ function createFocusedFieldDataMock(customFields = {}) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPortSpyMock(name: string) {
|
export function createPortSpyMock(name: string) {
|
||||||
return mock<chrome.runtime.Port>({
|
return mock<chrome.runtime.Port>({
|
||||||
name,
|
name,
|
||||||
onMessage: {
|
onMessage: {
|
||||||
@ -279,7 +279,7 @@ function createPortSpyMock(name: string) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createMutationRecordMock(customFields = {}): MutationRecord {
|
export function createMutationRecordMock(customFields = {}): MutationRecord {
|
||||||
return {
|
return {
|
||||||
addedNodes: mock<NodeList>(),
|
addedNodes: mock<NodeList>(),
|
||||||
attributeName: "default-attributeName",
|
attributeName: "default-attributeName",
|
||||||
@ -293,18 +293,3 @@ function createMutationRecordMock(customFields = {}): MutationRecord {
|
|||||||
...customFields,
|
...customFields,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
|
||||||
createAutofillFormMock,
|
|
||||||
createAutofillFieldMock,
|
|
||||||
createPageDetailMock,
|
|
||||||
createAutofillPageDetailsMock,
|
|
||||||
createChromeTabMock,
|
|
||||||
createGenerateFillScriptOptionsMock,
|
|
||||||
createAutofillScriptMock,
|
|
||||||
createInitAutofillInlineMenuButtonMessageMock,
|
|
||||||
createInitAutofillInlineMenuListMessageMock,
|
|
||||||
createFocusedFieldDataMock,
|
|
||||||
createPortSpyMock,
|
|
||||||
createMutationRecordMock,
|
|
||||||
};
|
|
||||||
|
Loading…
Reference in New Issue
Block a user