Skip to content

Commit

Permalink
Update tests to actually test boolean values
Browse files Browse the repository at this point in the history
  • Loading branch information
knolleary committed May 18, 2020
1 parent 051251c commit 67e0d23
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 43 deletions.
4 changes: 2 additions & 2 deletions test/lib/commands/disable_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ describe("commands/disable", function() {
if (error) {
throw error;
}
result.logList.called.should.be.true;
result.logList.called.should.be.true();
done();
}).otherwise(done);
});

it('displays command help if node not specified', function(done) {
command({_:{}},result);
result.help.called.should.be.true;
result.help.called.should.be.true();
done();
});
});
4 changes: 2 additions & 2 deletions test/lib/commands/enable_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ describe("commands/enable", function() {
if (error) {
throw error;
}
result.logList.called.should.be.true;
result.logList.called.should.be.true();
done();
}).otherwise(done);
});

it('displays command help if node not specified', function(done) {
command({_:{}},result);
result.help.called.should.be.true;
result.help.called.should.be.true();
done();
});
});
6 changes: 3 additions & 3 deletions test/lib/commands/hash_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("commands/hash-pw", function() {
});

command({},result).then(function() {
result.log.calledOnce.should.be.true;
result.log.calledOnce.should.be.true();
var hash = result.log.firstCall.args[0];
bcrypt.compare("a-test-password",hash,function(err,match) {
match.should.be.true
Expand All @@ -54,7 +54,7 @@ describe("commands/hash-pw", function() {
});

command({},result).then(function() {
result.log.called.should.be.false;
result.log.called.should.be.false();
done();
});
});
Expand All @@ -64,7 +64,7 @@ describe("commands/hash-pw", function() {
});

command({},result).then(function() {
result.log.called.should.be.false;
result.log.called.should.be.false();
done();
});
});
Expand Down
8 changes: 4 additions & 4 deletions test/lib/commands/info_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe("commands/info", function() {
if (error) {
throw error;
}
result.logDetails.called.should.be.true;
result.logDetails.called.should.be.true();
done();
}).otherwise(done);
});
Expand All @@ -66,16 +66,16 @@ describe("commands/info", function() {
if (error) {
throw error;
}
result.logDetails.called.should.be.false;
result.warn.called.should.be.true;
result.logDetails.called.should.be.false();
result.warn.called.should.be.true();
result.warn.args[0][0].should.eql("error");
done();
}).otherwise(done);
});

it('displays command help if node not specified', function(done) {
command({_:{}},result);
result.help.called.should.be.true;
result.help.called.should.be.true();
done();
});

Expand Down
4 changes: 2 additions & 2 deletions test/lib/commands/install_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ describe("commands/install", function() {
if (error) {
throw error;
}
result.logDetails.called.should.be.true;
result.logDetails.called.should.be.true();
done();
}).otherwise(done);
});

it('displays command help if node not specified', function(done) {
command({_:{}},result);
result.help.called.should.be.true;
result.help.called.should.be.true();
done();
});
});
2 changes: 1 addition & 1 deletion test/lib/commands/list_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe("commands/list", function() {
if (error) {
throw error;
}
result.logNodeList.called.should.be.true;
result.logNodeList.called.should.be.true();
done();
}).otherwise(done);
});
Expand Down
32 changes: 16 additions & 16 deletions test/lib/commands/login_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe("commands/list", function() {


command({},result).then(function() {
requestStub.calledTwice.should.be.true;
requestStub.calledTwice.should.be.true();
requestStub.args[0][0].should.eql("/auth/login");
requestStub.args[1][0].should.eql("/auth/token");
requestStub.args[1][1].should.eql({
Expand All @@ -63,11 +63,11 @@ describe("commands/list", function() {
});


config.tokens.calledTwice.should.be.true;
config.tokens.calledTwice.should.be.true();
should.not.exist(config.tokens.args[0][0]);
config.tokens.args[1][0].should.eql({access_token:"12345"});

/Logged in/.test(result.log.args[0][0]).should.be.true;
/Logged in/.test(result.log.args[0][0]).should.be.true();

done();
}).otherwise(done);
Expand All @@ -78,20 +78,20 @@ describe("commands/list", function() {
requestStub.onCall(0).returns(when.resolve({type:"unknown"}));
requestStub.onCall(1).returns(when.resolve({access_token:"12345"}));
command({},result).then(function() {
requestStub.calledOnce.should.be.true;
requestStub.calledOnce.should.be.true();
requestStub.args[0][0].should.eql("/auth/login");
/Unsupported login type/.test(result.warn.args[0][0]).should.be.true;
/Unsupported login type/.test(result.warn.args[0][0]).should.be.true();
done();
}).otherwise(done);
});
it('handles no authentication', function(done) {
var requestStub = sinon.stub(request,"request");
requestStub.onCall(0).returns(when.resolve({}));
command({},result).then(function() {
requestStub.calledOnce.should.be.true;
requestStub.calledOnce.should.be.true();
requestStub.args[0][0].should.eql("/auth/login");
result.log.called.should.be.false;
result.warn.called.should.be.false;
result.log.called.should.be.false();
result.warn.called.should.be.false();
done();
}).otherwise(done);
});
Expand All @@ -100,12 +100,12 @@ describe("commands/list", function() {
requestStub.onCall(0).returns(when.resolve({type:"credentials"}));
requestStub.onCall(1).returns(when.reject());
command({},result).then(function() {
config.tokens.calledOnce.should.be.true;
config.tokens.calledOnce.should.be.true();
should.not.exist(config.tokens.args[0][0]);

result.log.called.should.be.false;
result.warn.called.should.be.true;
/Login failed/.test(result.warn.args[0][0]).should.be.true;
result.log.called.should.be.false();
result.warn.called.should.be.true();
/Login failed/.test(result.warn.args[0][0]).should.be.true();
done();
}).otherwise(done);
});
Expand All @@ -114,11 +114,11 @@ describe("commands/list", function() {
var requestStub = sinon.stub(request,"request");
requestStub.onCall(0).returns(when.reject());
command({},result).then(function() {
config.tokens.calledOnce.should.be.true;
config.tokens.calledOnce.should.be.true();
should.not.exist(config.tokens.args[0][0]);
result.log.called.should.be.false;
result.warn.called.should.be.true;
/Login failed/.test(result.warn.args[0][0]).should.be.true;
result.log.called.should.be.false();
result.warn.called.should.be.true();
/Login failed/.test(result.warn.args[0][0]).should.be.true();
done();
}).otherwise(done);
});
Expand Down
4 changes: 2 additions & 2 deletions test/lib/commands/remove_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ describe("commands/remove", function() {
if (error) {
throw error;
}
result.log.called.should.be.true;
result.log.called.should.be.true();
done();
}).otherwise(done);
});

it('displays command help if node not specified', function(done) {
command({_:{}},result);
result.help.called.should.be.true;
result.help.called.should.be.true();
done();
});
});
4 changes: 2 additions & 2 deletions test/lib/commands/search_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe("commands/install", function() {
sinon.stub(httpRequest,"get").yields("testError",{statusCode:200},JSON.stringify({rows:[]}));

command({_:[null,"testnode"]},result).then(function() {
result.log.called.should.be.false;
result.log.called.should.be.false();
result.warn.called.should.be.true();
result.warn.args[0][0].should.eql("testError");
done();
Expand All @@ -78,7 +78,7 @@ describe("commands/install", function() {
sinon.stub(httpRequest,"get").yields(null,{statusCode:101},"testError");

command({_:[null,"testnode"]},result).then(function() {
result.log.called.should.be.false;
result.log.called.should.be.false();
result.warn.called.should.be.true();
result.warn.args[0][0].should.eql("101: testError");
done();
Expand Down
18 changes: 9 additions & 9 deletions test/lib/commands/target_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,31 @@ describe("commands/target", function() {

it('queries the target', function(done) {
command({_:[]},result);
config.target.called.should.be.true;
config.target.called.should.be.true();
config.target.args[0].should.have.lengthOf(0);
result.log.called.should.be.true;
/http\:\/\/test\.example\.com/.test(result.log.args[0][0]).should.be.true;
result.log.called.should.be.true();
/http\:\/\/test\.example\.com/.test(result.log.args[0][0]).should.be.true();
done();
});

it('sets the target', function(done) {
command({_:[null,"http://newtarget.example.com"]},result);
config.target.called.should.be.true;
config.target.called.should.be.true();
config.target.args[0][0].should.eql("http://newtarget.example.com");
result.log.called.should.be.true;
/http\:\/\/newtarget\.example\.com/.test(result.log.args[0][0]).should.be.true;
result.log.called.should.be.true();
/http\:\/\/newtarget\.example\.com/.test(result.log.args[0][0]).should.be.true();
done();
});

it('rejects non http targets', function(done) {
command({_:[null,"ftp://newtarget.example.com"]},result);
config.target.called.should.be.false;
result.warn.called.should.be.true;
config.target.called.should.be.false();
result.warn.called.should.be.true();
done();
});
it('strips trailing slash from target', function(done) {
command({_:[null,"http://newtarget.example.com/"]},result);
config.target.called.should.be.true;
config.target.called.should.be.true();
config.target.args[0][0].should.eql("http://newtarget.example.com");
done();
});
Expand Down

0 comments on commit 67e0d23

Please sign in to comment.