Skip to content

Commit 4829a15

Browse files
Add tests
1 parent 5db0ccf commit 4829a15

14 files changed

+195
-18
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = {
1616
'vite.build.config.ts',
1717
'vite.config.ts',
1818
'*.bk.vue',
19+
'*.spec.ts',
1920
],
2021
overrides: [
2122
{

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"prepublishOnly": "npm run build",
2121
"lint": "eslint src/**/*.{ts,vue} --max-warnings 20",
2222
"prepare": "husky install",
23-
"test:unit": "vitest"
23+
"test:dev": "vitest",
24+
"test:all": "vitest --run"
2425
},
2526
"lint-staged": {
2627
"src/**/*.{js,ts,vue}": [

src/plugin/VInlineCheckbox.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
:style="inlineFieldsContainerStyle"
66
>
77
<div
8-
v-if="(!showField && !settings.fieldOnly) || cardField"
8+
v-if="(!showField && !fieldOnly) || cardField"
99
:class="displayContainerClass"
1010
@click="settings.cell ? toggleField() : undefined"
1111
>
@@ -22,12 +22,12 @@
2222
>
2323
<BooleanIcons
2424
v-model="truthyModelValue"
25-
:icon-false="settings.iconFalse"
26-
:icon-false-color="settings.iconFalseColor"
27-
:icon-false-title="settings.iconFalseTitle"
28-
:icon-true="settings.iconTrue"
29-
:icon-true-color="settings.iconTrueColor"
30-
:icon-true-title="settings.iconTrueTitle"
25+
:icon-false="iconFalse"
26+
:icon-false-color="iconFalseColor"
27+
:icon-false-title="iconFalseTitle"
28+
:icon-true="iconTrue"
29+
:icon-true-color="iconTrueColor"
30+
:icon-true-title="iconTrueTitle"
3131
/>
3232
</div>
3333

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import VInlineCheckbox from '../VInlineCheckbox.vue';
2+
import { checkboxProps } from '@/plugin/utils/props';
3+
import { createVuetify } from 'vuetify';
4+
import { describe, it, expect } from 'vitest';
5+
import { mount } from '@vue/test-utils';
6+
7+
8+
const vuetify = createVuetify();
9+
10+
const componentProps = Object.assign(checkboxProps, {
11+
cardProps: {},
12+
item: undefined,
13+
modelValue: undefined,
14+
required: false,
15+
});
16+
17+
describe('VInlineCheckbox', () => {
18+
const wrapper = mount(VInlineCheckbox, {
19+
global: {
20+
plugins: [vuetify],
21+
},
22+
});
23+
24+
it('testing default component props', () => {
25+
const returnedProps = wrapper.getComponent(VInlineCheckbox).props();
26+
27+
expect(returnedProps).toEqual(componentProps);
28+
});
29+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import VInlineSelect from '../VInlineSelect.vue';
2+
import { createVuetify } from 'vuetify';
3+
import { describe, it, expect } from 'vitest';
4+
import { mount } from '@vue/test-utils';
5+
import { selectProps } from '@/plugin/utils/props';
6+
7+
8+
const vuetify = createVuetify();
9+
10+
const componentProps = Object.assign(selectProps, {
11+
cardProps: {},
12+
items: [],
13+
required: false,
14+
});
15+
16+
describe('VInlineSelect', () => {
17+
const wrapper = mount(VInlineSelect, {
18+
global: {
19+
plugins: [vuetify],
20+
},
21+
});
22+
23+
it('testing default component props', () => {
24+
const returnedProps = wrapper.getComponent(VInlineSelect).props();
25+
26+
expect(returnedProps).toEqual(componentProps);
27+
});
28+
});
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import VInlineSwitch from '../VInlineSwitch.vue';
2+
import { createVuetify } from 'vuetify';
3+
import { describe, it, expect } from 'vitest';
4+
import { mount } from '@vue/test-utils';
5+
import { switchProps } from '@/plugin/utils/props';
6+
7+
8+
const vuetify = createVuetify();
9+
10+
const componentProps = Object.assign(switchProps, {
11+
cardProps: {},
12+
item: undefined,
13+
modelValue: undefined,
14+
required: false,
15+
});
16+
17+
describe('VInlineSwitch', () => {
18+
const wrapper = mount(VInlineSwitch, {
19+
global: {
20+
plugins: [vuetify],
21+
},
22+
});
23+
24+
it('testing default component props', () => {
25+
const returnedProps = wrapper.getComponent(VInlineSwitch).props();
26+
27+
expect(returnedProps).toEqual(componentProps);
28+
});
29+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import VInlineTextField from '../VInlineTextField.vue';
2+
import { createVuetify } from 'vuetify';
3+
import { describe, it, expect } from 'vitest';
4+
import { mount } from '@vue/test-utils';
5+
import { textFieldProps } from '@/plugin/utils/props';
6+
7+
8+
const vuetify = createVuetify();
9+
10+
const componentProps = Object.assign(textFieldProps, {
11+
cardProps: {},
12+
required: false,
13+
});
14+
15+
describe('VInlineTextField', () => {
16+
const wrapper = mount(VInlineTextField, {
17+
global: {
18+
plugins: [vuetify],
19+
},
20+
});
21+
22+
it('testing default component props', () => {
23+
const returnedProps = wrapper.getComponent(VInlineTextField).props();
24+
25+
expect(returnedProps).toEqual(componentProps);
26+
});
27+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import VInlineTextarea from '../VInlineTextarea.vue';
2+
import { createVuetify } from 'vuetify';
3+
import { describe, it, expect } from 'vitest';
4+
import { mount } from '@vue/test-utils';
5+
import { textareaProps } from '@/plugin/utils/props';
6+
7+
8+
const vuetify = createVuetify();
9+
10+
const componentProps = Object.assign(textareaProps, {
11+
cardProps: {},
12+
required: false,
13+
});
14+
15+
describe('VInlineTextarea', () => {
16+
const wrapper = mount(VInlineTextarea, {
17+
global: {
18+
plugins: [vuetify],
19+
},
20+
});
21+
22+
it('testing default component props', () => {
23+
const returnedProps = wrapper.getComponent(VInlineTextarea).props();
24+
25+
expect(returnedProps).toEqual(componentProps);
26+
});
27+
});

src/plugin/__tests__/index.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
// Utilities
21
import { describe, it, expect } from 'vitest';
3-
// import { mount } from '@vue/test-utils';
42
import { createVInlineFields } from '@/plugin';
53

4+
65
describe('framework', () => {
76
describe('install', () => {
87
it('should return install function', () => {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { createVuetify } from 'vuetify';
3+
import defaultThemes from '@/plugins/theme';
4+
import { useGetColor } from '@/plugin/composables/colors';
5+
6+
7+
describe('Colors Composable', () => {
8+
const vuetify = createVuetify({
9+
theme: {
10+
defaultTheme: 'light',
11+
themes: {
12+
...defaultThemes,
13+
},
14+
},
15+
});
16+
17+
const { theme } = vuetify;
18+
const hslRed = 'hsl(0 100% 50% / 100%)';
19+
20+
const checkColors = [
21+
'error',
22+
'red',
23+
'#f00',
24+
'rgb(255, 0, 0)',
25+
'rgba(255, 0, 0, 100)',
26+
];
27+
28+
describe('useGetColor', () => {
29+
checkColors.forEach((color) => {
30+
it(`should return HSLA using color string "${color}"`, () => {
31+
const responseColor = useGetColor(color, theme);
32+
33+
expect(responseColor).toBe(hslRed);
34+
});
35+
});
36+
});
37+
});

0 commit comments

Comments
 (0)