From 770b6a30bbf04810abaf0251fc1e950c896a5bb5 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 27 Oct 2020 14:35:04 +0100 Subject: [PATCH] Added unit test --- modules/item/front/diary/index.spec.js | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/item/front/diary/index.spec.js b/modules/item/front/diary/index.spec.js index 52608cde3..988914978 100644 --- a/modules/item/front/diary/index.spec.js +++ b/modules/item/front/diary/index.spec.js @@ -60,6 +60,34 @@ describe('Item', () => { expect(controller.$anchorScroll).toHaveBeenCalledWith(); }); }); + + describe('showDescriptor ()', () => { + it('should call to the entryDescriptor show() method', () => { + controller.$.entryDescriptor = {}; + controller.$.entryDescriptor.show = jest.fn(); + + const $event = new Event('click'); + const target = document.createElement('div'); + target.dispatchEvent($event); + const data = {id: 1, origin: 1}; + controller.showDescriptor($event, data); + + expect(controller.$.entryDescriptor.show).toHaveBeenCalledWith($event.target, data.origin); + }); + + it('should call to the ticketDescriptor show() method', () => { + controller.$.ticketDescriptor = {}; + controller.$.ticketDescriptor.show = jest.fn(); + + const $event = new Event('click'); + const target = document.createElement('div'); + target.dispatchEvent($event); + const data = {id: 1, origin: 1, isTicket: true}; + controller.showDescriptor($event, data); + + expect(controller.$.ticketDescriptor.show).toHaveBeenCalledWith($event.target, data.origin); + }); + }); }); });