2021-10-15 12:33:44 -05:00
|
|
|
const { genSecret, sleep } = require("../src/util");
|
2021-10-13 09:16:46 -05:00
|
|
|
|
2021-10-15 12:33:44 -05:00
|
|
|
describe("Test genSecret", () => {
|
2021-10-12 13:53:59 -05:00
|
|
|
|
2021-10-15 12:33:44 -05:00
|
|
|
beforeAll(() => {
|
2021-10-12 13:53:59 -05:00
|
|
|
|
2021-10-15 12:33:44 -05:00
|
|
|
});
|
2021-10-13 09:16:46 -05:00
|
|
|
|
|
|
|
it("should be correct length", () => {
|
|
|
|
let secret = genSecret(-1);
|
|
|
|
expect(secret).toEqual("");
|
|
|
|
|
|
|
|
secret = genSecret(0);
|
|
|
|
expect(secret).toEqual("");
|
|
|
|
|
|
|
|
secret = genSecret(1);
|
|
|
|
expect(secret.length).toEqual(1);
|
2021-10-12 13:53:59 -05:00
|
|
|
|
2021-10-13 09:16:46 -05:00
|
|
|
secret = genSecret(2);
|
|
|
|
expect(secret.length).toEqual(2);
|
|
|
|
|
|
|
|
secret = genSecret(64);
|
|
|
|
expect(secret.length).toEqual(64);
|
|
|
|
|
|
|
|
secret = genSecret(9000);
|
|
|
|
expect(secret.length).toEqual(9000);
|
|
|
|
|
|
|
|
secret = genSecret(90000);
|
|
|
|
expect(secret.length).toEqual(90000);
|
|
|
|
});
|
2021-10-12 13:53:59 -05:00
|
|
|
|
2021-10-13 09:16:46 -05:00
|
|
|
it("should contain first and last possible chars", () => {
|
|
|
|
let secret = genSecret(90000);
|
|
|
|
expect(secret).toContain("A");
|
|
|
|
expect(secret).toContain("9");
|
2021-10-12 13:53:59 -05:00
|
|
|
});
|
2021-10-15 12:33:44 -05:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("Test reset-password", () => {
|
|
|
|
it("should able to run", async () => {
|
|
|
|
await require("../extra/reset-password").main();
|
2021-10-16 01:54:45 -05:00
|
|
|
}, 120000);
|
2021-10-12 13:53:59 -05:00
|
|
|
});
|