import PasswordThreeConsecutiveCharactersNotAllowedConstraint from "../PasswordThreeConsecutiveCharactersNotAllowedConstraint";

describe("password constraints", () => {
  it("passwordThreeConsecutiveCharactersNotAllowedConstraint", () => {
    const constraint =
      new PasswordThreeConsecutiveCharactersNotAllowedConstraint(1);

    expect(constraint.hasValidation()).toBe(true);
    expect(constraint.validate("ABACDEFGH")).toBeTruthy();
    expect(constraint.validate("ABAAABBCCDDEEFFGGHHAA")).toBeFalsy();
    expect(constraint.validate("")).toBeTruthy();
  });

  it("passwordThreeConsecutiveCharactersNotAllowedConstraint 3 concecutive chars", () => {
    const constraint =
      new PasswordThreeConsecutiveCharactersNotAllowedConstraint(3);

    expect(constraint.validate("AAABBACDEFGH")).toBeTruthy();
    expect(constraint.validate("ABAAAABBCCDDEEFFGGHHAA")).toBeFalsy();
    expect(constraint.validate("")).toBeTruthy();
  });
});
