You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
811 B
JavaScript
32 lines
811 B
JavaScript
7 years ago
|
import {equal, deepEqual} from 'assert';
|
||
|
import Event from '../src/utils/event.js';
|
||
|
|
||
|
var event = new Event('XYZ');
|
||
|
|
||
|
var callback = function() {
|
||
|
};
|
||
|
|
||
|
describe('event tests --', function() {
|
||
|
|
||
|
beforeEach(function(){
|
||
|
event.offAll();
|
||
|
event.on('topic1',callback);
|
||
|
event.on('topic1',callback);
|
||
|
event.on('topic2',callback);
|
||
|
});
|
||
|
|
||
|
it('listener should be 2 for the topic1', function() {
|
||
|
equal(event.listener.topic1.length, 2);
|
||
|
});
|
||
|
|
||
|
it('event dispatcher should be return true for a successful dispatcher', function() {
|
||
|
equal(event.dispatch('topic1', true), true);
|
||
|
});
|
||
|
|
||
|
it('listener should be zero after removing all listeners', function() {
|
||
|
event.offAll();
|
||
|
deepEqual(event.listener, {});
|
||
|
});
|
||
|
});
|
||
|
|