Skip to content

Commit

Permalink
Bah, one test is better than no test. Moving on.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminws committed Jan 21, 2012
1 parent f356f0a commit 626ff89
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 72 deletions.
1 change: 1 addition & 0 deletions lib/stomp_api.js
Expand Up @@ -6,6 +6,7 @@ function Stomp(args) {
this.passcode = args.passcode;
this.ssl = args.ssl || false;
this.ssl_validate = args.ssl_validate || false;
this.ssl_options = args.ssl_options || {};
this['client-id'] = args['client-id'];
};

Expand Down
151 changes: 79 additions & 72 deletions spec/StompApiSpec.js
@@ -1,6 +1,6 @@
var Stomp = require('../lib/stomp_api').Stomp;

describe('When using StompApi', function() {
describe('StompApi', function() {
var stomp;
var args;

Expand All @@ -17,78 +17,85 @@ describe('When using StompApi', function() {
stomp = new Stomp(args);
});

it('will have a port property', function() {
expect(stomp.port).toEqual(61613);
});

it('will have a port property, even if args are not set', function() {
delete args.port;
stomp = new Stomp(args)
expect(stomp.port).toEqual(61613);
args.port = 61613;
stomp = new Stomp(args)
});

it('will have a host property', function() {
expect(stomp.host).toEqual('127.0.0.1');
});

it('will have a host attribute, even if args are not set', function() {
delete args.host;
stomp = new Stomp(args)
expect(stomp.host).toEqual('127.0.0.1');
args.host = '127.0.0.1';
stomp = new Stomp(args)
});

it('will have a debug property', function() {
expect(stomp.debug).toBe(true);
});

it('will have a debug property that is false if argument not defined', function() {
delete args.debug;
stomp = new Stomp(args);
expect(stomp.debug).toBe(false);
args.debug = true;
stomp = new Stomp(args);
});

it('will have a login property if set', function() {
expect(stomp.login).toEqual('guest');
});
describe('When instanciating it', function() {
it('will have a port property', function() {
expect(stomp.port).toEqual(61613);
});

it('will have a port property, even if args are not set', function() {
delete args.port;
stomp = new Stomp(args)
expect(stomp.port).toEqual(61613);
args.port = 61613;
stomp = new Stomp(args)
});

it('will have a host property', function() {
expect(stomp.host).toEqual('127.0.0.1');
});

it('will have a host attribute, even if args are not set', function() {
delete args.host;
stomp = new Stomp(args)
expect(stomp.host).toEqual('127.0.0.1');
args.host = '127.0.0.1';
stomp = new Stomp(args)
});

it('will have a debug property', function() {
expect(stomp.debug).toBe(true);
});

it('will have a debug property that is false if argument not defined', function() {
delete args.debug;
stomp = new Stomp(args);
expect(stomp.debug).toBe(false);
args.debug = true;
stomp = new Stomp(args);
});

it('will have a login property if set', function() {
expect(stomp.login).toEqual('guest');
});

it('will have a passcode property if set', function() {
expect(stomp.passcode).toEqual('guest');
});

it('will have an ssl property if set', function() {
expect(stomp.ssl).toBe(true);
});

it('will have and ssl property that is false if argument not defined', function() {
delete args.ssl;
stomp = new Stomp(args);
expect(stomp.ssl).toBe(false);
args.ssl = true;
stomp = new Stomp(args);
});

it('will have an ssl_validate property if set', function() {
expect(stomp.ssl_validate).toBe(true);
});

it('will have an ssl_validate property that is false if argument not defined', function() {
delete args.ssl_validate;
stomp = new Stomp(args);
expect(stomp.ssl_validate).toBe(false);
args.ssl_validate = true;
stomp = new Stomp(args);
});

it('will have an ssl_options property as an empty object if not set', function() {
expect(Object.keys(stomp.ssl_options).length === 0).toBeTruthy();
});

it('could have a client-id header', function() {
args['client-id'] = 'test';
stomp = new Stomp(args);
expect(stomp['client-id']).toEqual('test');
});

it('will have a passcode property if set', function() {
expect(stomp.passcode).toEqual('guest');
});

it('will have an ssl property if set', function() {
expect(stomp.ssl).toBe(true);
});

it('will have and ssl property that is false if argument not defined', function() {
delete args.ssl;
stomp = new Stomp(args);
expect(stomp.ssl).toBe(false);
args.ssl = true;
stomp = new Stomp(args);
});

it('will have an ssl_validate property if set', function() {
expect(stomp.ssl_validate).toBe(true);
});

it('will have and ssl_validate property that is false if argument not defined', function() {
delete args.ssl_validate;
stomp = new Stomp(args);
expect(stomp.ssl_validate).toBe(false);
args.ssl_validate = true;
stomp = new Stomp(args);
});

it('could have a client-id header', function() {
args['client-id'] = 'test';
stomp = new Stomp(args);
expect(stomp['client-id']).toEqual('test');
});

});

0 comments on commit 626ff89

Please sign in to comment.