Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
66
gaia/tests/jsmarionette/runner/marionette-js-runner/test/rpc_test.js
Executable file
66
gaia/tests/jsmarionette/runner/marionette-js-runner/test/rpc_test.js
Executable file
|
|
@ -0,0 +1,66 @@
|
|||
'use strict';
|
||||
suite('rpc', function() {
|
||||
var RPC = require('../lib/rpc');
|
||||
var fork = require('child_process').fork;
|
||||
var assert = require('assert');
|
||||
|
||||
var proc;
|
||||
suiteSetup(function() {
|
||||
proc = fork(__dirname + '/fixtures/rpc');
|
||||
});
|
||||
|
||||
suiteTeardown(function() {
|
||||
proc.kill();
|
||||
});
|
||||
|
||||
var subject, client;
|
||||
setup(function() {
|
||||
subject = new RPC(proc.send.bind(proc));
|
||||
client = subject.client('test', ['noArgs', 'args', 'error', 'getSelf']);
|
||||
proc.on('message', subject.handle());
|
||||
});
|
||||
|
||||
test('noArgs', function() {
|
||||
return client.noArgs();
|
||||
});
|
||||
|
||||
test('args', function() {
|
||||
return client.args(1, 2, 3, 4).then(function(result) {
|
||||
assert.deepEqual(result, [1, 2, 3, 4]);
|
||||
});
|
||||
});
|
||||
|
||||
test('objects', function() {
|
||||
var obj;
|
||||
return client.getSelf().then(function(rpcObj) {
|
||||
obj = rpcObj;
|
||||
return rpcObj.args('woot', 'bar');
|
||||
}).then(function(value) {
|
||||
assert.deepEqual(value, ['woot', 'bar']);
|
||||
}).then(function() {
|
||||
assert(obj.destroy, 'has implicit destroy method');
|
||||
return obj.destroy();
|
||||
}).then(function() {
|
||||
return obj.args();
|
||||
}).then(
|
||||
function() { throw new Error('expected error'); },
|
||||
function(err) {
|
||||
assert.ok(err.message.indexOf('destroyed') !== -1);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('error', function() {
|
||||
return client.error()
|
||||
.then(function() {
|
||||
process.nextTick(function() {
|
||||
throw new Error('must not resolve');
|
||||
});
|
||||
})
|
||||
.catch (function(err) {
|
||||
assert.equal(err.message, 'xfoo');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue