thelounge/test/client/js/authTest.ts
Max Leiter dd05ee3a65
TypeScript and Vue 3 (#4559)
Co-authored-by: Eric Nemchik <eric@nemchik.com>
Co-authored-by: Pavel Djundik <xPaw@users.noreply.github.com>
2022-06-18 17:25:21 -07:00

35 lines
1.2 KiB
TypeScript

import {expect} from "chai";
import sinon from "ts-sinon";
import Auth from "../../../client/js/auth";
import localStorage from "../../../client/js/localStorage";
import location from "../../../client/js/location";
describe("Auth", function () {
describe(".signout", function () {
let localStorageClearStub: sinon.SinonStub<[], void>;
let locationReloadStub: sinon.SinonStub<[], void>;
beforeEach(function () {
localStorageClearStub = sinon.stub(localStorage, "clear");
locationReloadStub = sinon.stub(location, "reload");
});
afterEach(function () {
localStorageClearStub.restore();
locationReloadStub.restore();
});
it("should empty the local storage", function () {
Auth.signout();
// @ts-expect-error ts-migrate(2339) FIXME: Property 'calledOnce' does not exist on type '() =... Remove this comment to see the full error message
expect(localStorage.clear.calledOnce).to.be.true;
});
it("should reload the page", function () {
Auth.signout();
// @ts-expect-error ts-migrate(2339) FIXME: Property 'calledOnce' does not exist on type '{ ()... Remove this comment to see the full error message
expect(location.reload.calledOnce).to.be.true;
});
});
});