Add tests for AbstractEvent

Simplify import path

Move test to new location
This commit is contained in:
Tim Rourke 2017-09-30 07:28:25 -05:00
parent 84e798afe3
commit 42535bd6b5

View File

@ -0,0 +1,47 @@
import AbstractEvent from './../AbstractEvent';
describe('AbstractEvent', () => {
test('should be of type AbstractEvent', () => {
const event = new AbstractEvent();
expect(event).toBeInstanceOf(AbstractEvent);
});
test('should initialize with correct type', () => {
const event = new AbstractEvent();
expect(event.type).toBe('event');
});
test('should initialize in uncancelable state', () => {
const event = new AbstractEvent();
expect(event.cancelable).toBe(false);
});
test('should initialize in uncancelled state', () => {
const event = new AbstractEvent();
expect(event.canceled()).toBe(false);
});
test('should initialize with data', () => {
const event = new AbstractEvent({
foo: 'bar',
});
expect(event.data).toMatchObject({
foo: 'bar',
});
});
test('should cancel event', () => {
const event = new AbstractEvent();
expect(event.canceled()).toBe(false);
event.cancel();
expect(event.canceled()).toBe(true);
});
});