Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
dni committed Jan 3, 2024
1 parent cd2eaf7 commit 5e66a31
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions tests/utils/webln.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { detectWebLNProvider, enableWebln } from "../../src/utils/webln";
describe("WebLN", () => {
beforeEach(() => {
log.error = vitest.fn();
// @ts-ignore
window.webln = undefined;
});

test("should not detect WebLN when no injected provider is present", async () => {
Expand All @@ -25,35 +23,29 @@ describe("WebLN", () => {
});

test("should call WebLN callback if enable call succeeds", async () => {
// @ts-ignore
window.webln = {
enable: vitest.fn().mockResolvedValue(undefined),
} as any;
const cb = vitest.fn();

expect(await enableWebln(cb));

// @ts-ignore
expect(window.webln.enable).toHaveBeenCalledTimes(1);
// @ts-ignore
expect(window.webln.enable).toHaveBeenCalledWith();

expect(cb).toHaveBeenCalledTimes(1);
expect(log.error).toHaveBeenCalledTimes(0);
});

test("should not call WebLN callback if enable call fails", async () => {
// @ts-ignore
window.webln = {
enable: vitest.fn().mockRejectedValue("unauthorized"),
} as any;
const cb = vitest.fn();

expect(await enableWebln(cb));

// @ts-ignore
expect(window.webln.enable).toHaveBeenCalledTimes(1);
// @ts-ignore
expect(window.webln.enable).toHaveBeenCalledWith();

expect(cb).toHaveBeenCalledTimes(0);
Expand Down

0 comments on commit 5e66a31

Please sign in to comment.