-
Notifications
You must be signed in to change notification settings - Fork 231
/
Copy pathuseColorModeImages.spec.ts
38 lines (31 loc) · 1.09 KB
/
useColorModeImages.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// SPDX-License-Identifier: AGPL-3.0-or-later
import { mockNuxtImport } from "@nuxt/test-utils/runtime";
import useColorModeImages from "@/composables/useColorModeImages";
mockNuxtImport("useColorMode", () => useColorModeMock);
describe("useColorModeImage", () => {
it("adds _light to image path", () => {
useColorModeMock.mockImplementation(() => ({
preference: "light",
value: "light",
}));
const getImage = useColorModeImages();
expect(getImage("/path/to/image", ".png")).toEqual(
"/path/to/image_light.png"
);
});
it("adds _dark to image path", () => {
// window.useColorModeMock.mockImplementation(() => ({ value: 'dark' }));
const getImage = useColorModeImages();
expect(getImage("/path/to/image", ".png")).toEqual(
"/path/to/image_dark.png"
);
});
it("uses .png as default extension", () => {
useColorModeMock.mockImplementation(() => ({
preference: "light",
value: "light",
}));
const getImage = useColorModeImages();
expect(getImage("/path/to/image")).toEqual("/path/to/image_light.png");
});
});