Replace chai with expect

Fixes #17
main
Aaron Jensen 2015-08-12 22:31:01 -07:00
parent f0648c89f9
commit f7e570934d
14 changed files with 125 additions and 130 deletions

View File

@ -35,9 +35,9 @@
"babel-eslint": "^4.0.5",
"babel-loader": "^5.3.2",
"benchmark": "^1.0.0",
"chai": "^3.2.0",
"eslint": "^0.24.1",
"eslint-config-airbnb": "0.0.7",
"expect": "^1.9.0",
"exports-loader": "^0.6.2",
"gulp": "^3.6.0",
"gulp-babel": "^5.1.0",

View File

@ -1,5 +0,0 @@
{
"rules": {
"no-unused-expressions": 0
}
}

View File

@ -1,17 +1,17 @@
import { expect } from 'chai';
import expect from 'expect';
import u from '../lib';
describe('u.constant', () => {
it('returns what it is given... constantly', () => {
const func = u.constant(4);
expect(func()).to.equal(4);
expect(func('hi')).to.equal(4);
expect(func('hi', 8)).to.equal(4);
expect(func(4)).to.equal(4);
expect(func()).toBe(4);
expect(func('hi')).toBe(4);
expect(func('hi', 8)).toBe(4);
expect(func(4)).toBe(4);
});
it('freezes the result', () => {
expect(Object.isFrozen(u.constant({})())).to.be.true;
expect(Object.isFrozen(u.constant({})())).toBe(true);
});
});

View File

@ -1,4 +1,4 @@
import { expect } from 'chai';
import expect from 'expect';
import u from '../lib';
describe('u.freeze', () => {
@ -10,29 +10,29 @@ describe('u.freeze', () => {
const object = {};
u.freeze(object);
expect(Object.isFrozen(object)).to.be.true;
expect(Object.isFrozen(object)).toBe(true);
});
it('freezes nested objects', () => {
const object = { foo: { bar: 3 } };
u.freeze(object);
expect(Object.isFrozen(object.foo)).to.be.true;
expect(Object.isFrozen(object.foo)).toBe(true);
});
it('freezes nested arrays', () => {
const object = [[0]];
u.freeze(object);
expect(Object.isFrozen(object)).to.be.true;
expect(Object.isFrozen(object[0])).to.be.true;
expect(Object.isFrozen(object)).toBe(true);
expect(Object.isFrozen(object[0])).toBe(true);
});
it('ignores functions', () => {
const object = { foo: () => 1 };
u.freeze(object);
expect(Object.isFrozen(object.foo)).to.be.false;
expect(Object.isFrozen(object.foo)).toBe(false);
});
it('does not freeze children if the parent is already frozen', () => {
@ -40,7 +40,7 @@ describe('u.freeze', () => {
Object.freeze(object);
u.freeze(object);
expect(Object.isFrozen(object.foo)).to.be.false;
expect(Object.isFrozen(object.foo)).toBe(false);
});
it('does not freeze in production', () => {
@ -48,18 +48,18 @@ describe('u.freeze', () => {
const object = {};
u.freeze(object);
expect(Object.isFrozen(object)).to.be.false;
expect(Object.isFrozen(object)).toBe(false);
});
it('handles null objects', () => {
const object = { foo: null };
u.freeze(object);
expect(Object.isFrozen(object)).to.be.true;
expect(Object.isFrozen(object)).toBe(true);
});
it('returns the same object', () => {
const object = {};
const result = u.freeze(object);
expect(result).to.equal(object);
expect(result).toBe(object);
});
});

View File

@ -1,17 +1,17 @@
import { expect } from 'chai';
import expect from 'expect';
import u from '../lib';
describe('u.if', () => {
it('does not update if the predicate is false', () => {
const object = { a: 0 };
const result = u.if(false, { b: 1 }, object);
expect(result).to.eql(object);
expect(result).toEqual(object);
});
it('does update if the predicate is true', () => {
const object = { a: 0 };
const result = u.if(true, { b: 1 }, object);
expect(result).to.eql({ a: 0, b: 1 });
expect(result).toEqual({ a: 0, b: 1 });
});
it('will use the result of a function passed as a predicate', () => {
@ -19,7 +19,7 @@ describe('u.if', () => {
const aIsThree = x => x.a === 3;
const result = u.if(aIsThree, { b: 1 }, object);
expect(result).to.eql({ a: 0 });
expect(result).toEqual({ a: 0 });
});
it('can be partially applied', () => {
@ -31,11 +31,11 @@ describe('u.if', () => {
a: u.if(isEven, inc),
}, object);
expect(result).to.eql({ a: 3 });
expect(result).toEqual({ a: 3 });
});
it('freezes the result', () => {
expect(Object.isFrozen(u.if(true, {}, {}))).to.be.true;
expect(Object.isFrozen(u.if(false, {}, {}))).to.be.true;
expect(Object.isFrozen(u.if(true, {}, {}))).toBe(true);
expect(Object.isFrozen(u.if(false, {}, {}))).toBe(true);
});
});

View File

@ -1,17 +1,17 @@
import { expect } from 'chai';
import expect from 'expect';
import u from '../lib';
describe('u.ifElse', () => {
it('does updates with the else if the predicate is false', () => {
const object = { a: 0 };
const result = u.ifElse(false, { b: 1 }, { b: 2 }, object);
expect(result).to.eql({ a: 0, b: 2 });
expect(result).toEqual({ a: 0, b: 2 });
});
it('updates with the true update if the predicate is true', () => {
const object = { a: 0 };
const result = u.ifElse(true, { b: 1 }, { b: 4 }, object);
expect(result).to.eql({ a: 0, b: 1 });
expect(result).toEqual({ a: 0, b: 1 });
});
it('will use the result of a function passed as a predicate', () => {
@ -19,7 +19,7 @@ describe('u.ifElse', () => {
const aIsThree = x => x.a === 3;
const result = u.ifElse(aIsThree, { b: 1 }, { b: 4 }, object);
expect(result).to.eql({ a: 0, b: 4 });
expect(result).toEqual({ a: 0, b: 4 });
});
it('can be partially applied', () => {
@ -32,11 +32,11 @@ describe('u.ifElse', () => {
a: u.ifElse(isEven, inc, dec),
}, object);
expect(result).to.eql({ a: 3 });
expect(result).toEqual({ a: 3 });
});
it('freezes the result', () => {
expect(Object.isFrozen(u.ifElse(true, {}, {}, {}))).to.be.true;
expect(Object.isFrozen(u.ifElse(false, {}, {}, {}))).to.be.true;
expect(Object.isFrozen(u.ifElse(true, {}, {}, {}))).toBe(true);
expect(Object.isFrozen(u.ifElse(false, {}, {}, {}))).toBe(true);
});
});

View File

@ -1,59 +1,59 @@
import { expect } from 'chai';
import expect from 'expect';
import u from '../lib';
describe('u.is', () => {
it('returns true if path matches a value predicate', () => {
const result = u.is('a.b', 4, { a: { b: 4 } });
expect(result).to.be.true;
expect(result).toBe(true);
});
it('returns true if path matches a function predicate', () => {
const isEven = x => x % 2 === 0;
const result = u.is('a.b', isEven, { a: { b: 6 } });
expect(result).to.be.true;
expect(result).toBe(true);
});
it('returns false if path matches a value predicate', () => {
const result = u.is('a.b', 4, { a: { b: 5 } });
expect(result).to.be.false;
expect(result).toBe(false);
});
it('returns false if path matches a function predicate', () => {
const isEven = x => x % 2 === 0;
const result = u.is('a.b', isEven, { a: { b: 7 } });
expect(result).to.be.false;
expect(result).toBe(false);
});
it('returns false if the path does not exist', () => {
const result = u.is('a.b.c.d', 4, { a: { b: {} } });
expect(result).to.be.false;
expect(result).toBe(false);
});
it('can test for undefined', () => {
const result = u.is('a.b.c', undefined, { a: { b: {} } });
expect(result).to.be.true;
expect(result).toBe(true);
});
it('tests the actual object if a blank path is given', () => {
const result = u.is('', 4, 4);
expect(result).to.be.true;
expect(result).toBe(true);
});
it('can use arrays as paths', () => {
const result = u.is(['a', 'b'], 4, { a: { b: 4 } });
expect(result).to.be.true;
expect(result).toBe(true);
});
it('can include array indexes in paths', () => {
let result = u.is('a.1.b', 4, { a: [{}, { b: 4 }] });
expect(result).to.be.true;
expect(result).toBe(true);
result = u.is(['a', 1, 'b'], 4, { a: [{}, { b: 4 }] });
expect(result).to.be.true;
expect(result).toBe(true);
});
it('can be partially applied', () => {
const result = u.is('a.b')(4)({ a: { b: 4 } });
expect(result).to.be.true;
expect(result).toBe(true);
});
});

View File

@ -1,4 +1,4 @@
import { expect } from 'chai';
import expect from 'expect';
import u from '../lib';
describe('u.map', () => {
@ -7,7 +7,7 @@ describe('u.map', () => {
const inc = x => x + 1;
const result = u.map(inc, object);
expect(result).to.eql([1, 2, 3]);
expect(result).toEqual([1, 2, 3]);
});
it('applies updates to each value in an object', () => {
@ -15,14 +15,14 @@ describe('u.map', () => {
const inc = x => x + 1;
const result = u.map(inc, object);
expect(result).to.eql({ a: 1, b: 2, c: 3 });
expect(result).toEqual({ a: 1, b: 2, c: 3 });
});
it('can update with a regular updates object', () => {
const object = [{ a: 0 }, { a: 0 }];
const result = u.map({ a: 1 }, object);
expect(result).to.eql([{ a: 1 }, { a: 1 }]);
expect(result).toEqual([{ a: 1 }, { a: 1 }]);
});
it('returns the same object if no updates are made', () => {
@ -30,12 +30,12 @@ describe('u.map', () => {
const ident = x => x;
let result = u.map(ident, array);
expect(result).to.equal(array);
expect(result).toBe(array);
const object = { a: 0 };
result = u.map(ident, object);
expect(result).to.equal(object);
expect(result).toBe(object);
});
it('passes the key or index as the second parameter to the iteratee', () => {
@ -46,7 +46,7 @@ describe('u.map', () => {
const setToKey = (_, key) => key;
const result = u.map(u.map(setToKey), object);
expect(result).to.eql( {
expect(result).toEqual( {
a: { x: 'x' },
b: [0, 1],
});
@ -61,12 +61,12 @@ describe('u.map', () => {
b: u.map(setToKey),
}, object);
expect(result).to.eql( {
expect(result).toEqual( {
b: [0, 1],
});
});
it('freezes the result', () => {
expect(Object.isFrozen(u.map({}, {}))).to.be.true;
expect(Object.isFrozen(u.map({}, {}))).toBe(true);
});
});

View File

@ -1,14 +1,14 @@
import { expect } from 'chai';
import expect from 'expect';
import u from '../lib';
describe('u.omit', () => {
it('can omit a key', () => {
const result = u({ foo: u.omit('bar') }, { foo: { bar: 7 } });
expect(result).to.eql({ foo: {} });
expect(result).toEqual({ foo: {} });
});
it('freezes the result', () => {
expect(Object.isFrozen(u.omit('a', {}))).to.be.true;
expect(Object.isFrozen(u.omit('a', {}))).toBe(true);
});
});

View File

@ -1,8 +1,8 @@
import { expect } from 'chai';
import expect from 'expect';
import u from '../lib';
describe('u.reject', () => {
it('freezes the result', () => {
expect(Object.isFrozen(u.reject('a', []))).to.be.true;
expect(Object.isFrozen(u.reject('a', []))).toBe(true);
});
});

View File

@ -1,45 +1,45 @@
import { expect } from 'chai';
import expect from 'expect';
import u from '../lib';
describe('u.updateIn', () => {
it('can update a single path described with a string', () => {
const object = { a: { b: 0 } };
const result = u.updateIn('a.b', 3, object);
expect(result).to.eql({ a: { b: 3 } });
expect(result).toEqual({ a: { b: 3 } });
});
it('can update a single path described with a string with a function', () => {
const inc = x => x + 1;
const object = { a: { b: 0 } };
const result = u.updateIn('a.b', inc, object);
expect(result).to.eql({ a: { b: 1 } });
expect(result).toEqual({ a: { b: 1 } });
});
it('can update a single path described with an array', () => {
const object = { a: { b: 0 } };
const result = u.updateIn(['a', 'b'], 3, object);
expect(result).to.eql({ a: { b: 3 } });
expect(result).toEqual({ a: { b: 3 } });
});
it('can update arrays', () => {
const object = { a: [0, 0, 0] };
const result = u.updateIn('a.1', 3, object);
expect(result).to.eql({ a: [0, 3, 0] });
expect(result).toEqual({ a: [0, 3, 0] });
});
it('can be partially applied', () => {
const object = { a: { b: 0 } };
const result = u.updateIn('a.b')(3)(object);
expect(result).to.eql({ a: { b: 3 } });
expect(result).toEqual({ a: { b: 3 } });
});
it('replaces the object outright if the path is empty', () => {
const object = {};
const result = u.updateIn('', 3, object);
expect(result).to.equal(3);
expect(result).toBe(3);
});
it('freezes the result', () => {
expect(Object.isFrozen(u.updateIn('a', 0, {}))).to.be.true;
expect(Object.isFrozen(u.updateIn('a', 0, {}))).toBe(true);
});
});

View File

@ -1,4 +1,4 @@
import { expect } from 'chai';
import expect from 'expect';
import u from '../lib';
describe('updeep', () => {
@ -6,54 +6,54 @@ describe('updeep', () => {
const object = { foo: 3, bar: [7, 5] };
const result = u({}, object);
expect(result).to.equal(object);
expect(result).toBe(object);
});
it('can update with fixed values', () => {
const object = { foo: 3, bar: [7, 5] };
const result = u({ foo: 4 }, object);
expect(result).to.deep.equal({ foo: 4, bar: [7, 5] });
expect(result).toEqual({ foo: 4, bar: [7, 5] });
});
it('returns the same instance if an update doesn\'t make changes', () => {
const object = { foo: 3 };
const result = u({ foo: 3 }, object);
expect(result).to.equal(object);
expect(result).toBe(object);
});
it('can update a nested structure', () => {
const object = { foo: { bar: 7, bam: 3 }, baz: 32 };
const result = u({ foo: { bar: 8 } }, object);
expect(result).to.deep.equal({ foo: { bar: 8, bam: 3 }, baz: 32 });
expect(result).toEqual({ foo: { bar: 8, bam: 3 }, baz: 32 });
});
it('can update arrays', () => {
const object = [1, 2, 3];
const result = u({ 1: 7 }, object);
expect(result).to.deep.equal([1, 7, 3]);
expect(result).toEqual([1, 7, 3]);
});
it('replaces the object outright if updates are a constant', () => {
expect(u(3, {})).to.equal(3);
expect(u(null, {})).to.be.null;
expect(u(3, {})).toBe(3);
expect(u(null, {})).toBe(null);
});
it('can add an element to an array', () => {
const object = [];
const result = u({ 0: 3 }, object);
expect(result).to.eql([3]);
expect(result).toEqual([3]);
});
it('can update nested arrays', () => {
const object = { foo: [1, 2, 3], bar: 9 };
const result = u({ foo: { 1: 7 } }, object);
expect(result).to.deep.equal({ foo: [1, 7, 3], bar: 9 });
expect(result).toEqual({ foo: [1, 7, 3], bar: 9 });
});
it('can use functions to update values', () => {
@ -61,7 +61,7 @@ describe('updeep', () => {
const object = { foo: 3, bar: 4, baz: 7 };
const result = u({ foo: inc, bar: inc }, object);
expect(result).to.deep.equal({ foo: 4, bar: 5, baz: 7 });
expect(result).toEqual({ foo: 4, bar: 5, baz: 7 });
});
it('can be partially applied', () => {
@ -71,44 +71,44 @@ describe('updeep', () => {
const result = incFoo(object);
expect(result).to.deep.equal({ foo: 4 });
expect(result).toEqual({ foo: 4 });
});
it('passes additional arguments on to updates if it is a function', () => {
const func = (_, x) => x;
const result = u(func, 0, 4);
expect(result).to.equal(4);
expect(result).toBe(4);
});
it('can update if the value is an array', () => {
const object = {};
const result = u({ foo: [0, 1] }, object);
expect(result).to.deep.equal({ foo: [0, 1] });
expect(result).toEqual({ foo: [0, 1] });
});
it('can update when original object is undefined', () => {
const result = u({ foo: [0, 1] }, undefined);
expect(result).to.deep.equal({ foo: [0, 1] });
expect(result).toEqual({ foo: [0, 1] });
});
it('can take a function as the updater', () => {
const result = u(i => i + 1, 7);
expect(result).to.eql(8);
expect(result).toEqual(8);
});
it('deeply freezes the result', () => {
const result = u({ foo: { bar: 3 } }, { foo: { bar: 0 } });
expect(Object.isFrozen(result)).to.be.true;
expect(Object.isFrozen(result.foo)).to.be.true;
expect(Object.isFrozen(result)).toBe(true);
expect(Object.isFrozen(result.foo)).toBe(true);
});
it('assigns null values', () => {
expect(u({isNull: null}, {})).to.eql({isNull: null});
expect(u({isNull: null}, {})).toEqual({isNull: null});
});
it('can use a placeholder to partially apply', () => {
@ -116,17 +116,17 @@ describe('updeep', () => {
const updateJoe = u(u._, { name: 'Joe Merrill', age: 21 });
const result = updateJoe({ age: increment });
expect(result).to.eql({ name: 'Joe Merrill', age: 22 });
expect(result).toEqual({ name: 'Joe Merrill', age: 22 });
});
it('defaults to an empty object when null or undefined', () => {
let result = u({ a: { b: 0 } }, { a: null });
expect(result).to.eql({ a: { b: 0 } });
expect(result).toEqual({ a: { b: 0 } });
result = u({ a: { b: 0 } }, { a: undefined });
expect(result).to.eql({ a: { b: 0 } });
expect(result).toEqual({ a: { b: 0 } });
result = u({ a: { b: 0 } }, { });
expect(result).to.eql({ a: { b: 0 } });
expect(result).toEqual({ a: { b: 0 } });
});
});

View File

@ -1,90 +1,90 @@
import { expect } from 'chai';
import expect from 'expect';
import { curry1, curry2, curry3, curry4, _ } from '../../lib/util/curry';
describe('curry1', () => {
it('can curry one arguments', () => {
const addOne = curry1((x) => x + 1);
expect(addOne(3)).to.equal(4);
expect(addOne()(3)).to.equal(4);
expect(addOne(3)).toBe(4);
expect(addOne()(3)).toBe(4);
});
it('will take up to two extra arguments', () => {
const curried = curry1((a, b, c) => [a, b, c]);
expect(curried(1, 2, 3, 4)).to.eql([1, 2, 3]);
expect(curried(1, 2, 3, 4)).toEqual([1, 2, 3]);
});
});
describe('curry2', () => {
it('can curry two arguments', () => {
const add = curry2((x, y) => x + y);
expect(add(3)(4)).to.equal(7);
expect(add()(3)()(4)).to.equal(7);
expect(add(3, 4)).to.equal(7);
expect(add(3)(4)).toBe(7);
expect(add()(3)()(4)).toBe(7);
expect(add(3, 4)).toBe(7);
});
it('will take up to two extra arguments', () => {
const curried = curry2((a, b, c, d) => [a, b, c, d]);
expect(curried(1, 2, 3, 4, 5)).to.eql([1, 2, 3, 4]);
expect(curried(1, 2, 3, 4, 5)).toEqual([1, 2, 3, 4]);
});
it('can use the placeholder', () => {
const curried = curry2((a, b, c, d) => [a, b, c, d]);
expect(curried(_, 2)(1, 3, 4)).to.eql([1, 2, 3, 4]);
expect(curried(_, 2)(1, 3, 4)).toEqual([1, 2, 3, 4]);
});
});
describe('curry3', () => {
it('can curry three arguments', () => {
const add = curry3((x, y, z) => x + y + z);
expect(add(3, _)(4)(5)).to.equal(12);
expect(add()(3)()(4, 5)).to.equal(12);
expect(add(3, 4, 5)).to.equal(12);
expect(add(3, _)(4)(5)).toBe(12);
expect(add()(3)()(4, 5)).toBe(12);
expect(add(3, 4, 5)).toBe(12);
});
it('will take up to two extra arguments', () => {
const curried = curry3((a, b, c, d, e) => [a, b, c, d, e]);
expect(curried(1, 2, 3, 4, 5, 6)).to.eql([1, 2, 3, 4, 5]);
expect(curried(1, 2, 3, 4, 5, 6)).toEqual([1, 2, 3, 4, 5]);
});
it('can use the placeholder', () => {
const curried = curry3((a, b, c, d, e) => [a, b, c, d, e]);
expect(curried(_, 2)('a', 3, 4, 5)).to.eql(['a', 2, 3, 4, 5]);
expect(curried('b', _, 3)(2, 4, 5)).to.eql(['b', 2, 3, 4, 5]);
expect(curried(_, 2, 3)('c', 4, 5)).to.eql(['c', 2, 3, 4, 5]);
expect(curried(_, _, 3)('d', 2, 4, 5)).to.eql(['d', 2, 3, 4, 5]);
expect(curried(_, 2)('a', 3, 4, 5)).toEqual(['a', 2, 3, 4, 5]);
expect(curried('b', _, 3)(2, 4, 5)).toEqual(['b', 2, 3, 4, 5]);
expect(curried(_, 2, 3)('c', 4, 5)).toEqual(['c', 2, 3, 4, 5]);
expect(curried(_, _, 3)('d', 2, 4, 5)).toEqual(['d', 2, 3, 4, 5]);
});
});
describe('curry4', () => {
it('can curry four arguments', () => {
const add = curry4((x, y, z, u) => x + y + z + u);
expect(add(3, _)(4)(5)(6)).to.equal(18);
expect(add()(3)()(4, 5, 6)).to.equal(18);
expect(add(3, 4, 5, 6)).to.equal(18);
expect(add(3, _)(4)(5)(6)).toBe(18);
expect(add()(3)()(4, 5, 6)).toBe(18);
expect(add(3, 4, 5, 6)).toBe(18);
});
it('will take up to two extra arguments', () => {
const curried = curry4((a, b, c, d, e, f) => [a, b, c, d, e, f]);
expect(curried(1, 2, 3, 4, 5, 6, 7)).to.eql([1, 2, 3, 4, 5, 6]);
expect(curried(1, 2, 3, 4, 5, 6, 7)).toEqual([1, 2, 3, 4, 5, 6]);
});
it('can use the placeholder', () => {
const curried = curry4((a, b, c, d, e, f) => [a, b, c, d, e, f]);
expect(curried(_, 2)('a', 3, 4, 5, 6)).to.eql(['a', 2, 3, 4, 5, 6]);
expect(curried(_, 2, 3)('b', 4, 5, 6)).to.eql(['b', 2, 3, 4, 5, 6]);
expect(curried(_, 2, 3, 4)('c', 5, 6)).to.eql(['c', 2, 3, 4, 5, 6]);
expect(curried(_, 2)('a', 3, 4, 5, 6)).toEqual(['a', 2, 3, 4, 5, 6]);
expect(curried(_, 2, 3)('b', 4, 5, 6)).toEqual(['b', 2, 3, 4, 5, 6]);
expect(curried(_, 2, 3, 4)('c', 5, 6)).toEqual(['c', 2, 3, 4, 5, 6]);
expect(curried('d', _, 3)(2, 4, 5, 6)).to.eql(['d', 2, 3, 4, 5, 6]);
expect(curried('e', _, 3, 4)(2, 5, 6)).to.eql(['e', 2, 3, 4, 5, 6]);
expect(curried('d', _, 3)(2, 4, 5, 6)).toEqual(['d', 2, 3, 4, 5, 6]);
expect(curried('e', _, 3, 4)(2, 5, 6)).toEqual(['e', 2, 3, 4, 5, 6]);
expect(curried('f', 2, _, 4)(3, 5, 6)).to.eql(['f', 2, 3, 4, 5, 6]);
expect(curried('f', 2, _, 4)(3, 5, 6)).toEqual(['f', 2, 3, 4, 5, 6]);
expect(curried(_, _, 3)('g', 2, 4, 5, 6)).to.eql(['g', 2, 3, 4, 5, 6]);
expect(curried(_, _, 3, 4)('h', 2, 5, 6)).to.eql(['h', 2, 3, 4, 5, 6]);
expect(curried(_, 2, _, 4)('i', 3, 5, 6)).to.eql(['i', 2, 3, 4, 5, 6]);
expect(curried(_, _, 3)('g', 2, 4, 5, 6)).toEqual(['g', 2, 3, 4, 5, 6]);
expect(curried(_, _, 3, 4)('h', 2, 5, 6)).toEqual(['h', 2, 3, 4, 5, 6]);
expect(curried(_, 2, _, 4)('i', 3, 5, 6)).toEqual(['i', 2, 3, 4, 5, 6]);
expect(curried('j', _, _, 4)(2, 3, 5, 6)).to.eql(['j', 2, 3, 4, 5, 6]);
expect(curried('j', _, _, 4)(2, 3, 5, 6)).toEqual(['j', 2, 3, 4, 5, 6]);
expect(curried(_, _, _, 4)('k', 2, 3, 5, 6)).to.eql(['k', 2, 3, 4, 5, 6]);
expect(curried(_, _, _, 4)('k', 2, 3, 5, 6)).toEqual(['k', 2, 3, 4, 5, 6]);
});
});

View File

@ -1,4 +1,4 @@
import { expect } from 'chai';
import expect from 'expect';
import u from '../lib';
describe('u.withDefault', () => {
@ -6,14 +6,14 @@ describe('u.withDefault', () => {
const inc = x => x + 1;
const result = u.withDefault({ a: 0 }, { a: inc }, undefined);
expect(result).to.eql({ a: 1 });
expect(result).toEqual({ a: 1 });
});
it('uses ignores the default if the object is defined', () => {
const inc = x => x + 1;
const result = u.withDefault({ a: 0 }, { a: inc }, { a: 3 });
expect(result).to.eql({ a: 4 });
expect(result).toEqual({ a: 4 });
});
it('can be partially applied', () => {
@ -22,10 +22,10 @@ describe('u.withDefault', () => {
foo: u.withDefault([], { 0: 'bar' }),
}, object);
expect(result).to.eql({ foo: ['bar'] });
expect(result).toEqual({ foo: ['bar'] });
});
it('freezes the result', () => {
expect(Object.isFrozen(u.withDefault({}, { a: 1 })(undefined))).to.be.true;
expect(Object.isFrozen(u.withDefault({}, { a: 1 })(undefined))).toBe(true);
});
});