From df1b1205cf4c369c8c38153f8e442f02b71df190 Mon Sep 17 00:00:00 2001 From: provira Date: Thu, 2 Jan 2025 12:16:05 +0100 Subject: [PATCH 1/3] feat: refs #7077 created test for VnInputTime --- .../common/__tests__/VnInputTime.spec.js | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/components/common/__tests__/VnInputTime.spec.js diff --git a/src/components/common/__tests__/VnInputTime.spec.js b/src/components/common/__tests__/VnInputTime.spec.js new file mode 100644 index 000000000..1ecc01cc3 --- /dev/null +++ b/src/components/common/__tests__/VnInputTime.spec.js @@ -0,0 +1,63 @@ +import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest'; +import { createWrapper } from 'app/test/vitest/helper'; +import VnInputTime from 'components/common/VnInputTime.vue'; + +describe('VnInputTime', () => { + let wrapper; + let vm; + + beforeAll(() => { + wrapper = createWrapper(VnInputTime, { + props: { + isOutlined: true, + timeOnly: false, // Initial props values + }, + }); + vm = wrapper.vm; + wrapper = wrapper.wrapper; + }); + + afterEach(() => { + vi.clearAllMocks(); + }); + + it('should return the correct data if isOutlined is true', () => { + expect(vm.isOutlined).toBe(true); + expect(vm.styleAttrs).toEqual({ dense: true, outlined: true, rounded: true }); + }); + + it('should return the formatted data', () => { + expect(vm.dateToTime('2022-01-01T03:23:43')).toBe('03:23'); + }); + + describe('formattedTime', () => { + it('should return the formatted time for a valid ISO date', () => { + vm.model = '2025-01-02T15:45:00'; + expect(vm.formattedTime).toBe('15:45'); + }); + + it('should handle null model value gracefully', () => { + vm.model = null; + expect(vm.formattedTime).toBe(null); + }); + + it('should handle time-only input correctly', async () => { + await wrapper.setProps({ timeOnly: true }); + vm.formattedTime = '14:30'; + expect(vm.model).toBe('14:30'); + }); + + it('should pad short time values correctly', async () => { + await wrapper.setProps({ timeOnly: true }); + vm.formattedTime = '9'; + expect(vm.model).toBe('09:00'); + }); + + it('should not update the model if the value is unchanged', () => { + vm.model = '14:30'; + const previousModel = vm.model; + vm.formattedTime = '14:30'; + expect(vm.model).toBe(previousModel); + }); + }); +}); \ No newline at end of file -- 2.40.1 From 6a88cad90338bf4d370f77d08a68578f126df104 Mon Sep 17 00:00:00 2001 From: provira Date: Wed, 15 Jan 2025 09:55:59 +0100 Subject: [PATCH 2/3] fix: refs #7077 removed unused imports --- src/components/common/VnInputTime.vue | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/common/VnInputTime.vue b/src/components/common/VnInputTime.vue index b4b246618..4147f8976 100644 --- a/src/components/common/VnInputTime.vue +++ b/src/components/common/VnInputTime.vue @@ -1,13 +1,11 @@