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.
svelte/test/runtime/samples/window-bind-scroll-update/_config.js

38 lines
624 B

import { env, useFakeTimers } from '../../../helpers';
let clock;
export default {
before_test() {
clock = useFakeTimers();
const window = env();
Object.defineProperties(window, {
pageYOffset: {
value: 0,
configurable: true
},
pageXOffset: {
value: 0,
configurable: true
}
});
},
after_test() {
clock.removeFakeTimers();
clock = null;
},
async test({ assert, component, window }) {
assert.equal(window.pageYOffset, 0);
// clear the previous 'scrolling' state
clock.flush();
component.scrollY = 100;
clock.flush();
assert.equal(window.pageYOffset, 100);
}
};