De promotiewebsite die de reguliere site vervangt tijdens de Kick-In. https://join.harambee.utwente.nl
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
kick-in-promo-site/tests/unit/fitToSection.js

65 lines
2.5 KiB

//overwritting the scrollTop function of jQuery to simulate scroll
//when using autoScrolling:false or scrollBar:true
function simulateScroll(scrollValue){
window.pageYOffset = (function(){
return scrollValue;
})();
trigger(window, 'scroll');
}
QUnit.test('Testing fitToSection:true', function(assert) {
var id = '#fullpage';
var FP = initFullpageNew(id, Object.assign({}, sectionsAndSlidesCallbacks, {autoScrolling:false, fitToSection: true, scrollingSpeed: 50}));
var done = assert.async(1);
$(SECTION_ACTIVE_SEL)[0].offsetTop = window.innerHeight * 0.6;
simulateScroll(window.innerHeight * 0.6);
assert.equal($(SECTION_ACTIVE_SEL).index(), 1, 'We expect section 1 to be active');
assert.ok($(SECTION_SEL).eq(0).hasClass(COMPLETELY), '1st section has class COMPLETELY_SEL');
setTimeout(function(){
assert.ok($(SECTION_SEL).eq(1).hasClass(COMPLETELY), '2nd section has class COMPLETELY_SEL');
done();
},100 + 1000);
});
QUnit.test('Testing fitToSection:false', function(assert) {
var id = '#fullpage';
var FP = initFullpageNew(id, Object.assign({}, sectionsAndSlidesCallbacks, {autoScrolling:false, fitToSection: false, scrollingSpeed: 50}));
var done = assert.async(1);
$(SECTION_ACTIVE_SEL)[0].offsetTop = window.innerHeight * 0.6;
simulateScroll(window.innerHeight * 0.6);
assert.equal($(SECTION_ACTIVE_SEL).index(), 1, 'We expect section 1 to be active');
assert.ok($(SECTION_SEL).eq(0).hasClass(COMPLETELY), '1st section has class COMPLETELY_SEL');
setTimeout(function(){
assert.ok(!$(SECTION_SEL).eq(1).hasClass(COMPLETELY), '2nd section does not have the class COMPLETELY_SEL');
done();
},200 + 1000);
});
QUnit.test('Testing fitToSection:true & fitToSectionDelay:100', function(assert) {
var id = '#fullpage';
var FP = initFullpageNew(id, Object.assign({}, sectionsAndSlidesCallbacks, {autoScrolling:false, fitToSection: true, fitToSectionDelay:100, scrollingSpeed: 50}));
var done = assert.async(1);
$(SECTION_ACTIVE_SEL)[0].offsetTop = window.innerHeight * 0.6;
simulateScroll(window.innerHeight * 0.6);
assert.equal($(SECTION_ACTIVE_SEL).index(), 1, 'We expect section 1 to be active');
assert.ok($(SECTION_SEL).eq(0).hasClass(COMPLETELY), '1st section has class COMPLETELY_SEL');
setTimeout(function(){
assert.ok($(SECTION_SEL).eq(1).hasClass(COMPLETELY), '2nd section has class COMPLETELY_SEL');
done();
},200 + 100);
});