Skip to content

Commit

Permalink
seeker.msg object added
Browse files Browse the repository at this point in the history
```
this.msg = {
          noAuth: 'No Authorized Tessels Found.',
          auth: 'No Tessels Found.'
        };
```
callable by
```
var seeker = new discover.TesselSeeker().start(seekerOpts);
var noTessels = opts.authorized ?
      seeker.msg.noAuth :
      seeker.msg.auth;
```

[x] Tests what call `Tessel.get` or `Tessel.list` needed to add msg
into stub of `TesselSeeker.start`
  • Loading branch information
Student007 authored and rwaldron committed Oct 8, 2015
1 parent 8c661bf commit b8066b7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ Tessel.list = function(opts) {
// Start looking for Tessels
var seeker = new discover.TesselSeeker().start(seekerOpts);
var noTessels = opts.authorized ?
'No Authorized Tessels Found.' :
'No Tessels Found.';

seeker.msg.noAuth :
seeker.msg.auth;
// When a Tessel is found
seeker.on('tessel', function displayResults(tessel) {

Expand Down Expand Up @@ -127,9 +126,9 @@ Tessel.get = function(opts) {

// Create a seeker object and start detecting any Tessels
var seeker = new discover.TesselSeeker().start(seekerOpts);
var noTessels = seekerOpts.authorized ?
'No Authorized Tessels Found.' :
'No Tessels Found.';
var noTessels = opts.authorized ?
seeker.msg.noAuth :
seeker.msg.auth;

function searchComplete() {
// If we found no Tessels
Expand Down
4 changes: 4 additions & 0 deletions lib/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ util.inherits(TesselSeeker, EventEmitter);

TesselSeeker.prototype.start = function(opts) {
var self = this;
self.msg = {
noAuth: 'No Authorized Tessels Found.',
auth: 'No Tessels Found.'
};
// Initialize the opts if it wasn't provided
opts = opts || {};

Expand Down
8 changes: 8 additions & 0 deletions test/unit/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ exports['Tessel.list'] = {
this.seeker = this.sandbox.stub(Seeker, 'TesselSeeker', function Seeker() {
this.start = function(opts) {
self.activeSeeker = this;
this.msg = {
noAuth: 'No Authorized Tessels Found.',
auth: 'No Tessels Found.'
};
if (opts.timeout && typeof opts.timeout === 'number') {
setTimeout(this.stop, opts.timeout);
}
Expand Down Expand Up @@ -515,6 +519,10 @@ exports['Tessel.get'] = {
this.seeker = this.sandbox.stub(Seeker, 'TesselSeeker', function Seeker() {
this.start = function(opts) {
self.activeSeeker = this;
this.msg = {
noAuth: 'No Authorized Tessels Found.',
auth: 'No Tessels Found.'
};
if (opts.timeout && typeof opts.timeout === 'number') {
setTimeout(this.stop, opts.timeout);
}
Expand Down
4 changes: 4 additions & 0 deletions test/unit/tessel.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ exports['Tessel (get)'] = {
this.seeker = this.sandbox.stub(discover, 'TesselSeeker', function Seeker() {
this.start = function(options) {
self.activeSeeker = this;
this.msg = {
noAuth: 'No Authorized Tessels Found.',
auth: 'No Tessels Found.'
};
setTimeout(this.stop.bind(this), options.timeout);
return this;
};
Expand Down

0 comments on commit b8066b7

Please sign in to comment.