1
0
mirror of https://github.com/webslides/WebSlides.git synced 2025-08-18 02:41:37 +02:00

Reorganizing tests

This commit is contained in:
displaynone
2017-05-15 22:53:28 +02:00
parent c82fd6507a
commit dbc06fedbb

37
test/utils/hash.test.js Normal file
View File

@@ -0,0 +1,37 @@
import DOM from '../../src/js/utils/dom';
import Hash from '../../src/js/plugins/hash';
beforeAll(() => {
document.body.innerHTML = `<div id="webslides" data-test="test"><p>Text</p></div>`;
});
test('Hash plugin', () => {
document.location.hash = '#slide=1';
const goto = jest.fn();
const ws = document.getElementById('webslides');
// Simulates dataset
ws.dataset = {};
const webslides = {
options: {
changeOnClick: true
},
goToSlide: goto,
el: ws
};
expect(goto).not.toBeCalled();
const hash = new Hash(webslides);
expect(Hash.getSlideNumber()).toBe(0);
DOM.fireEvent(ws, 'ws:slide-change', {
slides: 3,
currentSlide0: 1,
currentSlide: 2
});
expect(Hash.getSlideNumber()).toBe(1);
expect(document.location.hash).toBe('#slide=2');
DOM.fireEvent(window, 'hashchange');
expect(goto.mock.calls.length).toBe(1);
});