cartodb-4.42/lib/assets/test/spec/deep-insights/viewport-utils.spec.js

36 lines
1.0 KiB
JavaScript
Raw Normal View History

2024-04-06 13:25:13 +08:00
var $ = require('jquery');
var viewportUtils = require('../../../javascripts/deep-insights/viewport-utils');
describe('viewport-utils', function () {
beforeEach(function () {
spyOn($.prototype, 'width').and.returnValue(100);
});
describe('._isViewport', function () {
it('should return true if window is lower than provided viewport', function () {
expect(viewportUtils._isViewport(101)).toBe(true);
expect(viewportUtils._isViewport(99)).toBe(false);
});
});
describe('.isMobileViewport', function () {
it('should return true if viewport is mobile', function () {
spyOn(viewportUtils, '_isViewport');
viewportUtils.isMobileViewport();
expect(viewportUtils._isViewport).toHaveBeenCalledWith(480);
});
});
describe('.isTabletViewport', function () {
it('should return true if viewport is tablet', function () {
spyOn(viewportUtils, '_isViewport');
viewportUtils.isTabletViewport();
expect(viewportUtils._isViewport).toHaveBeenCalledWith(760);
});
});
});