mirror of
https://github.com/webslides/WebSlides.git
synced 2025-08-13 08:34:50 +02:00
@@ -8,8 +8,9 @@ const CLASSES = {
|
|||||||
const Events = {
|
const Events = {
|
||||||
ENTER: 'dom:enter',
|
ENTER: 'dom:enter',
|
||||||
LEAVE: 'dom:leave',
|
LEAVE: 'dom:leave',
|
||||||
|
DISABLE: 'slide:disable',
|
||||||
ENABLE: 'slide:enable',
|
ENABLE: 'slide:enable',
|
||||||
DISABLE: 'slide:disable'
|
SHOW: 'slide:show'
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,6 +58,7 @@ class Slide {
|
|||||||
show() {
|
show() {
|
||||||
DOM.show(this.el);
|
DOM.show(this.el);
|
||||||
this.el.classList.add(CLASSES.CURRENT);
|
this.el.classList.add(CLASSES.CURRENT);
|
||||||
|
this.fire_(Events.SHOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -71,22 +71,26 @@ describe('Slide module', () => {
|
|||||||
const enter = jest.fn();
|
const enter = jest.fn();
|
||||||
const enable = jest.fn();
|
const enable = jest.fn();
|
||||||
const disable = jest.fn();
|
const disable = jest.fn();
|
||||||
|
const show = jest.fn();
|
||||||
|
|
||||||
slide.el.addEventListener('dom:leave', leave);
|
slide.el.addEventListener('dom:leave', leave);
|
||||||
slide.el.addEventListener('dom:enter', enter);
|
slide.el.addEventListener('dom:enter', enter);
|
||||||
slide.el.addEventListener('slide:enable', enable);
|
slide.el.addEventListener('slide:enable', enable);
|
||||||
slide.el.addEventListener('slide:disable', disable);
|
slide.el.addEventListener('slide:disable', disable);
|
||||||
|
slide.el.addEventListener('slide:show', show);
|
||||||
|
|
||||||
expect(enter).not.toHaveBeenCalled();
|
expect(enter).not.toHaveBeenCalled();
|
||||||
expect(leave).not.toHaveBeenCalled();
|
expect(leave).not.toHaveBeenCalled();
|
||||||
expect(enable).not.toHaveBeenCalled();
|
expect(enable).not.toHaveBeenCalled();
|
||||||
expect(disable).not.toHaveBeenCalled();
|
expect(disable).not.toHaveBeenCalled();
|
||||||
|
expect(show).not.toHaveBeenCalled();
|
||||||
|
|
||||||
slide.enable();
|
slide.enable();
|
||||||
expect(enter).not.toHaveBeenCalled();
|
expect(enter).not.toHaveBeenCalled();
|
||||||
expect(leave).not.toHaveBeenCalled();
|
expect(leave).not.toHaveBeenCalled();
|
||||||
expect(enable).toHaveBeenCalledTimes(1);
|
expect(enable).toHaveBeenCalledTimes(1);
|
||||||
expect(disable).not.toHaveBeenCalled();
|
expect(disable).not.toHaveBeenCalled();
|
||||||
|
expect(show).not.toHaveBeenCalled();
|
||||||
enable.mockClear();
|
enable.mockClear();
|
||||||
|
|
||||||
slide.disable();
|
slide.disable();
|
||||||
@@ -94,6 +98,7 @@ describe('Slide module', () => {
|
|||||||
expect(leave).not.toHaveBeenCalled();
|
expect(leave).not.toHaveBeenCalled();
|
||||||
expect(enable).not.toHaveBeenCalled();
|
expect(enable).not.toHaveBeenCalled();
|
||||||
expect(disable).toHaveBeenCalledTimes(1);
|
expect(disable).toHaveBeenCalledTimes(1);
|
||||||
|
expect(show).not.toHaveBeenCalled();
|
||||||
disable.mockClear();
|
disable.mockClear();
|
||||||
|
|
||||||
slide.moveAfterLast();
|
slide.moveAfterLast();
|
||||||
@@ -101,6 +106,7 @@ describe('Slide module', () => {
|
|||||||
expect(leave).toHaveBeenCalledTimes(1);
|
expect(leave).toHaveBeenCalledTimes(1);
|
||||||
expect(enable).not.toHaveBeenCalled();
|
expect(enable).not.toHaveBeenCalled();
|
||||||
expect(disable).not.toHaveBeenCalled();
|
expect(disable).not.toHaveBeenCalled();
|
||||||
|
expect(show).not.toHaveBeenCalled();
|
||||||
enter.mockClear();
|
enter.mockClear();
|
||||||
leave.mockClear();
|
leave.mockClear();
|
||||||
|
|
||||||
@@ -109,8 +115,12 @@ describe('Slide module', () => {
|
|||||||
expect(leave).toHaveBeenCalledTimes(1);
|
expect(leave).toHaveBeenCalledTimes(1);
|
||||||
expect(enable).not.toHaveBeenCalled();
|
expect(enable).not.toHaveBeenCalled();
|
||||||
expect(disable).not.toHaveBeenCalled();
|
expect(disable).not.toHaveBeenCalled();
|
||||||
|
expect(show).not.toHaveBeenCalled();
|
||||||
enter.mockClear();
|
enter.mockClear();
|
||||||
leave.mockClear();
|
leave.mockClear();
|
||||||
|
|
||||||
|
slide.show();
|
||||||
|
expect(show).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Move', () => {
|
test('Move', () => {
|
||||||
|
Reference in New Issue
Block a user