43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { resolve } from "path";
|
|
import { describe, it, beforeEach } from "mocha";
|
|
import { expect } from "chai";
|
|
// import { fs, vol } from "memfs"
|
|
|
|
import type { Vault } from "../src/index";
|
|
import { OnePassword } from "../src/index";
|
|
|
|
describe("OnePassword", () => {
|
|
const freddy = resolve(__dirname, "../freddy-2013-12-04.opvault");
|
|
|
|
describe("getProfileNames", () => {
|
|
it("freddy", async () => {
|
|
const instance = new OnePassword({ path: freddy });
|
|
expect(await instance.getProfileNames()).to.deep.equal(["default"]);
|
|
});
|
|
|
|
it.skip("ignores faulty folders", async () => {});
|
|
});
|
|
|
|
describe("unlock", () => {
|
|
let vault: Vault;
|
|
|
|
beforeEach(async () => {
|
|
vault = await new OnePassword({ path: freddy }).getProfile("default");
|
|
});
|
|
|
|
it("accepts correct password", () => {
|
|
expect(() => vault.unlock("freddy")).to.not.throw();
|
|
expect(vault.isLocked).to.be.false;
|
|
});
|
|
|
|
it("rejects wrong password", () => {
|
|
["Freddy", "_freddy", ""].forEach((password) => {
|
|
expect(() => vault.unlock(password)).to.throw("Invalid password");
|
|
expect(vault.isLocked).to.be.true;
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("lock", () => {});
|
|
});
|