// (C) 2007-2019 GoodData Corporation import { register } from "../register"; import { ISchema } from "../../schema/model/Schema"; describe("register", () => { const emptySchema: ISchema[] = []; const baseOptions = { schema: emptySchema, }; function getMockedApp(): any { return { use: jest.fn(), get: jest.fn(), post: jest.fn(), init: jest.fn(), }; } it("should use two base middlewares when tokenExpiration not configured", () => { const app = getMockedApp(); register(app, baseOptions); expect(app.use.mock.calls.length).toEqual(2); }); it("should use two base middlewares plus one tokenExpiration if configured", () => { const app = getMockedApp(); register(app, { ...baseOptions, config: { useTokenExpiration: true } }); expect(app.use.mock.calls.length).toEqual(3); }); });