/
githubmirror
/
fullPage.js
Обзор
Документация
Войти
/
githubmirror
/
fullPage.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
tests/unit/responsiveWidth.js
69 строк
3 KB
Alvaro Trigo López
- Improving tests
16 мар 2022, 21:05
16 мар 2022, 21:05
0998df3
Код
Авторство
О чём код?
function checkIsResponsive(FP, assert){ assert.ok($('body').hasClass(RESPONSIVE), 'We expect RESPONSIVE class to be applied on the body'); assert.equal(FP.test.options.autoScrolling, false, 'We expect autoScrolling to be false'); assert.equal(FP.test.options.fitToSection, false, 'We expect fitToSection to be false'); assert.equal($(SECTION_NAV_SEL).is(':visible'), false, 'We expect SECTION_NAV_SEL to be hidden'); assert.equal(afterResponsive, true, 'We expect afterResponsive callback to be fired'); } function checkIsNotResponsive(FP, assert){ assert.ok(!$('body').hasClass(RESPONSIVE), 'We expect RESPONSIVE class to not be applied on the body'); assert.equal(FP.test.options.autoScrolling, true, 'We expect autoScrolling to be true'); assert.equal(FP.test.options.fitToSection, true, 'We expect fitToSection to be true'); assert.equal($(SECTION_NAV_SEL).is(':visible'), true, 'We expect SECTION_NAV_SEL to be visible'); assert.equal(afterResponsive, false, 'We expect afterResponsive callback not to have been fired yet or to have value false'); } QUnit.test('Testing responsiveWidth', function(assert) { var id = '#fullpage'; var done = assert.async(2); var windowWidth = $(window).width(); var reponsiveValue = windowWidth/1.5; var options = {responsiveWidth: reponsiveValue, fitToSection:true, navigation:true}; var FP = initFullpageNew(id, Object.assign({}, sectionsAndSlidesCallbacks, options)); setTimeout(function(){ checkIsNotResponsive(FP, assert); done(); //mocking resize down window.innerWidth = reponsiveValue - 1; trigger(window, 'resize'); }, 800); setTimeout(function(){ checkIsResponsive(FP, assert); done(); }, 800 * 2); }); QUnit.test('Testing responsiveWidth on page load', function(assert) { var id = '#fullpage'; var windowWidth = $(window).width(); var reponsiveValue = windowWidth + 100; var options = {responsiveWidth: reponsiveValue, fitToSection:true, navigation:true}; var FP = initFullpageNew(id, Object.assign({}, sectionsAndSlidesCallbacks, options)); checkIsResponsive(FP, assert); }); QUnit.test('Testing responsiveWidth undo responsive on resize up', function(assert) { var id = '#fullpage'; var done = assert.async(1); var windowWidth = $(window).width(); var reponsiveValue = windowWidth + 100; var options = {responsiveWidth: reponsiveValue, fitToSection:true, navigation:true}; var FP = initFullpageNew(id, Object.assign({}, sectionsAndSlidesCallbacks, options)); checkIsResponsive(FP, assert); //mocking resize down window.innerWidth = windowWidth + 200; trigger(window, 'resize'); setTimeout(function(){ console.log("timeout...."); checkIsNotResponsive(FP, assert); done(); }, 800*3); });