From c93250f8e85c2d5aed6ea0b6b8704345ac78d5f5 Mon Sep 17 00:00:00 2001 From: proteriax <8125011+proteriax@users.noreply.github.com> Date: Thu, 8 Jul 2021 02:09:20 -0400 Subject: [PATCH] Remove unused method --- src/vault.ts | 20 ++++---------------- test/profile.test.ts | 13 ++++++++++++- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/vault.ts b/src/vault.ts index c172625..accd3ae 100644 --- a/src/vault.ts +++ b/src/vault.ts @@ -72,7 +72,10 @@ export class Vault { } }, - values: () => Array.from(this.#overviews.values()), + values: () => { + this.#assertUnlocked() + return Array.from(this.#overviews.values()) + }, }) /** @@ -127,21 +130,6 @@ export class Vault { } } - getOverview(title: string): Overview - getOverview(predicate: (overview: Overview) => boolean): Overview - - getOverview(condition: string | ((overview: Overview) => boolean)) { - if (typeof condition === "string") { - const title = condition - condition = overview => overview.title === title - } - for (const value of this.#overviews.values()) { - if (condition(value)) { - return value - } - } - } - getItem(uuid: string) { this.#assertUnlocked() const encrypted = uuid ? this.#bands.get(uuid[0])![uuid] : undefined diff --git a/test/profile.test.ts b/test/profile.test.ts index 36ae3ee..6cca3f6 100644 --- a/test/profile.test.ts +++ b/test/profile.test.ts @@ -38,5 +38,16 @@ describe("OnePassword", () => { }); }); - describe("lock", () => {}); + describe("lock", () => { + it("locks", async () => { + const instance = new OnePassword({ path: freddy }); + const vault = await instance.getProfile("default"); + vault.unlock("freddy"); + expect(vault.isLocked).to.be.false; + + vault.lock(); + expect(vault.isLocked).to.be.true; + expect(() => vault.overviews.values()).to.throw(); + }); + }); });