browsertrix/frontend/src/utils/auth.test.ts
2021-11-23 16:57:28 -08:00

27 lines
648 B
TypeScript

import { spy } from "sinon";
import { expect } from "@esm-bundle/chai";
import * as auth from "./auth";
describe("auth", () => {
describe("needLogin", () => {
it("dispatches the correct event on need log in", () => {
const dispatchEventSpy = spy();
class LiteElementMock {
dispatchEvent = dispatchEventSpy;
}
const Element = auth.needLogin(
class extends LiteElementMock {
authState = null;
} as any
);
const element = new Element();
element.connectedCallback();
expect(dispatchEventSpy.getCall(0).firstArg.type).to.equal("need-login");
});
});
});