|
1 | | -import { describe, it, expect } from 'vitest'; |
| 1 | +import { |
| 2 | + describe, |
| 3 | + it, |
| 4 | + expect, |
| 5 | + vi, |
| 6 | +} from 'vitest'; |
2 | 7 | import { |
3 | 8 | getSingleColor, |
4 | 9 | useGetLevelColors, |
@@ -37,13 +42,36 @@ describe('Level Colors Composable', () => { |
37 | 42 |
|
38 | 43 | it('should return a non theme color option as default HSL color value', () => { |
39 | 44 | const color = getSingleColor('foobar', theme); |
| 45 | + |
40 | 46 | expect(color).toMatchInlineSnapshot(`"hsl(0 0% 100% / 12%)"`); |
41 | 47 | }); |
42 | 48 |
|
43 | 49 | it('should return a non theme variable as default HSL color value', () => { |
44 | 50 | const color = getSingleColor('--v-foobar', theme); |
| 51 | + |
45 | 52 | expect(color).toMatchInlineSnapshot(`"hsl(0 0% 100% / 12%)"`); |
46 | 53 | }); |
| 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 | + }); |
47 | 75 | }); |
48 | 76 |
|
49 | 77 | describe('useGetLevelColors', () => { |
|
0 commit comments