2021-07-09 03:49:18 +02:00
|
|
|
import "mocha";
|
2021-07-10 19:18:20 +02:00
|
|
|
import * as crypto from "crypto";
|
2021-07-09 03:49:18 +02:00
|
|
|
import { expect } from "chai";
|
2021-07-10 19:18:20 +02:00
|
|
|
import * as sinon from "sinon";
|
2021-07-09 03:49:18 +02:00
|
|
|
import { generatePassword } from "../lib/PasswordGenerator";
|
|
|
|
|
2021-07-10 10:33:07 +02:00
|
|
|
describe("PasswordGenerator", () => {
|
2021-07-09 03:49:18 +02:00
|
|
|
it("should return true for the first time", async () => {
|
|
|
|
const result = await generatePassword(10);
|
|
|
|
expect(result).to.lengthOf(10);
|
|
|
|
});
|
2021-07-10 19:18:20 +02:00
|
|
|
// it.only("should return true for the first time", async () => {
|
|
|
|
// const testData = Buffer.from([31, 32, 126, 127]);
|
|
|
|
// sinon.stub(crypto, "randomBytes")
|
|
|
|
// .callsFake((size: number, cb: (err: Error | null, buf: Buffer) => void) => {
|
|
|
|
// console.log("HEY")
|
|
|
|
// cb(null, testData);
|
|
|
|
// });
|
|
|
|
// const result = await generatePassword(10);
|
|
|
|
// expect(result).to.equal(" ~");
|
|
|
|
// });
|
2021-07-09 03:49:18 +02:00
|
|
|
});
|