Skip to content

Commit

Permalink
TDD
Browse files Browse the repository at this point in the history
  • Loading branch information
Neamar committed Jun 6, 2014
1 parent 78b4e7a commit e2ab5e4
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ module.exports = function rarity(arg, cb) {
}
};

module.exports.pad = require('./pad.js');
module.exports.carry = require('./carry.js');
module.exports.pad = require('./pad');
module.exports.carry = require('./carry');
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"main": "./lib",
"repository": {
"type": "git",
"url": "https://github.com/AnyFetch/rarity"
"url": "https://github.com/Neamar/rarity"
},
"keywords": [
"rarity",
Expand Down
76 changes: 76 additions & 0 deletions test/carry-arguments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"use strict";

var should = require('should');
var rarity = require('../lib/');

describe('rarity.carry()', function() {
var EXPECTED_RESULT = "expectedResult";

var noop = function() {};

it("should fail with non array", function(done) {
try {
rarity.carry("nope", noop);
}
catch(e) {
e.toString().should.containDeep('must be an array');
return done();
}

done(new Error("Should not be working"));
});

it.only("should fail without function as second argument", function(done) {
try {
rarity.carry([], 4);
}
catch(e) {
e.toString().should.containDeep('must be a function');
return done();
}

done(new Error("Should not be working"));
});

it("should carry arguments", function(done) {
var original = function(cb) {
cb('error', EXPECTED_RESULT);
};

original(rarity.carry(['carry'], function(c1, c2, c3) {
c1.should.eql('error');
c2.should.eql('carry');
c3.should.eql(EXPECTED_RESULT);
arguments.should.have.lengthOf(3);
done();
}));
});

it("should carry arguments when cb only launch err", function(done) {
var original = function(cb) {
cb('error');
};

original(rarity.carry(['carry'], function(c1, c2) {
c1.should.eql('error');
c2.should.eql('carry');
arguments.should.have.lengthOf(2);

done();
}));
});

it("should carry arguments when cb don't render anything", function(done) {
var original = function(cb) {
cb();
};

original(rarity.carry(['carry'], function(c1, c2) {
c1.should.eql(null);
c2.should.eql('carry');
arguments.should.have.lengthOf(2);

done();
}));
});
});
2 changes: 1 addition & 1 deletion test/pad-arguments.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

var should = require('should');
var rarity = require('../');
var rarity = require('../lib/');

describe('rarity.pad()', function() {
var EXPECTED_RESULT = "expectedResult";
Expand Down
2 changes: 1 addition & 1 deletion test/slice-arguments.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

var should = require('should');
var rarity = require('../');
var rarity = require('../lib/');

describe('rarity()', function() {
var EXPECTED_RESULT = "expectedResult";
Expand Down

0 comments on commit e2ab5e4

Please sign in to comment.