Skip to content

Commit

Permalink
fix(callback): fix typo on cancel function
Browse files Browse the repository at this point in the history
closes #1, typo fixed

#1
  • Loading branch information
miketrebilcock committed Mar 27, 2017
1 parent fc40f6f commit f7a0338
Show file tree
Hide file tree
Showing 48 changed files with 74 additions and 2 deletions.
Empty file modified .bithoundrc
100644 → 100755
Empty file.
Empty file modified .eslintrc
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .idea/inspectionProfiles/Project_Default.xml
100644 → 100755
Empty file.
Empty file modified .idea/js-pigpiod.iml
100644 → 100755
Empty file.
Empty file modified .idea/jsLibraryMappings.xml
100644 → 100755
Empty file.
Empty file modified .idea/misc.xml
100644 → 100755
Empty file.
Empty file modified .idea/modules.xml
100644 → 100755
Empty file.
Empty file modified .idea/vcs.xml
100644 → 100755
Empty file.
Empty file modified .idea/watcherTasks.xml
100644 → 100755
Empty file.
Empty file modified .jsinitrc
100644 → 100755
Empty file.
Empty file modified .npmignore
100644 → 100755
Empty file.
Empty file modified .travis.yml
100644 → 100755
Empty file.
Empty file modified LICENCE.txt
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified docs/-_callback.html
100644 → 100755
Empty file.
Empty file modified docs/-_callback.js.html
100644 → 100755
Empty file.
Empty file modified docs/Pigpio.html
100644 → 100755
Empty file.
Empty file modified docs/definitions.js.html
100644 → 100755
Empty file.
Empty file modified docs/global.html
100644 → 100755
Empty file.
Empty file modified docs/index.html
100644 → 100755
Empty file.
Empty file modified docs/index.js.html
100644 → 100755
Empty file.
Empty file modified docs/pigpio.html
100644 → 100755
Empty file.
Empty file modified docs/scripts/linenumber.js
100644 → 100755
Empty file.
Empty file modified docs/scripts/prettify/Apache-License-2.0.txt
100644 → 100755
Empty file.
Empty file modified docs/scripts/prettify/lang-css.js
100644 → 100755
Empty file.
Empty file modified docs/scripts/prettify/prettify.js
100644 → 100755
Empty file.
Empty file modified docs/styles/jsdoc.css
100644 → 100755
Empty file.
Empty file modified docs/styles/prettify.css
100644 → 100755
Empty file.
Empty file modified examples/edge_detection.js
100644 → 100755
Empty file.
Empty file modified examples/getHardwareRevision.js
100644 → 100755
Empty file.
Empty file modified examples/js-pwm.js
100644 → 100755
Empty file.
Empty file modified examples/test_read_write.js
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion js-pigpio/_callback.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class _callback {
*/
cancel () {
"use strict";
this._notfy.remove(this._callback);
this._notify.remove(this._callback);
}

/**
Expand Down
Empty file modified js-pigpio/definitions.js
100644 → 100755
Empty file.
Empty file modified js-pigpio/index.js
100644 → 100755
Empty file.
Empty file modified js-pigpio/utils.js
100644 → 100755
Empty file.
Empty file modified jsdoc.json
100644 → 100755
Empty file.
Empty file modified package.json
100644 → 100755
Empty file.
Empty file modified test/eslint.spec.js
100644 → 100755
Empty file.
Empty file modified test/mocha.opts
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion test/pigpio.advanced.spec.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let server;

describe('advanced', () => {

const port = 5001;
const port = 5031;

before(()=> {
server = new testServer(port);
Expand Down
Empty file modified test/pigpio.beginner.spec.js
100644 → 100755
Empty file.
Empty file modified test/pigpio.essential.spec.js
100644 → 100755
Empty file.
Empty file modified test/pigpio.intermediate.spec.js
100644 → 100755
Empty file.
Empty file modified test/pigpio.utils.spec.js
100644 → 100755
Empty file.
Empty file modified test/testhelper.js
100644 → 100755
Empty file.
72 changes: 72 additions & 0 deletions test/utils.spec.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/*global it describe context */

const assert = require('chai').assert;
const expect = require('chai').expect;
const reverse_string_and_clean = require('../js-pigpio/utils.js').reverse_string_and_clean;
const reverse_string = require('../js-pigpio/utils.js').reverse_string;
const _socklock = require('../js-pigpio/utils.js')._socklock;
const _pi_gpio_command = require('../js-pigpio/utils.js')._pi_gpio_command;

describe('js-pigpio-utils', () => {

Expand All @@ -20,4 +23,73 @@ describe('js-pigpio-utils', () => {

});
});

context('_socklock class', () => {
it('initialises with parameters', () => {
const test = new _socklock('192.168.1.1',5000);
assert(test.host === '192.168.1.1', 'Host was not held');
assert(test.port === 5000, 'Port was not held');
});
it('Places only one lock on a server and port', () => {
const test = new _socklock('192.168.1.1',5000);
test._acquireLock();
test._acquireLock();
expect((done) => {
test._acquireLock();
done();
}).to.throw(Error);
});
it('Places more than one lock on a server', () => {
const test = new _socklock('192.168.1.1',5000);
const test2 = new _socklock('192.168.1.1',5001);
const test3 = new _socklock('192.168.1.1',5002);
test._acquireLock();
test2._acquireLock();
test3._acquireLock();
});
it('locks, releases and relocks on a server and port', () => {
const test = new _socklock('192.168.1.1',5000);
test._acquireLock();
test._releaseLock();
test._acquireLock();
expect((done) => {
test._acquireLock();
done();
}).to.throw(Error);
});
});

context('_pi_gpio_command', () => {
it('checks that socketlock is present', () => {
const test = {};
expect(() => {
_pi_gpio_command(test, 0, 0, 0);
}).to.throw(Error);
});

it('checks that command is present', () => {
const test = new _socklock('192.168.1.1',5000);
expect(() => {
_pi_gpio_command(test);
}).to.throw(Error);
});

it('reports an error when data send fails', () => {
const test = new _socklock('192.168.1.1',5000);
test.s = {write(){return false;}};
expect(() => {
_pi_gpio_command(test,1);
}).to.throw(Error);
});

it('places a lock', () => {
const test = new _socklock('192.168.1.1',5000);
test.s = {write(){return true;}};
_pi_gpio_command(test,1,0,0,0,true);
expect(() => {
test._acquireLock();
}).to.throw(Error);
});

});
});

0 comments on commit f7a0338

Please sign in to comment.