2015-02-10 19:41:24 +00:00
|
|
|
/*global describe it before after */
|
|
|
|
|
|
|
|
"use client";
|
|
|
|
|
2015-05-01 14:19:15 +00:00
|
|
|
require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "/vfs-home"], function (architect, chai, basePath, homePath) {
|
2015-02-10 19:41:24 +00:00
|
|
|
var expect = chai.expect;
|
|
|
|
var Assert = chai.assert;
|
|
|
|
|
|
|
|
expect.setupArchitectTest([
|
|
|
|
{
|
|
|
|
packagePath: "plugins/c9.core/c9",
|
|
|
|
workspaceId: "ubuntu/ip-10-35-77-180",
|
|
|
|
startdate: new Date(),
|
|
|
|
debug: true,
|
|
|
|
hosted: true,
|
|
|
|
local: false,
|
2015-05-01 13:02:28 +00:00
|
|
|
davPrefix: "/",
|
2015-05-01 14:19:15 +00:00
|
|
|
home: homePath
|
2015-02-10 19:41:24 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
"plugins/c9.core/ext",
|
|
|
|
"plugins/c9.core/http-xhr",
|
|
|
|
"plugins/c9.core/util",
|
2015-05-01 13:36:36 +00:00
|
|
|
"plugins/c9.ide.ui/lib_apf",
|
|
|
|
"plugins/c9.ide.ui/ui",
|
2015-02-10 19:41:24 +00:00
|
|
|
"plugins/c9.core/settings",
|
|
|
|
"plugins/c9.vfs.client/vfs_client",
|
|
|
|
"plugins/c9.vfs.client/endpoint",
|
|
|
|
"plugins/c9.ide.auth/auth",
|
|
|
|
"plugins/c9.fs/fs",
|
2015-05-01 13:02:28 +00:00
|
|
|
"plugins/c9.fs/net",
|
|
|
|
|
|
|
|
{
|
|
|
|
packagePath: "plugins/c9.cli.bridge/bridge",
|
|
|
|
startBridge: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
packagePath: "plugins/c9.cli.bridge/bridge_commands",
|
|
|
|
basePath: basePath
|
|
|
|
},
|
|
|
|
"plugins/c9.cli.bridge/bridge-client",
|
2015-02-10 19:41:24 +00:00
|
|
|
|
|
|
|
// Mock plugins
|
|
|
|
{
|
2015-05-01 13:02:28 +00:00
|
|
|
consumes: [],
|
2015-02-10 19:41:24 +00:00
|
|
|
provides: [
|
2015-05-01 13:02:28 +00:00
|
|
|
"preferences", "ui"
|
2015-02-10 19:41:24 +00:00
|
|
|
],
|
|
|
|
setup: expect.html.mocked
|
|
|
|
},
|
|
|
|
{
|
2015-05-01 13:02:28 +00:00
|
|
|
consumes: ["bridge", "bridge.client"],
|
2015-02-10 19:41:24 +00:00
|
|
|
provides: [],
|
|
|
|
setup: main
|
|
|
|
}
|
|
|
|
], architect);
|
|
|
|
|
|
|
|
function main(options, imports, register) {
|
2015-05-01 13:02:28 +00:00
|
|
|
var bridge = imports.bridge;
|
|
|
|
var client = imports["bridge.client"];
|
2015-02-10 19:41:24 +00:00
|
|
|
|
2015-05-01 13:02:28 +00:00
|
|
|
describe('bridge', function() {
|
|
|
|
// this.timeout(10000);
|
|
|
|
|
|
|
|
before(function(done){
|
|
|
|
bridge.on("ready", function(){
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2015-02-10 19:41:24 +00:00
|
|
|
|
2015-05-01 13:02:28 +00:00
|
|
|
it('send and receive messages', function(done) {
|
|
|
|
bridge.on("message", function(e){
|
|
|
|
if (e.message.hello) {
|
2015-05-01 16:31:49 +00:00
|
|
|
e.respond(null, { "hi": true });
|
2015-05-01 13:02:28 +00:00
|
|
|
}
|
2015-05-01 16:31:49 +00:00
|
|
|
});
|
2015-05-01 13:02:28 +00:00
|
|
|
client.send({ "hello": true }, function(err, message){
|
|
|
|
if (err) throw err.message;
|
|
|
|
expect(message).property("hi").to.be.ok;
|
|
|
|
done();
|
2015-02-10 19:41:24 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
if (onload)
|
|
|
|
onload();
|
|
|
|
}
|
|
|
|
});
|