Skip to content

Commit

Permalink
Switch from chai-factories to chai-js-factories
Browse files Browse the repository at this point in the history
  • Loading branch information
ndhoule committed Sep 3, 2014
1 parent 5fc0ed7 commit 98b25cc
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 30 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"blanket": "^1.1.6",
"bluebird": "^2.3.0",
"chai": "^1.9.1",
"chai-factories": "^0.1.0",
"chai-js-factories": "git+https://github.com/ndhoule/chai-js-factories.git",
"coveralls": "^2.11.1",
"dox": "^0.4.6",
"exec-sync": "^0.1.6",
Expand All @@ -31,7 +31,7 @@
"html-minifier": "^0.6.6",
"karma": "^0.12.23",
"karma-chai": "^0.1.0",
"karma-chai-factories": "git+https://github.com/ndhoule/karma-chai-factories.git",
"karma-chai-js-factories": "git+https://github.com/ndhoule/karma-chai-js-factories.git",
"karma-chrome-launcher": "^0.1.4",
"karma-cli": "0.0.4",
"karma-mocha": "^0.1.9",
Expand Down
2 changes: 1 addition & 1 deletion test/config/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = function(config) {

config.set({
basePath: '../..',
frameworks: ['mocha', 'sinon-chai', 'chai-factories', 'chai'],
frameworks: ['mocha', 'sinon-chai', 'chai-js-factories', 'chai'],
reporters: ['dots', 'saucelabs'],
colors: true,
port: 9876,
Expand Down
2 changes: 1 addition & 1 deletion test/config/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ global.sinon = require('sinon');

// Chai plugins
chai.use(require('sinon-chai'));
chai.use(require('chai-factories'));
chai.use(require('chai-js-factories'));

// Load factories
fs.readdirSync(FACTORIES_PATH)
Expand Down
34 changes: 18 additions & 16 deletions test/factories/functions.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
var add = function add(a, b) { return a + b; };
chai.factory.define('functions', function() {
var add = function add(a, b) { return a + b; };

var always = function always(val) {
return function() {
return val;
var always = function always(val) {
return function() {
return val;
};
};
};

var eq = function eq(originalVal) {
return function(val) { return val === originalVal; };
};
var eq = function eq(originalVal) {
return function(val) { return val === originalVal; };
};

var identity = function identity(val) { return val; };
var identity = function identity(val) { return val; };

var reduce = function reduce(fn, acc, list) { return list.reduce(fn, acc); };
var reduce = function reduce(fn, acc, list) { return list.reduce(fn, acc); };

chai.factory('functions', {
add: add,
always: always,
eq: eq,
identity: identity,
reduce: reduce,
return {
add: add,
always: always,
eq: eq,
identity: identity,
reduce: reduce,
};
});
2 changes: 1 addition & 1 deletion test/unit/collection/foldl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('foldl', function() {

beforeEach(function() {
observe = sinon.spy(identity);
add = sinon.spy(chai.create('functions').add);
add = sinon.spy(chai.factory.create('functions').add);
});

it('should be a function', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/function/arity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('arity', function() {
var add;

beforeEach(function() {
add = sinon.spy(chai.create('functions').add);
add = sinon.spy(chai.factory.create('functions').add);
});

it('should be a function', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/function/compose.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('compose', function() {
var add;

beforeEach(function() {
add = sinon.spy(chai.create('functions').add);
add = sinon.spy(chai.factory.create('functions').add);
});

it('should be a function', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/function/curry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var curry = fungus.curry;

describe('curry', function() {
var add, curriedAdd, reduce, curriedReduce;
var functions = chai.create('functions');
var functions = chai.factory.create('functions');

beforeEach(function() {
add = sinon.spy(functions.add);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/function/lPartial.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('lPartial', function() {
var add;

beforeEach(function() {
add = sinon.spy(chai.create('functions').add);
add = sinon.spy(chai.factory.create('functions').add);
});

it('should be a function', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/function/memoize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var identity = fungus.identity;

describe('memoize', function() {
var memoAdd, memoIdentity;
var add = chai.create('functions').add;
var add = chai.factory.create('functions').add;

beforeEach(function() {
add = sinon.spy(add);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/function/rPartial.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('rPartial', function() {
var add;

beforeEach(function() {
add = sinon.spy(chai.create('functions').add);
add = sinon.spy(chai.factory.create('functions').add);
});

it('should be a function', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/object/clone.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,5 @@ describe('clone', function() {
// xit('should handle the ' + name + ' host object', function() {
// new Function('clone', 'obj', 'expect(clone(obj)).to.equal(obj);')(clone, HostObject);
// });
// }, chai.create('hostObjects'));
// }, chai.factory.create('hostObjects'));
});
2 changes: 1 addition & 1 deletion test/unit/object/findKey.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe('findKey', function() {
var findKey = fungus.findKey;

var alwaysFalse, alwaysTrue, animals, eq, observe;
var fns = chai.create('functions');
var fns = chai.factory.create('functions');

beforeEach(function() {
alwaysFalse = sinon.spy(fns.always(false));
Expand Down
2 changes: 1 addition & 1 deletion test/unit/object/findKeyLast.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe('findKeyLast', function() {
var findKeyLast = fungus.findKeyLast;

var alwaysFalse, alwaysTrue, animals, eq, observe;
var fns = chai.create('functions');
var fns = chai.factory.create('functions');

beforeEach(function() {
alwaysFalse = sinon.spy(fns.always(false));
Expand Down

0 comments on commit 98b25cc

Please sign in to comment.