$(function () {
'use strict'
/* global QUnit */
/* global viewport */
/* global $ */
QUnit.module('sticky event')
QUnit.module('aceSticky', {
afterEach: function () {
$('#qunit-fixture').html('')
}
})
QUnit.test('should trigger sticky event', function (assert) {
assert.expect(1)
var done = assert.async()
$('
').appendTo('#qunit-fixture')
var nav = $('').appendTo('#qunit-fixture')
$('').appendTo('#qunit-fixture')
setTimeout(function () {
nav.get(0).addEventListener('sticky-change', function (e) {
assert.ok(e.detail.isSticky, 'sticky-change triggered')
done()
})
$('html,body').scrollTop(3300)
}, 100)
nav.aceSticky()
})
QUnit.test('should not trigger sticky event on above `md` size', function (assert) {
assert.expect(1)
var done = assert.async()
$('').appendTo('#qunit-fixture')
var nav = $('').appendTo('#qunit-fixture')
$('').appendTo('#qunit-fixture')
setTimeout(function () {
nav.get(0).addEventListener('sticky-change', function (e) {
assert.notOk(e.detail.isSticky, 'sticky-change triggered')
done()
})
$('html,body').scrollTop(3300)
}, 100)
nav.aceSticky()
})
QUnit.test('should trigger sticky event on below `md` size', function (assert) {
assert.expect(1)
var done = assert.async()
viewport.set(480, 640)
$('').appendTo('#qunit-fixture')
var nav = $('').appendTo('#qunit-fixture')
$('').appendTo('#qunit-fixture')
setTimeout(function () {
nav.get(0).addEventListener('sticky-change', function (e) {
assert.ok(e.detail.isSticky, 'sticky-change triggered')
viewport.reset()
done()
})
$('html,body').scrollTop(3300)
}, 100)
nav.aceSticky()
})
})