Skip to content

Commit 32409f2

Browse files
Update test
1 parent 2d6a66e commit 32409f2

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/plugin/composables/__tests__/levelColors.test.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { describe, it, expect } from 'vitest';
1+
import {
2+
describe,
3+
it,
4+
expect,
5+
vi,
6+
} from 'vitest';
27
import {
38
getSingleColor,
49
useGetLevelColors,
@@ -37,13 +42,36 @@ describe('Level Colors Composable', () => {
3742

3843
it('should return a non theme color option as default HSL color value', () => {
3944
const color = getSingleColor('foobar', theme);
45+
4046
expect(color).toMatchInlineSnapshot(`"hsl(0 0% 100% / 12%)"`);
4147
});
4248

4349
it('should return a non theme variable as default HSL color value', () => {
4450
const color = getSingleColor('--v-foobar', theme);
51+
4552
expect(color).toMatchInlineSnapshot(`"hsl(0 0% 100% / 12%)"`);
4653
});
54+
55+
// console.warn tests //
56+
const logSpy = vi.spyOn(console, 'warn').mockImplementation(() => undefined);
57+
58+
it('should console warn when color prop "foobar" doesn\'t exist in colors', () => {
59+
logSpy.mockReset();
60+
61+
getSingleColor('foobar', theme);
62+
63+
expect(logSpy).toHaveBeenCalled();
64+
expect(logSpy).toHaveBeenCalledTimes(1);
65+
});
66+
67+
it('should console warn when color prop "--v-foobar" doesn\'t exist in colors', () => {
68+
logSpy.mockReset();
69+
70+
getSingleColor('--v-foobar', theme);
71+
72+
expect(logSpy).toHaveBeenCalled();
73+
expect(logSpy).toHaveBeenCalledTimes(1);
74+
});
4775
});
4876

4977
describe('useGetLevelColors', () => {

0 commit comments

Comments
 (0)