-
-
Save lmiller1990/927828ea5ec4036f25cbb2fa19f5c612 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { beforeEach } from "@/router.js" | |
import mockModule from "@/bust-cache.js" | |
jest.mock("@/bust-cache.js", () => ({ bustCache: jest.fn() })) | |
describe("beforeEach", () => { | |
afterEach(() => { | |
mockModule.bustCache.mockClear() | |
}) | |
it("busts the cache when going to /user", () => { | |
const to = { | |
matched: [{ meta: { shouldBustCache: true } }] | |
} | |
const next = jest.fn() | |
beforeEach(to, undefined, next) | |
expect(mockModule.bustCache).toHaveBeenCalled() | |
expect(next).toHaveBeenCalled() | |
}) | |
it("busts the cache when going to /user", () => { | |
const to = { | |
matched: [{ meta: { shouldBustCache: false } }] | |
} | |
const next = jest.fn() | |
beforeEach(to, undefined, next) | |
expect(mockModule.bustCache).not.toHaveBeenCalled() | |
expect(next).toHaveBeenCalled() | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment