From f8035c9777e3f00c8b82fbc130f7406f4efb3397 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 3 Apr 2019 12:39:24 +0200 Subject: [PATCH] fixed calendar front unit tests --- front/core/components/calendar/index.spec.js | 22 ++++++++------------ modules/worker/front/calendar/index.js | 1 - 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/front/core/components/calendar/index.spec.js b/front/core/components/calendar/index.spec.js index 94ba8134a..6a082a236 100644 --- a/front/core/components/calendar/index.spec.js +++ b/front/core/components/calendar/index.spec.js @@ -1,4 +1,4 @@ -fdescribe('Component vnCalendar', () => { +describe('Component vnCalendar', () => { let controller; let $element; @@ -14,12 +14,12 @@ fdescribe('Component vnCalendar', () => { $element.remove(); }); - describe('events() setter', () => { + describe('data() setter', () => { it(`should set an array of events and convert string dates to string object, then call repaint() method`, () => { spyOn(controller, 'repaint'); let currentDate = new Date().toString(); - controller.events = [ + controller.data = [ {dated: currentDate, title: 'Event 1'}, {dated: currentDate, title: 'Event 2'}, ]; @@ -30,8 +30,7 @@ fdescribe('Component vnCalendar', () => { }); describe('addEvent()', () => { - it(`should add an event to an array of events, then call repaint() method`, () => { - spyOn(controller, 'repaint'); + it(`should add an event to an array of events`, () => { controller.events = []; controller.addEvent({ dated: new Date(), @@ -43,13 +42,13 @@ fdescribe('Component vnCalendar', () => { expect(firstEvent.title).toEqual('My event'); expect(firstEvent.isRemovable).toBeDefined(); expect(firstEvent.isRemovable).toBeTruthy(); - expect(controller.repaint).toHaveBeenCalledWith(); }); - it(`should not repeat an event for the same date, should not call repaint() method`, () => { - spyOn(controller, 'repaint'); + it(`should not repeat an event for the same date`, () => { const curDate = new Date(); - controller._events = [{ + curDate.setHours(0, 0, 0, 0); + + controller.events = [{ dated: curDate, title: 'My event 1', className: 'color' @@ -64,13 +63,11 @@ fdescribe('Component vnCalendar', () => { expect(controller.events.length).toEqual(1); expect(firstEvent.title).toEqual('My event 1'); - expect(controller.repaint).not.toHaveBeenCalledWith(); }); }); describe('removeEvent()', () => { - it(`should remove an event from an array of events, then call repaint() method`, () => { - spyOn(controller, 'repaint'); + it(`should remove an event from an array of events`, () => { const curDate = new Date(); controller._events = [{ dated: curDate, @@ -80,7 +77,6 @@ fdescribe('Component vnCalendar', () => { controller.removeEvent(curDate); expect(controller.events.length).toEqual(0); - expect(controller.repaint).toHaveBeenCalledWith(); }); }); diff --git a/modules/worker/front/calendar/index.js b/modules/worker/front/calendar/index.js index 55381ae44..dafa1d24d 100644 --- a/modules/worker/front/calendar/index.js +++ b/modules/worker/front/calendar/index.js @@ -98,7 +98,6 @@ class Controller { now.setDate(1); months[i] = now; - console.log(now); } return months;