@dcrackel/hematournamentui 1.0.22 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +18 -18
- package/.gitattributes +2 -2
- package/.prettierignore +1 -1
- package/.storybook/main.js +18 -18
- package/.storybook/mockRoutes.js +9 -9
- package/.storybook/preview-head.html +3 -3
- package/.storybook/preview.js +17 -17
- package/LICENSE +21 -21
- package/README.md +83 -83
- package/dist/HemaTouranmentUI-lib.es.js +7060 -6920
- package/dist/HemaTouranmentUI-lib.umd.js +27 -27
- package/dist/style.css +1 -1
- package/index.html +12 -12
- package/package.json +58 -58
- package/postcss.config.js +6 -6
- package/prettier.config.js +10 -10
- package/src/index.js +25 -25
- package/src/main.js +2 -2
- package/src/mocks/fileMock.js +1 -1
- package/src/mocks/tournamentMock.js +34 -34
- package/src/stories/Atoms/Icon/BaseIcon.stories.js +54 -54
- package/src/stories/Atoms/Icon/BaseIcon.test.js +91 -91
- package/src/stories/Atoms/Icon/BaseIcon.vue +48 -48
- package/src/stories/Atoms/Input/BaseInput.stories.js +29 -28
- package/src/stories/Atoms/Input/BaseInput.test.js +87 -87
- package/src/stories/Atoms/Input/BaseInput.vue +85 -73
- package/src/stories/Atoms/RadioGroup/BaseRadioGroup.stories.js +31 -31
- package/src/stories/Atoms/RadioGroup/BaseRadioGroup.test.js +49 -49
- package/src/stories/Atoms/RadioGroup/BaseRadioGroup.vue +49 -49
- package/src/stories/Atoms/Tag/BaseTag.stories.js +29 -29
- package/src/stories/Atoms/Tag/BaseTag.test.js +42 -42
- package/src/stories/Atoms/Tag/BaseTag.vue +57 -57
- package/src/stories/Atoms/Text/BaseText.stories.js +77 -77
- package/src/stories/Atoms/Text/BaseText.test.js +172 -172
- package/src/stories/Atoms/Text/BaseText.vue +170 -170
- package/src/stories/Configure.mdx +320 -320
- package/src/stories/Molecules/Breadcrumb/Admin/Breadcrumb.stories.js +41 -41
- package/src/stories/Molecules/Breadcrumb/Admin/Breadcrumb.test.js +80 -80
- package/src/stories/Molecules/Breadcrumb/Admin/Breadcrumb.vue +31 -31
- package/src/stories/Molecules/Button/BaseButton.stories.js +93 -76
- package/src/stories/Molecules/Button/BaseButton.test.js +147 -147
- package/src/stories/Molecules/Button/BaseButton.vue +116 -125
- package/src/stories/Molecules/Cards/Detail/TournamentCardDetail.stories.js +33 -33
- package/src/stories/Molecules/Cards/Detail/TournamentCardDetail.vue +38 -38
- package/src/stories/Molecules/Cards/Header/TournamentCardHeader.stories.js +48 -48
- package/src/stories/Molecules/Cards/Header/TournamentCardHeader.vue +40 -40
- package/src/stories/Molecules/Filters/FilterAndSortBar/FilterAndSortBar.stories.js +36 -36
- package/src/stories/Molecules/Filters/FilterAndSortBar/FilterAndSortBar.vue +49 -49
- package/src/stories/Molecules/Filters/FilterUpcomingPast/FilterUpcomingPast.stories.js +32 -32
- package/src/stories/Molecules/Filters/FilterUpcomingPast/FilterUpcomingPast.vue +46 -46
- package/src/stories/Organisms/AddressAutocomplete/AddressAutocomplete.stories.js +25 -25
- package/src/stories/Organisms/AddressAutocomplete/AddressAutocomplete.vue +51 -51
- package/src/stories/Organisms/DatePicker/DatePicker.stories.js +25 -25
- package/src/stories/Organisms/DatePicker/DatePicker.vue +62 -62
- package/src/stories/Organisms/DropDown/DropDownMenu.stories.js +34 -34
- package/src/stories/Organisms/DropDown/DropDownMenu.vue +51 -51
- package/src/stories/Organisms/Grid/GridContainer.stories.js +47 -47
- package/src/stories/Organisms/Grid/GridContainer.vue +108 -108
- package/src/stories/Organisms/ImageCropper/ImageCropper.stories.js +28 -28
- package/src/stories/Organisms/ImageCropper/ImageCropper.vue +86 -86
- package/src/stories/Organisms/TextBoxEditor/TextBoxEditor.stories.js +28 -28
- package/src/stories/Organisms/TextBoxEditor/TextBoxEditor.vue +97 -97
- package/src/stories/Organisms/TournamentCard/TournamentCard.stories.js +37 -37
- package/src/stories/Organisms/TournamentCard/TournamentCard.vue +35 -35
- package/src/stories/Templates/Forms/AddTournamentPageOne/AddTournamentPageOne.stories.js +25 -25
- package/src/stories/Templates/Forms/AddTournamentPageOne/AddTournamentPageOne.vue +138 -137
- package/src/stories/Templates/Forms/AddTournamentPageTwo/AddTournamentPageTwo.stories.js +35 -0
- package/src/stories/Templates/Forms/AddTournamentPageTwo/AddTournamentPageTwo.vue +121 -0
- package/src/stories/Templates/Menu/Admin/AdminLeftMenu.stories.js +28 -28
- package/src/stories/Templates/Menu/Admin/AdminLeftMenu.vue +57 -57
- package/tailwind/output.css +1247 -1212
- package/tailwind/tailwind.css +4 -4
- package/tailwind.config.js +50 -50
- package/vite.config.js +23 -23
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
-
import { mount } from '@vue/test-utils';
|
|
3
|
-
import BaseIcon from './BaseIcon.vue';
|
|
4
|
-
|
|
5
|
-
describe('BaseIcon', () => {
|
|
6
|
-
// Mocking console.warn
|
|
7
|
-
const originalWarn = console.warn;
|
|
8
|
-
let consoleOutput = [];
|
|
9
|
-
const mockedWarn = output => consoleOutput.push(output);
|
|
10
|
-
console.warn = mockedWarn;
|
|
11
|
-
|
|
12
|
-
afterEach(() => {
|
|
13
|
-
console.warn = originalWarn;
|
|
14
|
-
consoleOutput = [];
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('renders without errors', () => {
|
|
18
|
-
const wrapper = mount(BaseIcon, {
|
|
19
|
-
props: { iconName: 'fa-icons' }
|
|
20
|
-
});
|
|
21
|
-
expect(wrapper.exists()).toBeTruthy();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('default values are correctly applied when props are not provided', () => {
|
|
25
|
-
const wrapper = mount(BaseIcon, {
|
|
26
|
-
props: {}
|
|
27
|
-
});
|
|
28
|
-
expect(wrapper.classes()).toContain('fa-solid');
|
|
29
|
-
expect(wrapper.classes()).toContain('fa-face-smile');
|
|
30
|
-
expect(wrapper.classes()).toContain('text-sm');
|
|
31
|
-
expect(wrapper.classes()).toContain('text-primary');
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it('applies default props correctly', () => {
|
|
35
|
-
const wrapper = mount(BaseIcon, {
|
|
36
|
-
props: { iconName: 'fa-icons' }
|
|
37
|
-
});
|
|
38
|
-
expect(wrapper.classes()).toContain('fa-solid');
|
|
39
|
-
expect(wrapper.classes()).toContain('text-sm');
|
|
40
|
-
expect(wrapper.classes()).toContain('text-primary');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('computes classes based on props', () => {
|
|
44
|
-
const wrapper = mount(BaseIcon, {
|
|
45
|
-
props: {
|
|
46
|
-
iconName: 'fa-icons',
|
|
47
|
-
style: 'fa-regular',
|
|
48
|
-
size: 'lg',
|
|
49
|
-
color: 'secondary'
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
expect(wrapper.classes()).toContain('fa-regular');
|
|
53
|
-
expect(wrapper.classes()).toContain('fa-icons');
|
|
54
|
-
expect(wrapper.classes()).toContain('text-lg');
|
|
55
|
-
expect(wrapper.classes()).toContain('text-secondary');
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('validates style prop correctly with valid value', () => {
|
|
59
|
-
mount(BaseIcon, {
|
|
60
|
-
props: { style: 'fa-solid' }
|
|
61
|
-
});
|
|
62
|
-
expect(consoleOutput).toHaveLength(0); // No warnings should be emitted
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('emits a warning with invalid style prop value', () => {
|
|
66
|
-
mount(BaseIcon, {
|
|
67
|
-
props: { style: 'invalid-style' }
|
|
68
|
-
});
|
|
69
|
-
const expectedWarning = '[Vue warn]: Invalid prop: custom validator check failed for prop "style".';
|
|
70
|
-
const styleWarning = consoleOutput.find(msg => msg.includes(expectedWarning));
|
|
71
|
-
expect(styleWarning).toBeFalsy(); // Check if specific warning is found
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('validates style size correctly with valid value', () => {
|
|
75
|
-
mount(BaseIcon, {
|
|
76
|
-
props: { size: 'sm' }
|
|
77
|
-
});
|
|
78
|
-
expect(consoleOutput).toHaveLength(0); // No warnings should be emitted
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('emits a warning with invalid size prop value', () => {
|
|
82
|
-
mount(BaseIcon, {
|
|
83
|
-
props: { size: 'invalid-size' }
|
|
84
|
-
});
|
|
85
|
-
const expectedWarning = '[Vue warn]: Invalid prop: custom validator check failed for prop "size".';
|
|
86
|
-
const styleWarning = consoleOutput.find(msg => msg.includes(expectedWarning));
|
|
87
|
-
expect(styleWarning).toBeFalsy(); // Check if specific warning is found
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
});
|
|
91
|
-
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import { mount } from '@vue/test-utils';
|
|
3
|
+
import BaseIcon from './BaseIcon.vue';
|
|
4
|
+
|
|
5
|
+
describe('BaseIcon', () => {
|
|
6
|
+
// Mocking console.warn
|
|
7
|
+
const originalWarn = console.warn;
|
|
8
|
+
let consoleOutput = [];
|
|
9
|
+
const mockedWarn = output => consoleOutput.push(output);
|
|
10
|
+
console.warn = mockedWarn;
|
|
11
|
+
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
console.warn = originalWarn;
|
|
14
|
+
consoleOutput = [];
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('renders without errors', () => {
|
|
18
|
+
const wrapper = mount(BaseIcon, {
|
|
19
|
+
props: { iconName: 'fa-icons' }
|
|
20
|
+
});
|
|
21
|
+
expect(wrapper.exists()).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('default values are correctly applied when props are not provided', () => {
|
|
25
|
+
const wrapper = mount(BaseIcon, {
|
|
26
|
+
props: {}
|
|
27
|
+
});
|
|
28
|
+
expect(wrapper.classes()).toContain('fa-solid');
|
|
29
|
+
expect(wrapper.classes()).toContain('fa-face-smile');
|
|
30
|
+
expect(wrapper.classes()).toContain('text-sm');
|
|
31
|
+
expect(wrapper.classes()).toContain('text-primary');
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('applies default props correctly', () => {
|
|
35
|
+
const wrapper = mount(BaseIcon, {
|
|
36
|
+
props: { iconName: 'fa-icons' }
|
|
37
|
+
});
|
|
38
|
+
expect(wrapper.classes()).toContain('fa-solid');
|
|
39
|
+
expect(wrapper.classes()).toContain('text-sm');
|
|
40
|
+
expect(wrapper.classes()).toContain('text-primary');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('computes classes based on props', () => {
|
|
44
|
+
const wrapper = mount(BaseIcon, {
|
|
45
|
+
props: {
|
|
46
|
+
iconName: 'fa-icons',
|
|
47
|
+
style: 'fa-regular',
|
|
48
|
+
size: 'lg',
|
|
49
|
+
color: 'secondary'
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
expect(wrapper.classes()).toContain('fa-regular');
|
|
53
|
+
expect(wrapper.classes()).toContain('fa-icons');
|
|
54
|
+
expect(wrapper.classes()).toContain('text-lg');
|
|
55
|
+
expect(wrapper.classes()).toContain('text-secondary');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('validates style prop correctly with valid value', () => {
|
|
59
|
+
mount(BaseIcon, {
|
|
60
|
+
props: { style: 'fa-solid' }
|
|
61
|
+
});
|
|
62
|
+
expect(consoleOutput).toHaveLength(0); // No warnings should be emitted
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('emits a warning with invalid style prop value', () => {
|
|
66
|
+
mount(BaseIcon, {
|
|
67
|
+
props: { style: 'invalid-style' }
|
|
68
|
+
});
|
|
69
|
+
const expectedWarning = '[Vue warn]: Invalid prop: custom validator check failed for prop "style".';
|
|
70
|
+
const styleWarning = consoleOutput.find(msg => msg.includes(expectedWarning));
|
|
71
|
+
expect(styleWarning).toBeFalsy(); // Check if specific warning is found
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('validates style size correctly with valid value', () => {
|
|
75
|
+
mount(BaseIcon, {
|
|
76
|
+
props: { size: 'sm' }
|
|
77
|
+
});
|
|
78
|
+
expect(consoleOutput).toHaveLength(0); // No warnings should be emitted
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('emits a warning with invalid size prop value', () => {
|
|
82
|
+
mount(BaseIcon, {
|
|
83
|
+
props: { size: 'invalid-size' }
|
|
84
|
+
});
|
|
85
|
+
const expectedWarning = '[Vue warn]: Invalid prop: custom validator check failed for prop "size".';
|
|
86
|
+
const styleWarning = consoleOutput.find(msg => msg.includes(expectedWarning));
|
|
87
|
+
expect(styleWarning).toBeFalsy(); // Check if specific warning is found
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
});
|
|
91
|
+
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<i :class="computedIconClass"></i>
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script>
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
name: 'BaseIcon',
|
|
9
|
-
props: {
|
|
10
|
-
iconName: {
|
|
11
|
-
type: String,
|
|
12
|
-
default: 'fa-face-smile',
|
|
13
|
-
required: true
|
|
14
|
-
},
|
|
15
|
-
style: {
|
|
16
|
-
type: String,
|
|
17
|
-
default: 'fa-solid',
|
|
18
|
-
validator: function (value) {
|
|
19
|
-
return ['fa-solid', 'fa-regular', 'fa-solid', 'fa-light', 'fa-thing'].indexOf(value) !== -1;
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
size: {
|
|
23
|
-
type: String,
|
|
24
|
-
validator: function (value) {
|
|
25
|
-
return ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl'].indexOf(value) !== -1;
|
|
26
|
-
},
|
|
27
|
-
default: 'sm'
|
|
28
|
-
},
|
|
29
|
-
color: {
|
|
30
|
-
type: String,
|
|
31
|
-
default: 'primary'
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
computed: {
|
|
35
|
-
computedIconClass() {
|
|
36
|
-
return [
|
|
37
|
-
this.style,
|
|
38
|
-
this.iconName,
|
|
39
|
-
`text-${this.size}`,
|
|
40
|
-
this.colorClass
|
|
41
|
-
];
|
|
42
|
-
},
|
|
43
|
-
colorClass() {
|
|
44
|
-
return `text-${this.color}`;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<i :class="computedIconClass"></i>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
name: 'BaseIcon',
|
|
9
|
+
props: {
|
|
10
|
+
iconName: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: 'fa-face-smile',
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
style: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: 'fa-solid',
|
|
18
|
+
validator: function (value) {
|
|
19
|
+
return ['fa-solid', 'fa-regular', 'fa-solid', 'fa-light', 'fa-thing'].indexOf(value) !== -1;
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
size: {
|
|
23
|
+
type: String,
|
|
24
|
+
validator: function (value) {
|
|
25
|
+
return ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl'].indexOf(value) !== -1;
|
|
26
|
+
},
|
|
27
|
+
default: 'sm'
|
|
28
|
+
},
|
|
29
|
+
color: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: 'primary'
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
computed: {
|
|
35
|
+
computedIconClass() {
|
|
36
|
+
return [
|
|
37
|
+
this.style,
|
|
38
|
+
this.iconName,
|
|
39
|
+
`text-${this.size}`,
|
|
40
|
+
this.colorClass
|
|
41
|
+
];
|
|
42
|
+
},
|
|
43
|
+
colorClass() {
|
|
44
|
+
return `text-${this.color}`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
</script>
|
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import BaseInput from './BaseInput.vue';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: 'Atoms/BaseInput',
|
|
5
|
-
component: BaseInput,
|
|
6
|
-
tags: ['autodocs'],
|
|
7
|
-
argTypes: {
|
|
8
|
-
placeholder: {
|
|
9
|
-
value: {
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
1
|
+
import BaseInput from './BaseInput.vue';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Atoms/BaseInput',
|
|
5
|
+
component: BaseInput,
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
argTypes: {
|
|
8
|
+
placeholder: {control: 'text'},
|
|
9
|
+
value: {control: 'text'},
|
|
10
|
+
icon: {control: ''}
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const Template = args => ({
|
|
15
|
+
components: {BaseInput},
|
|
16
|
+
props: Object.keys(args),
|
|
17
|
+
methods: {
|
|
18
|
+
onValueUpdate(newValue) {
|
|
19
|
+
console.log('Value updated:', newValue);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const Default = {
|
|
25
|
+
args: {
|
|
26
|
+
placeholder: 'Enter text...',
|
|
27
|
+
value: ''
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import BaseInput from './BaseInput.vue';
|
|
2
|
-
import { mount } from "@vue/test-utils";
|
|
3
|
-
import { describe, expect, test, it } from "vitest";
|
|
4
|
-
|
|
5
|
-
describe('BaseInput.vue', () => {
|
|
6
|
-
|
|
7
|
-
it('renders with default props', () => {
|
|
8
|
-
const wrapper = mount(BaseInput);
|
|
9
|
-
const inputElement = wrapper.find('input');
|
|
10
|
-
|
|
11
|
-
expect(inputElement.attributes('placeholder')).toBe('');
|
|
12
|
-
expect(wrapper.vm.internalValue).toBe('');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('initializes with the correct value prop', () => {
|
|
16
|
-
const initialValue = 'Hello, World!';
|
|
17
|
-
const wrapper = mount(BaseInput, {
|
|
18
|
-
props: {
|
|
19
|
-
value: initialValue
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
expect(wrapper.vm.internalValue).toBe(initialValue);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('updates internalValue when value prop changes', async () => {
|
|
27
|
-
const wrapper = mount(BaseInput);
|
|
28
|
-
await wrapper.setProps({ value: 'New Value' });
|
|
29
|
-
|
|
30
|
-
expect(wrapper.vm.internalValue).toBe('New Value');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('emits update:value with a delay upon input', async () => {
|
|
34
|
-
const wrapper = mount(BaseInput);
|
|
35
|
-
const inputElement = wrapper.find('input');
|
|
36
|
-
|
|
37
|
-
await inputElement.setValue('Test Input');
|
|
38
|
-
|
|
39
|
-
// TODO: Handle timer-related functionality with vitest
|
|
40
|
-
await new Promise(resolve => setTimeout(resolve, 350));
|
|
41
|
-
|
|
42
|
-
expect(wrapper.emitted('update:value')).toBeTruthy();
|
|
43
|
-
expect(wrapper.emitted('update:value')[0]).toEqual(['Test Input']);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('applies formInput styles when type is formInput', () => {
|
|
47
|
-
const wrapper = mount(BaseInput, {
|
|
48
|
-
props: {
|
|
49
|
-
type: 'formInput',
|
|
50
|
-
invalid: false
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
const inputElement = wrapper.find('input');
|
|
54
|
-
expect(inputElement.classes()).toContain('border');
|
|
55
|
-
expect(inputElement.classes()).toContain('rounded-lg');
|
|
56
|
-
expect(inputElement.classes()).toContain('text-secondary');
|
|
57
|
-
expect(inputElement.classes()).toContain('placeholder:text-xs');
|
|
58
|
-
expect(inputElement.classes()).toContain('text-sm');
|
|
59
|
-
expect(inputElement.classes()).toContain('p-2');
|
|
60
|
-
expect(inputElement.classes()).toContain('w-full');
|
|
61
|
-
expect(inputElement.classes()).toContain('border-dropdownSelect');
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('applies border-alarm class when invalid is true', () => {
|
|
65
|
-
const wrapper = mount(BaseInput, {
|
|
66
|
-
props: {
|
|
67
|
-
type: 'formInput',
|
|
68
|
-
invalid: true
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
const inputElement = wrapper.find('input');
|
|
72
|
-
expect(inputElement.classes()).toContain('border-alarm');
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('does not apply border-alarm class when invalid is false', () => {
|
|
76
|
-
const wrapper = mount(BaseInput, {
|
|
77
|
-
props: {
|
|
78
|
-
type: 'formInput',
|
|
79
|
-
invalid: false
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
const inputElement = wrapper.find('input');
|
|
83
|
-
expect(inputElement.classes()).not.toContain('border-alarm');
|
|
84
|
-
expect(inputElement.classes()).toContain('border-dropdownSelect');
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
});
|
|
1
|
+
import BaseInput from './BaseInput.vue';
|
|
2
|
+
import { mount } from "@vue/test-utils";
|
|
3
|
+
import { describe, expect, test, it } from "vitest";
|
|
4
|
+
|
|
5
|
+
describe('BaseInput.vue', () => {
|
|
6
|
+
|
|
7
|
+
it('renders with default props', () => {
|
|
8
|
+
const wrapper = mount(BaseInput);
|
|
9
|
+
const inputElement = wrapper.find('input');
|
|
10
|
+
|
|
11
|
+
expect(inputElement.attributes('placeholder')).toBe('');
|
|
12
|
+
expect(wrapper.vm.internalValue).toBe('');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('initializes with the correct value prop', () => {
|
|
16
|
+
const initialValue = 'Hello, World!';
|
|
17
|
+
const wrapper = mount(BaseInput, {
|
|
18
|
+
props: {
|
|
19
|
+
value: initialValue
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
expect(wrapper.vm.internalValue).toBe(initialValue);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('updates internalValue when value prop changes', async () => {
|
|
27
|
+
const wrapper = mount(BaseInput);
|
|
28
|
+
await wrapper.setProps({ value: 'New Value' });
|
|
29
|
+
|
|
30
|
+
expect(wrapper.vm.internalValue).toBe('New Value');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('emits update:value with a delay upon input', async () => {
|
|
34
|
+
const wrapper = mount(BaseInput);
|
|
35
|
+
const inputElement = wrapper.find('input');
|
|
36
|
+
|
|
37
|
+
await inputElement.setValue('Test Input');
|
|
38
|
+
|
|
39
|
+
// TODO: Handle timer-related functionality with vitest
|
|
40
|
+
await new Promise(resolve => setTimeout(resolve, 350));
|
|
41
|
+
|
|
42
|
+
expect(wrapper.emitted('update:value')).toBeTruthy();
|
|
43
|
+
expect(wrapper.emitted('update:value')[0]).toEqual(['Test Input']);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('applies formInput styles when type is formInput', () => {
|
|
47
|
+
const wrapper = mount(BaseInput, {
|
|
48
|
+
props: {
|
|
49
|
+
type: 'formInput',
|
|
50
|
+
invalid: false
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const inputElement = wrapper.find('input');
|
|
54
|
+
expect(inputElement.classes()).toContain('border');
|
|
55
|
+
expect(inputElement.classes()).toContain('rounded-lg');
|
|
56
|
+
expect(inputElement.classes()).toContain('text-secondary');
|
|
57
|
+
expect(inputElement.classes()).toContain('placeholder:text-xs');
|
|
58
|
+
expect(inputElement.classes()).toContain('text-sm');
|
|
59
|
+
expect(inputElement.classes()).toContain('p-2');
|
|
60
|
+
expect(inputElement.classes()).toContain('w-full');
|
|
61
|
+
expect(inputElement.classes()).toContain('border-dropdownSelect');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('applies border-alarm class when invalid is true', () => {
|
|
65
|
+
const wrapper = mount(BaseInput, {
|
|
66
|
+
props: {
|
|
67
|
+
type: 'formInput',
|
|
68
|
+
invalid: true
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
const inputElement = wrapper.find('input');
|
|
72
|
+
expect(inputElement.classes()).toContain('border-alarm');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('does not apply border-alarm class when invalid is false', () => {
|
|
76
|
+
const wrapper = mount(BaseInput, {
|
|
77
|
+
props: {
|
|
78
|
+
type: 'formInput',
|
|
79
|
+
invalid: false
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const inputElement = wrapper.find('input');
|
|
83
|
+
expect(inputElement.classes()).not.toContain('border-alarm');
|
|
84
|
+
expect(inputElement.classes()).toContain('border-dropdownSelect');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
});
|