Permalink
Browse files

Change platform mocking from using buster stub to constructor opt, pr…

…ocess.platform is read-only starting node v0.11.10 .
  • Loading branch information...
cliffano committed Jan 13, 2014
1 parent d7d09a7 commit 13a06e9f253f4e09fa683ac1144be4d1088533e2
Showing with 5 additions and 5 deletions.
  1. +1 −0 lib/notifiers/buildlight.js
  2. +1 −1 package.json
  3. +3 −4 test/notifiers/buildlight.js
@@ -8,6 +8,7 @@ var _BuildLight = require('buildlight');
* scheme allows flexibility to use BuildLight with various Delcom devices (RGB, RGY)
* - usbled: path to usbled installation, if not specified then it will try to
* find a usbled installation at /sys/bus/usb/drivers/usbled/
+ * - platform: override platform, used by unit tests to override buildlight platform
*/
function BuildLight(opts) {
opts = opts || {};
View
@@ -34,7 +34,7 @@
"bagofcli": "~0.0.8",
"bagofrequest": "~0.0.6",
"bagoftext": "~0.0.3",
- "buildlight": "~0.0.5",
+ "buildlight": "~0.0.6",
"colors": "~0.6.2",
"commander": "~2.0.0",
"cron": "~1.0.1",
@@ -8,7 +8,6 @@ var buster = require('buster-node'),
buster.testCase('buildlight - notify', {
setUp: function () {
this.mockFs = this.mock(fs);
- this.stub(process, 'platform', 'linux');
this.stub(_BuildLight.prototype, 'unblink', function (cb) {
cb();
});
@@ -18,22 +17,22 @@ buster.testCase('buildlight - notify', {
this.mockFs.expects('writeFileSync').once().withExactArgs('/some/usbled/path/green', 0);
this.mockFs.expects('writeFileSync').once().withExactArgs('/some/usbled/path/blue', 0);
this.mockFs.expects('writeFileSync').once().withExactArgs('/some/usbled/path/green', 1);
- var buildLight = new BuildLight({ scheme: ['red', 'green', 'blue'], usbled: '/some/usbled/path/' });
+ var buildLight = new BuildLight({ scheme: ['red', 'green', 'blue'], usbled: '/some/usbled/path/', platform: 'linux' });
buildLight.notify('OK');
},
'should switch all colours on on build light device when notification status is warn': function () {
this.mockFs.expects('writeFileSync').once().withExactArgs('/some/usbled/path/red', 1);
this.mockFs.expects('writeFileSync').once().withExactArgs('/some/usbled/path/green', 1);
this.mockFs.expects('writeFileSync').once().withExactArgs('/some/usbled/path/blue', 1);
- var buildLight = new BuildLight({ scheme: ['red', 'green', 'blue'], usbled: '/some/usbled/path/' });
+ var buildLight = new BuildLight({ scheme: ['red', 'green', 'blue'], usbled: '/some/usbled/path/', platform: 'linux' });
buildLight.notify('WARN');
},
'should switch all colours off then switch blue colour on on build light device when status is unknown': function () {
this.mockFs.expects('writeFileSync').once().withExactArgs('/some/usbled/path/red', 0);
this.mockFs.expects('writeFileSync').once().withExactArgs('/some/usbled/path/green', 0);
this.mockFs.expects('writeFileSync').once().withExactArgs('/some/usbled/path/blue', 0);
this.mockFs.expects('writeFileSync').once().withExactArgs('/some/usbled/path/blue', 1);
- var buildLight = new BuildLight({ scheme: ['red', 'green', 'blue'], usbled: '/some/usbled/path/' });
+ var buildLight = new BuildLight({ scheme: ['red', 'green', 'blue'], usbled: '/some/usbled/path/', platform: 'linux' });
buildLight.notify('SOMEUNKNOWNSTATUS');
}
});

0 comments on commit 13a06e9

Please sign in to comment.