-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpasswordValidation.test.js
32 lines (28 loc) · 1.2 KB
/
passwordValidation.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const passwordValidation = require("./passwordValidation");
describe("passwordValidation", () => {
it("should return true if have 8 characters or more", () => {
expect(passwordValidation("1234567b")).toBe(true);
expect(passwordValidation("1234567a")).toBe(true);
});
it("should return false if password have less than 8 characters", () => {
expect(passwordValidation("12345")).toBe(false);
expect(passwordValidation("1234567")).toBe(false);
});
describe("should contain at least one lowercase character", () => {
it("should return false if there are no lowercase characters", () => {
expect(passwordValidation("ABCDEFGH")).toBe(false);
});
it("should return true if there at least one lowercase characters", () => {
expect(passwordValidation("aBCDE123")).toBe(true);
});
it("should return true if there at least two lowercase characters", () => {
expect(passwordValidation("AbcDxE123")).toBe(true);
});
});
it("should return true if password have a numba", () => {
expect(passwordValidation("abcdefg1")).toBe(true);
});
it("should return true if password have a numba", () => {
expect(passwordValidation("abcde")).toBe(false);
});
});