Skip to content

Commit

Permalink
WIP adding coterminous-js-loopback as part of the unit tests
Browse files Browse the repository at this point in the history
Tried to get istanbul to properly run (runs, still not coverage) : gotwarlost/istanbul#538 (comment)
  • Loading branch information
Christian Nadeau committed Sep 15, 2016
1 parent 04d9a1e commit 1421717
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 13 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"babel": "6.5.2",
"babel-preset-es2015": "^6.14.0",
"babel-register": "^6.14.0",
"coterminous-js-loopback": "^0.2.0",
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-webserver": "^0.9.1",
Expand All @@ -24,9 +25,8 @@
},
"scripts": {
"start": "gulp start",
"test": "mocha --compilers js:babel-core/register",
"coverage": "istanbul cover _mocha -- -R spec --compilers js:babel-register"

"test": "mocha --use_strict --compilers js:babel-core/register",
"coverage": "node --use_strict ./node_modules/.bin/istanbul cover _mocha -- --compilers js:babel-core/register test/index.js"
},
"keywords": [
"webpack",
Expand Down
49 changes: 39 additions & 10 deletions test/coterminous-spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import assert from 'assert';

import {
registerCapability
}
from '../src/coterminous.js';

import * as Coterminous from '../src/coterminous.js';
import * as Loopback from 'coterminous-js-loopback';

var mockedCapability = {
"name": "mocked",
"version": "0.0.1",
Expand All @@ -16,17 +20,42 @@ var mockedCapability = {
Message,
Cache
}) {}
}
describe('Coterminous', function() {
it('registerCapability invalid capability', function() {
assert.throws(() => {
registerCapability({})
}, 'Should have thrown');
};

describe('Coterminous', () => {

describe('registerCapability', () => {

it('invalid capability', () => {
assert.throws(() => {
registerCapability({})
}, 'Should have thrown');
});

it('valid capability', () => {
assert.doesNotThrow(() => {
registerCapability(mockedCapability)
}, 'Should not have thrown');
});

});

it('registerCapability valid capability', function() {
assert.doesNotThrow(() => {
registerCapability(mockedCapability)
}, 'Should not have thrown');
describe('connect test', () => {

it('ensure root definition', () => {
Coterminous.root({
hello: function() {
return "world";
}
});

var transport = new Loopback();

Coterminous.connect(transport).then(function(remoteInterface) {
assert.equal(remoteInterface.hello(), 'world', 'Root remote interface should have been used');
});
});
});


});
6 changes: 6 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
global = global || {};
global.enableCoterminusLogs = true;

// Load test suites
require('./coterminous-spec.js');
require('./walkObject-spec.js');

0 comments on commit 1421717

Please sign in to comment.