Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests, move tests to mocha, add jshint runner
- Loading branch information
1 parent
e8a6db5
commit fdbaf26
Showing
6 changed files
with
91 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"bitwise": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"forin": true, | ||
"immed": true, | ||
"latedef": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"noempty": true, | ||
"nonew": true, | ||
"regexp": true, | ||
"undef": true, | ||
"strict": true, | ||
"trailing": true, | ||
|
||
"globalstrict": true, | ||
|
||
"white": true, | ||
|
||
"indent": 4, | ||
"maxlen": 80 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FIND_JS="find -name '*.js' ! -path './node_modules/*'" | ||
STATIC="-path './static/*'" | ||
TESTS="-path './test/*'" | ||
JSHINT="xargs -0 -I FILE node_modules/.bin/jshint FILE --show-non-errors" | ||
|
||
sh -c "$FIND_JS ! $STATIC ! $TESTS -print0 | $JSHINT --node | ||
$FIND_JS $TESTS -print0 | $JSHINT --node # --predef describe it | ||
$FIND_JS $STATIC -print0 | $JSHINT --browser" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1 @@ | ||
PATH=$PATH:~/bin expresso -I . test/* | ||
# Expresso somehow disables strict mode, so we use the following as well | ||
NODE_PATH=. node -e 'var tsts = require("./test/tests"), | ||
assert=require("assert"); | ||
for (var i in tsts) { | ||
if (tsts.hasOwnProperty(i)) { | ||
tsts[i](function () {}, assert); | ||
} | ||
} | ||
' | ||
node_modules/.bin/mocha -R spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
"use strict"; | ||
|
||
var should = require('should'); | ||
var lib = require('../lib'); | ||
|
||
describe('numSort', function () { | ||
it('should sort numbers by numeric value, ascending', function () { | ||
should.deepEqual(lib.numSort([1, -4.5, 2, 3, -5, 0, 5, 20, 0.2, 9]), | ||
[-5, -4.5, 0, 0.2, 1, 2, 3, 5, 9, 20]); | ||
}); | ||
|
||
it('should gracefully handle an empty argument', function () { | ||
should.deepEqual(lib.numSort([]), []); | ||
}); | ||
}); | ||
|
||
describe('untilValue', function () { | ||
it('should return a found value which is the first', function (done) { | ||
lib.untilValue([ | ||
1, 5 | ||
], function (val, ncbValHandled) { | ||
ncbValHandled(val === 5, val === 1 ? (val * 2) : undefined); | ||
}, function (errs, res) { | ||
should.not.exist(errs); | ||
res.should.eql(2); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should return a found value which is not the first', function (done) { | ||
lib.untilValue([ | ||
1, 5 | ||
], function (val, ncbValHandled) { | ||
ncbValHandled(val === 1, val === 5 ? (val * 2) : undefined); | ||
}, function (errs, res) { | ||
should.not.exist(errs); | ||
res.should.eql(10); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should return errors if no value found', function (done) { | ||
lib.untilValue([ | ||
1, 5 | ||
], function (val, ncbValHandled) { | ||
ncbValHandled(val * 2); | ||
}, function (errs, res) { | ||
should.exist(errs); | ||
errs.should.eql([2, 10]); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.