From 2aa38297ae815faa1f1778bcf89bdfaf09f96a0f Mon Sep 17 00:00:00 2001 From: Creighton Date: Sun, 22 Sep 2024 23:49:05 -0500 Subject: [PATCH] unit tests Signed-off-by: Creighton --- .../javascript/unit/views/AppSidebar.spec.js | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/javascript/unit/views/AppSidebar.spec.js b/tests/javascript/unit/views/AppSidebar.spec.js index 484121f05..6989dcdd0 100644 --- a/tests/javascript/unit/views/AppSidebar.spec.js +++ b/tests/javascript/unit/views/AppSidebar.spec.js @@ -55,4 +55,39 @@ describe('AppSidebar.vue', () => { actual = wrapper.vm.newDueDate expect(actual.getTime()).toBe(newDueDate.getTime()) }) + + it('Task completed date is set correctly', () => { + const wrapper = shallowMount(AppSidebar, { + global: { + plugins: [store, router], + }, + }) + + let actual = wrapper.vm.newCompletedDate + expect(actual).toBe(null) + + const newCompletedDate = new Date('2019-01-01T12:00:00') + wrapper.vm.changeCompletedDate({ task: wrapper.vm.task, value: newCompletedDate }) + + actual = wrapper.vm.newCompletedDate + expect(actual.getTime()).toBe(newCompletedDate.getTime()) + }) + + it('Setting completed date to future is ignored', () => { + const wrapper = shallowMount(AppSidebar, { + global: { + plugins: [store, router], + }, + }) + + let actual = wrapper.vm.newCompletedDate + const expected = new Date('2019-01-01T12:00:00') + expect(actual.getTime()).toBe(expected.getTime()) + + const newCompletedDate = new Date('2020-01-01T12:00:01') + wrapper.vm.changeCompletedDate({ task: wrapper.vm.task, value: newCompletedDate }) + + actual = wrapper.vm.newCompletedDate + expect(actual.getTime()).toBe(expected.getTime()) + }) })