1
0
mirror of https://github.com/webslides/WebSlides.git synced 2025-08-12 08:04:14 +02:00

Firing show event on the slide

Fixes #104
This commit is contained in:
Antonio Laguna
2018-01-01 16:03:32 +01:00
parent ed93fd8df9
commit 5dd1b9c649
2 changed files with 13 additions and 1 deletions

View File

@@ -8,8 +8,9 @@ const CLASSES = {
const Events = {
ENTER: 'dom:enter',
LEAVE: 'dom:leave',
DISABLE: 'slide:disable',
ENABLE: 'slide:enable',
DISABLE: 'slide:disable'
SHOW: 'slide:show'
};
/**
@@ -57,6 +58,7 @@ class Slide {
show() {
DOM.show(this.el);
this.el.classList.add(CLASSES.CURRENT);
this.fire_(Events.SHOW);
}
/**

View File

@@ -71,22 +71,26 @@ describe('Slide module', () => {
const enter = jest.fn();
const enable = jest.fn();
const disable = jest.fn();
const show = jest.fn();
slide.el.addEventListener('dom:leave', leave);
slide.el.addEventListener('dom:enter', enter);
slide.el.addEventListener('slide:enable', enable);
slide.el.addEventListener('slide:disable', disable);
slide.el.addEventListener('slide:show', show);
expect(enter).not.toHaveBeenCalled();
expect(leave).not.toHaveBeenCalled();
expect(enable).not.toHaveBeenCalled();
expect(disable).not.toHaveBeenCalled();
expect(show).not.toHaveBeenCalled();
slide.enable();
expect(enter).not.toHaveBeenCalled();
expect(leave).not.toHaveBeenCalled();
expect(enable).toHaveBeenCalledTimes(1);
expect(disable).not.toHaveBeenCalled();
expect(show).not.toHaveBeenCalled();
enable.mockClear();
slide.disable();
@@ -94,6 +98,7 @@ describe('Slide module', () => {
expect(leave).not.toHaveBeenCalled();
expect(enable).not.toHaveBeenCalled();
expect(disable).toHaveBeenCalledTimes(1);
expect(show).not.toHaveBeenCalled();
disable.mockClear();
slide.moveAfterLast();
@@ -101,6 +106,7 @@ describe('Slide module', () => {
expect(leave).toHaveBeenCalledTimes(1);
expect(enable).not.toHaveBeenCalled();
expect(disable).not.toHaveBeenCalled();
expect(show).not.toHaveBeenCalled();
enter.mockClear();
leave.mockClear();
@@ -109,8 +115,12 @@ describe('Slide module', () => {
expect(leave).toHaveBeenCalledTimes(1);
expect(enable).not.toHaveBeenCalled();
expect(disable).not.toHaveBeenCalled();
expect(show).not.toHaveBeenCalled();
enter.mockClear();
leave.mockClear();
slide.show();
expect(show).toHaveBeenCalled();
});
test('Move', () => {