Add tests and update core example to handle stage being undefined.

This commit is contained in:
Karishma Chadha 2019-03-22 12:13:37 -04:00
parent 0e710ba3d9
commit 30c9b7fd84
3 changed files with 68 additions and 17 deletions
test/unit

View file

@ -62,3 +62,24 @@ test('remote', t => {
.then(() => runServiceTest('RemoteDispatchTest', t), e => t.fail(e))
.then(() => dispatch._remoteCall(worker, 'dispatch', 'terminate'), e => t.fail(e));
});
test('local, sync', t => {
dispatch.setServiceSync('SyncDispatchTest', new DispatchTestService());
const a = dispatch.callSync('SyncDispatchTest', 'returnFortyTwo');
t.equal(a, 42);
const b = dispatch.callSync('SyncDispatchTest', 'doubleArgument', 9);
t.equal(b, 18);
const c = dispatch.callSync('SyncDispatchTest', 'doubleArgument', 123);
t.equal(c, 246);
try {
dispatch.callSync('SyncDispatchTest', 'throwException');
} catch (e) {
t.equal(e.message, 'This is a test exception thrown by DispatchTest');
}
t.end();
});