mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
[PM-8027] Working through jest tests for the InlineMenuFieldQualificationService
This commit is contained in:
@@ -19,27 +19,55 @@ describe("InlineMenuFieldQualificationService", () => {
|
|||||||
describe("validating a password field for a login form", () => {
|
describe("validating a password field for a login form", () => {
|
||||||
describe("an invalid password field", () => {
|
describe("an invalid password field", () => {
|
||||||
it("has a `new-password` autoCompleteType", () => {
|
it("has a `new-password` autoCompleteType", () => {
|
||||||
const newPasswordField = mock<AutofillField>({
|
const field = mock<AutofillField>({
|
||||||
type: "password",
|
type: "password",
|
||||||
autoCompleteType: "new-password",
|
autoCompleteType: "new-password",
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(
|
expect(inlineMenuFieldQualificationService.isFieldForLoginForm(field, pageDetails)).toBe(
|
||||||
inlineMenuFieldQualificationService.isFieldForLoginForm(newPasswordField, pageDetails),
|
false,
|
||||||
).toBe(false);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has a type that is an excluded type", () => {
|
it("has a type that is an excluded type", () => {
|
||||||
AutoFillConstants.ExcludedAutofillLoginTypes.forEach((excludedType) => {
|
AutoFillConstants.ExcludedAutofillLoginTypes.forEach((excludedType) => {
|
||||||
const excludedField = mock<AutofillField>({
|
const field = mock<AutofillField>({
|
||||||
type: excludedType,
|
type: excludedType,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
inlineMenuFieldQualificationService.isFieldForLoginForm(excludedField, pageDetails),
|
inlineMenuFieldQualificationService.isFieldForLoginForm(field, pageDetails),
|
||||||
).toBe(false);
|
).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("has an attribute present on the FieldIgnoreList, indicating that the field is a captcha", () => {
|
||||||
|
AutoFillConstants.FieldIgnoreList.forEach((attribute, index) => {
|
||||||
|
const field = mock<AutofillField>({
|
||||||
|
type: "password",
|
||||||
|
htmlID: index === 0 ? attribute : "",
|
||||||
|
htmlName: index === 1 ? attribute : "",
|
||||||
|
placeholder: index > 1 ? attribute : "",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(
|
||||||
|
inlineMenuFieldQualificationService.isFieldForLoginForm(field, pageDetails),
|
||||||
|
).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("has a type other than `password` or `text`", () => {
|
||||||
|
const field = mock<AutofillField>({
|
||||||
|
type: "number",
|
||||||
|
htmlID: "not-password",
|
||||||
|
htmlName: "not-password",
|
||||||
|
placeholder: "not-password",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(inlineMenuFieldQualificationService.isFieldForLoginForm(field, pageDetails)).toBe(
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("a valid password field", () => {});
|
describe("a valid password field", () => {});
|
||||||
|
|||||||
Reference in New Issue
Block a user