Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #714 from CSchulz/patch-3
#701@trivial: Add CustomEvent test.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import CustomEvent from '../../src/event/events/CustomEvent'; | ||
|
||
describe('CustomEvent', () => { | ||
it('Create a CustomEvent', () => { | ||
const eventType = 'click'; | ||
const event = new CustomEvent(eventType); | ||
expect(event.type).toBe(eventType); | ||
expect(event.detail).toBeNull(); | ||
}); | ||
|
||
it('Create a CustomEvent with detail', () => { | ||
const eventType = 'click'; | ||
const eventDetail = { someInformation: true }; | ||
const event = new CustomEvent(eventType, { detail: eventDetail }); | ||
expect(event.type).toBe(eventType); | ||
expect(event.detail).toEqual(eventDetail); | ||
}); | ||
|
||
it('Create a CustomEvent with empty detail', () => { | ||
const eventType = 'click'; | ||
let event = new CustomEvent(eventType, {}); | ||
expect(event.type).toBe(eventType); | ||
expect(event.detail).toBeNull(); | ||
|
||
event = new CustomEvent(eventType, { detail: undefined }); | ||
expect(event.type).toBe(eventType); | ||
expect(event.detail).toBeNull(); | ||
|
||
event = new CustomEvent(eventType, { detail: null }); | ||
expect(event.type).toBe(eventType); | ||
expect(event.detail).toBeNull(); | ||
}); | ||
}); |