Skip to content

Commit

Permalink
re-enabled tests, added a couple more
Browse files Browse the repository at this point in the history
  • Loading branch information
4umfreak committed Nov 17, 2019
1 parent b3d8262 commit 84dd888
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
6 changes: 5 additions & 1 deletion test/transom-core.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ describe('TransomCore', function () {
core.initialize(dummyServer, myApi).then(function(server){
expect(server.name).to.equal('dummyServer');
expect(server.registry.constructor.name).to.equal('PocketRegistry');

// Make sure it's a functioning registry
server.registry.set("foo", "bar")
expect(server.registry.get("foo")).to.equal('bar');
done();
});
});
Expand Down Expand Up @@ -270,7 +274,7 @@ describe('TransomCore', function () {
expect(core.initialize({})).to.exist;
});

it.only('can initialize with a non-empty api definition', function (done) {
it('can initialize with a non-empty api definition', function (done) {
const dummyServer = {};
dummyServer.pre = sinon.spy();
dummyServer.use = sinon.spy();
Expand Down
16 changes: 11 additions & 5 deletions test/wrapper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ describe('TransomCore wrapper', function() {
// Define functions
fxs.map(p => {
Object.defineProperty(MockRestify.prototype, p, {
value: function() {}
value: function() {
return `Function name is ${p}.`
}
});
});

Expand Down Expand Up @@ -110,10 +112,12 @@ describe('TransomCore wrapper', function() {
properties.map(p => {
wrapper[p] = `Hello, My name is property '${p}'`; // setter!
expect(wrapper[p]).to.equal(`Hello, My name is property '${p}'`); // getter!
// Verify that the actual restify property value is same.
expect(wrapper.restify[p]).to.equal(`Hello, My name is property '${p}'`);
});
// Make sure each property is called only once.
// Make sure each property is called only twice, as above.
properties.map(p => {
expect(spies[p].get.callCount).to.equal(1);
expect(`${spies[p].get.callCount}-${p}`).to.equal(`2-${p}`);
});

// Test the defined functions with a single argument.
Expand Down Expand Up @@ -145,7 +149,8 @@ describe('TransomCore wrapper', function() {
// console.log(fakeArgs);

// Ensure that args are proxied through to restify
wrapper[f](...fakeArgs); // call fx!
const result = wrapper[f](...fakeArgs); // call fx!
expect(result).to.equal(`Function name is ${f}.`);
expect(spies[f].firstCall.args).to.have.members(fakeArgs);
});
});
Expand All @@ -159,7 +164,8 @@ describe('TransomCore wrapper', function() {
// Test the defined functions with a single argument.
httpMethods.map(h => {
// Ensure that args are proxied through to restify
wrapper[h](`Calling HTTP ${h} method!`); // call the fx!
const result = wrapper[h](`Calling HTTP ${h} method!`); // call the fx!
expect(result).to.equal(`Function name is ${h}.`);
expect(spies['emit'].lastCall.args[0]).to.equal(`transom.route.${h}`);
expect(spies['emit'].lastCall.args[1][0]).to.equal(`Calling HTTP ${h} method!`);
});
Expand Down

0 comments on commit 84dd888

Please sign in to comment.