diff --git a/modules/item/front/diary/index.spec.js b/modules/item/front/diary/index.spec.js index ccf7ac1a1..b6e50e5c5 100644 --- a/modules/item/front/diary/index.spec.js +++ b/modules/item/front/diary/index.spec.js @@ -40,6 +40,26 @@ describe('Item', () => { expect(controller.item.id).toEqual(1); }); }); + + describe('scrollToLine ()', () => { + it('should assign $location then call anchorScroll using controller value', () => { + jest.spyOn(controller, '$anchorScroll'); + controller.lineFk = 1; + controller.scrollToLine('invalidValue'); + + expect(controller.$location.hash()).toEqual(`vnItemDiary-${1}`); + expect(controller.$anchorScroll).toHaveBeenCalledWith(); + }); + + it('should assign $location then call anchorScroll using received value', () => { + jest.spyOn(controller, '$anchorScroll'); + controller.lineFk = undefined; + controller.scrollToLine(1); + + expect(controller.$location.hash()).toEqual(`vnItemDiary-${1}`); + expect(controller.$anchorScroll).toHaveBeenCalledWith(); + }); + }); }); });