Skip to content

Commit 9bbe64c

Browse files
Fixing tests
1 parent 5575d48 commit 9bbe64c

File tree

5 files changed

+38
-16
lines changed

5 files changed

+38
-16
lines changed

Diff for: src/plugin/components/VInlineAutocomplete/__tests__/VInlineAutocomplete.spec.ts

+14-12
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@ import { selectProps } from '../../../utils/props';
88
const vuetify = createVuetify();
99

1010
const componentProps = Object.assign(selectProps, {
11-
cardProps: {},
12-
items: [],
13-
// isRequired: false,
11+
autoSelectFirst: false,
12+
cardProps: {},
13+
items: [],
14+
menuIcon: '$dropdown',
15+
rules: [],
1416
});
1517

1618
describe('VInlineSelect', () => {
17-
const wrapper = mount(VInlineAutocomplete, {
18-
global: {
19-
plugins: [vuetify],
20-
},
21-
});
19+
const wrapper = mount(VInlineAutocomplete, {
20+
global: {
21+
plugins: [vuetify],
22+
},
23+
});
2224

23-
it('testing default component props', () => {
24-
const returnedProps = wrapper.getComponent(VInlineAutocomplete).props();
25+
it('testing default component props', () => {
26+
const returnedProps = wrapper.getComponent(VInlineAutocomplete).props();
2527

26-
expect(returnedProps).toEqual(componentProps);
27-
});
28+
expect(returnedProps).toEqual(componentProps);
29+
});
2830
});

Diff for: src/plugin/components/common/__tests__/common.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import SaveFieldButtons from '../SaveFieldButtons.vue';
55
import { createVuetify } from 'vuetify';
66
import { describe, it, expect } from 'vitest';
77
import { mount } from '@vue/test-utils';
8-
import { selectProps } from '@/plugin/utils/props';
8+
import { selectProps } from '../../../utils/props';
99

1010

1111
const vuetify = createVuetify();

Diff for: src/plugin/composables/__tests__/colors.test.ts

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect } from 'vitest';
1+
import { describe, it, expect, vi } from 'vitest';
22
import { createVuetify } from 'vuetify';
33
import { useGetColor } from '../colors';
44
import defaultThemes from '../../../plugins/theme';
@@ -34,6 +34,9 @@ describe('Colors Composable', () => {
3434
});
3535
});
3636

37+
// console.warn tests //
38+
const logSpy = vi.spyOn(console, 'warn').mockImplementation(() => undefined);
39+
3740
it('should return HSLA default value if color not found', () => {
3841
const responseColor = useGetColor('foobar', theme);
3942

@@ -45,5 +48,23 @@ describe('Colors Composable', () => {
4548

4649
expect(responseColor).toMatchInlineSnapshot(`"rgb(var(--v-theme-primary))"`);
4750
});
51+
52+
it('should console warn when color prop "foobar" doesn\'t exist in colors', () => {
53+
logSpy.mockReset();
54+
55+
useGetColor('foobar', theme);
56+
57+
expect(logSpy).toHaveBeenCalled();
58+
expect(logSpy).toHaveBeenCalledTimes(1);
59+
});
60+
61+
it('should console warn when color prop "--v-foobar" doesn\'t exist in colors', () => {
62+
logSpy.mockReset();
63+
64+
useGetColor('--v-foobar', theme);
65+
66+
expect(logSpy).toHaveBeenCalled();
67+
expect(logSpy).toHaveBeenCalledTimes(1);
68+
});
4869
});
4970
});

Diff for: src/plugin/composables/colors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function convertToHSL(color: string): string {
9393
if (max === null || !min === null || isNaN(max) || isNaN(min)) {
9494
const defaultColor = '0 0% 100% / 12%';
9595

96-
console.warn(`[VuetifyInlineFields: The "color" prop value using "${newColor}" doesn't exist. Using the value "hsl(${defaultColor})" in it's place.`);
96+
console.warn(`[VuetifyInlineFields]: The "color" prop value using "${newColor}" doesn't exist. Using the value "hsl(${defaultColor})" in it's place.`);
9797
return defaultColor;
9898
}
9999

Diff for: vitest.config.mts

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export default mergeConfig(
1010
exclude: [
1111
...configDefaults.exclude,
1212
'./src/plugin/components/common/__tests__/common.test.ts',
13-
'./src/plugin/components/VInlineAutocomplete'
1413
],
1514
root: fileURLToPath(new URL('./', import.meta.url)),
1615
server: {

0 commit comments

Comments
 (0)