mgraph.events
Version:
Modern eventing library for Node.js and browsers
38 lines (34 loc) • 918 B
JavaScript
// test/errors.js
import { test } from 'tap';
import eventify from '../index.js';
test('Eventify protects your object with reserved property', (t) => {
t.plan(1);
try {
eventify({ on: "dummy string" });
t.fail("Expected error not thrown");
} catch (e) {
t.pass("Eventify threw an exception to protect the object");
}
t.end();
});
test('Eventify does not allow falsy objects', (t) => {
t.plan(1);
try {
eventify(null);
t.fail("Expected error not thrown");
} catch (e) {
t.pass("Eventify threw an exception for falsy object");
}
t.end();
});
test('Eventify does not allow subscribe without a function', (t) => {
t.plan(1);
const subject = eventify({});
try {
subject.on('foo');
t.fail("Expected error not thrown");
} catch (e) {
t.pass("Eventify threw an exception when no function is provided");
}
t.end();
});