gotty/js/spice-web-client/unittest/syncasynchandler.test.js
Soren L. Hansen c66ae7b2e4 First, primitive stab at SPiCE integration
Launch an Xspice and run:
echo -ne "\033]844;127.0.0.1;9876\007"

This will launch a SPiCE client connecting to 127.0.0.1:9876.

Still need to add all the security stuff and generally be
more defensive in the implementation.
2021-04-16 06:50:05 -07:00

63 lines
1.4 KiB
JavaScript

suite('syncasynchandler', function () {
var sut;
var callbackWrapper;
var asyncWorker;
var scope;
setup(function() {
asyncWorker = {
run: function () {}
};
var isAsync = true;
asyncSut = new wdi.SyncAsyncHandler({
asyncWorker: asyncWorker,
isAsync: isAsync
});
syncSut = new wdi.SyncAsyncHandler({
isAsync: !isAsync
});
callbackWrapper = {
callback: function () {}
};
scope = {};
});
teardown(function () {
});
test('dispatch calls workerProcess dispatch when sync', sinon.test(function() {
var stub = this.stub(window, 'workerDispatch');
var buffer = 'one buffer';
syncSut.dispatch(buffer, callbackWrapper.callback, scope);
var isAsync = false;
sinon.assert.calledWithExactly(stub, buffer, isAsync);
}));
test('dispatch calls callback with dispatch result when sync', sinon.test(function() {
var resultFromDispatch = 'some result';
var stub = this.stub(window, 'workerDispatch').returns(resultFromDispatch);
var buffer = 'one buffer';
var callbackStub = sinon.stub();
syncSut.dispatch(buffer, callbackStub, scope);
sinon.assert.calledWithExactly(callbackStub, resultFromDispatch);
}));
test('dispatch calls AsyncWorker dispatch when async', sinon.test(function() {
var stub = this.stub(asyncWorker, 'run');
var buffer = 'one buffer';
asyncSut.dispatch(buffer, callbackWrapper.callback, scope);
sinon.assert.calledWithExactly(stub, buffer, callbackWrapper.callback, scope);
}));
});