diff --git a/app/assets/javascripts/breakpoints.js b/app/assets/javascripts/breakpoints.js index 4d5d6bb864b2d5fc5f6d0a0c6c963fd46e566b9d..93aacba0e8e2ea9a9cac3a4a47a1ab81a03bfbd0 100644 --- a/app/assets/javascripts/breakpoints.js +++ b/app/assets/javascripts/breakpoints.js @@ -15,7 +15,7 @@ const BreakpointInstance = { return breakpoint; }, isDesktop() { - return ['lg', 'md'].includes(this.getBreakpointSize); + return ['lg', 'md'].includes(this.getBreakpointSize()); }, }; diff --git a/spec/javascripts/breakpoints_spec.js b/spec/javascripts/breakpoints_spec.js index 5ee777fee3fa59e8a940a510a3bbdcb0b8332e61..fc0d9eb907a9471b70a666280be2862ed9823e32 100644 --- a/spec/javascripts/breakpoints_spec.js +++ b/spec/javascripts/breakpoints_spec.js @@ -10,4 +10,18 @@ describe('breakpoints', () => { expect(bp.getBreakpointSize()).toBe(key); }); }); + + describe('isDesktop', () => { + it('returns true when screen size is medium', () => { + spyOn(bp, 'windowWidth').and.returnValue(breakpoints.md + 10); + + expect(bp.isDesktop()).toBe(true); + }); + + it('returns false when screen size is small', () => { + spyOn(bp, 'windowWidth').and.returnValue(breakpoints.sm + 10); + + expect(bp.isDesktop()).toBe(false); + }); + }); });