generate new test that did already exist & update all module snippets with declaration
This commit is contained in:
14
test/createEventHub/createEventHub.js
Normal file
14
test/createEventHub/createEventHub.js
Normal file
@ -0,0 +1,14 @@
|
||||
module.exports = createEventHub = () => ({
|
||||
hub: Object.create(null),
|
||||
emit(event, data) {
|
||||
(this.hub[event] || []).forEach(handler => handler(data));
|
||||
},
|
||||
on(event, handler) {
|
||||
if (!this.hub[event]) this.hub[event] = [];
|
||||
this.hub[event].push(handler);
|
||||
},
|
||||
off(event, handler) {
|
||||
const i = (this.hub[event] || []).findIndex(h => h === handler);
|
||||
if (i > -1) this.hub[event].splice(i, 1);
|
||||
}
|
||||
});
|
||||
13
test/createEventHub/createEventHub.test.js
Normal file
13
test/createEventHub/createEventHub.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const test = require('tape');
|
||||
const createEventHub = require('./createEventHub.js');
|
||||
|
||||
test('Testing createEventHub', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof createEventHub === 'function', 'createEventHub is a Function');
|
||||
//t.deepEqual(createEventHub(args..), 'Expected');
|
||||
//t.equal(createEventHub(args..), 'Expected');
|
||||
//t.false(createEventHub(args..), 'Expected');
|
||||
//t.throws(createEventHub(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
Reference in New Issue
Block a user