Navigation Menu

Skip to content

Commit

Permalink
Upgrade jest and remove jest-each
Browse files Browse the repository at this point in the history
  • Loading branch information
mattphillips committed Oct 23, 2018
1 parent 45549c8 commit 6296889
Show file tree
Hide file tree
Showing 8 changed files with 1,556 additions and 652 deletions.
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -30,8 +30,7 @@
"babel-preset-es2015": "^6.18.0",
"babel-preset-stage-0": "^6.16.0",
"coveralls": "^3.0.0",
"jest": "^22.0.0",
"jest-each": "0.3.1"
"jest": "^23.6.0"
},
"babel": {
"presets": [
Expand Down
10 changes: 4 additions & 6 deletions src/added/index.test.js
@@ -1,12 +1,10 @@
import forEach from 'jest-each';

import addedDiff from './';

describe('.addedDiff', () => {

describe('base case', () => {
describe('equal', () => {
forEach([
test.each([
['int', 1],
['string', 'a'],
['boolean', true],
Expand All @@ -16,13 +14,13 @@ describe('.addedDiff', () => {
['array', [1]],
['function', () => ({})],
['date', new Date()],
]).test('returns empty object when given values of type %s are equal', (type, value) => {
])('returns empty object when given values of type %s are equal', (type, value) => {
expect(addedDiff(value, value)).toEqual({});
});
});

describe('not equal and not object', () => {
forEach([
test.each([
[1, 2],
['a', 'b'],
[true, false],
Expand All @@ -35,7 +33,7 @@ describe('.addedDiff', () => {
[100, () => ({})],
[() => ({}), 100],
[new Date('2017-01-01'), new Date('2017-01-02')],
]).test('returns empty object when values are not equal (%s, %s)', (lhs, rhs) => {
])('returns empty object when values are not equal (%s, %s)', (lhs, rhs) => {
expect(addedDiff(lhs, rhs)).toEqual({});
});
});
Expand Down
11 changes: 4 additions & 7 deletions src/arrayDiff/index.test.js
@@ -1,12 +1,10 @@
import forEach from 'jest-each';

import diff from './';

describe('.arrayDiff', () => {

describe('base case', () => {
describe('equal', () => {
forEach([
test.each([
['int', 1],
['string', 'a'],
['boolean', true],
Expand All @@ -17,13 +15,13 @@ describe('.arrayDiff', () => {
['function', () => ({})],
['date', new Date()],
['date with milliseconds', new Date('2017-01-01T00:00:00.637Z')],
]).test('returns empty object when given values of type %s are equal', (type, value) => {
])('returns empty object when given values of type %s are equal', (type, value) => {
expect(diff(value, value)).toEqual({});
});
});

describe('not equal and not object', () => {
forEach([
test.each([
[1, 2],
['a', 'b'],
[true, false],
Expand All @@ -37,7 +35,7 @@ describe('.arrayDiff', () => {
[() => ({}), 100],
[new Date('2017-01-01'), new Date('2017-01-02')],
[new Date('2017-01-01T00:00:00.636Z'), new Date('2017-01-01T00:00:00.637Z')],
]).test('returns right hand side value when different to left hand side value (%s, %s)', (lhs, rhs) => {
])('returns right hand side value when different to left hand side value (%s, %s)', (lhs, rhs) => {
expect(diff(lhs, rhs)).toEqual(rhs);
});
});
Expand Down Expand Up @@ -100,7 +98,6 @@ describe('.arrayDiff', () => {
delete expected['0'];
delete expected['1'];
delete expected['2'];
// expected.forEach(console.log)
expect(diff([1, 2, 3], [1, 2, 3, 9])).toEqual(expected);
});
});
Expand Down
10 changes: 4 additions & 6 deletions src/deleted/index.test.js
@@ -1,12 +1,10 @@
import forEach from 'jest-each';

import deletedDiff from './';

describe('.deletedDiff', () => {

describe('base case', () => {
describe('equal', () => {
forEach([
test.each([
['int', 1],
['string', 'a'],
['boolean', true],
Expand All @@ -16,13 +14,13 @@ describe('.deletedDiff', () => {
['array', [1]],
['function', () => ({})],
['date', new Date()],
]).test('returns empty object when given values of type %s are equal', (type, value) => {
])('returns empty object when given values of type %s are equal', (type, value) => {
expect(deletedDiff(value, value)).toEqual({});
});
});

describe('not equal and not object', () => {
forEach([
test.each([
[1, 2],
['a', 'b'],
[true, false],
Expand All @@ -35,7 +33,7 @@ describe('.deletedDiff', () => {
[100, () => ({})],
[() => ({}), 100],
[new Date('2017-01-01'), new Date('2017-01-02')],
]).test('returns empty object when given values are unequal', (lhs, rhs) => {
])('returns empty object when given values: %s %s are unequal', (lhs, rhs) => {
expect(deletedDiff(lhs, rhs)).toEqual({});
});
});
Expand Down
10 changes: 4 additions & 6 deletions src/diff/index.test.js
@@ -1,12 +1,10 @@
import forEach from 'jest-each';

import diff from './';

describe('.diff', () => {

describe('base case', () => {
describe('equal', () => {
forEach([
test.each([
['int', 1],
['string', 'a'],
['boolean', true],
Expand All @@ -17,13 +15,13 @@ describe('.diff', () => {
['function', () => ({})],
['date', new Date()],
['date with milliseconds', new Date('2017-01-01T00:00:00.637Z')],
]).test('returns empty object when given values of type %s are equal', (type, value) => {
])('returns empty object when given values of type %s are equal', (type, value) => {
expect(diff(value, value)).toEqual({});
});
});

describe('not equal and not object', () => {
forEach([
test.each([
[1, 2],
['a', 'b'],
[true, false],
Expand All @@ -37,7 +35,7 @@ describe('.diff', () => {
[() => ({}), 100],
[new Date('2017-01-01'), new Date('2017-01-02')],
[new Date('2017-01-01T00:00:00.636Z'), new Date('2017-01-01T00:00:00.637Z')],
]).test('returns right hand side value when different to left hand side value (%s, %s)', (lhs, rhs) => {
])('returns right hand side value when different to left hand side value (%s, %s)', (lhs, rhs) => {
expect(diff(lhs, rhs)).toEqual(rhs);
});
});
Expand Down
10 changes: 4 additions & 6 deletions src/updated/index.test.js
@@ -1,12 +1,10 @@
import forEach from 'jest-each';

import updatedDiff from './';

describe('.updatedDiff', () => {

describe('base case', () => {
describe('equal', () => {
forEach([
test.each([
['int', 1],
['string', 'a'],
['boolean', true],
Expand All @@ -17,13 +15,13 @@ describe('.updatedDiff', () => {
['function', () => ({})],
['date', new Date()],
['date with milliseconds', new Date('2017-01-01T00:00:00.637Z')],
]).test('returns empty object when given values of type %s are equal', (type, value) => {
])('returns empty object when given values of type %s are equal', (type, value) => {
expect(updatedDiff(value, value)).toEqual({});
});
});

describe('not equal and not object', () => {
forEach([
test.each([
[1, 2],
['a', 'b'],
[true, false],
Expand All @@ -37,7 +35,7 @@ describe('.updatedDiff', () => {
[() => ({}), 100],
[new Date('2017-01-01'), new Date('2017-01-02')],
[new Date('2017-01-01T00:00:00.636Z'), new Date('2017-01-01T00:00:00.637Z')],
]).test('returns right hand side value when different to left hand side value (%s, %s)', (lhs, rhs) => {
])('returns right hand side value when different to left hand side value (%s, %s)', (lhs, rhs) => {
expect(updatedDiff(lhs, rhs)).toEqual(rhs);
});
});
Expand Down
14 changes: 6 additions & 8 deletions src/utils/index.test.js
@@ -1,31 +1,29 @@
import forEach from 'jest-each';

import { isDate, isEmpty, isObject, properObject } from './';

describe('utils', () => {

describe('.isDate', () => {
forEach([
test.each([
[new Date()],
[new Date('2016')],
[new Date('2016-01')],
[new Date('2016-01-01')],
[new Date('2016-01-01:14:45:20')],
[new Date('Tue Feb 14 2017 14:45:20 GMT+0000 (GMT)')],
[new Date('nonsense')],
]).test('returns true when given a date object of %s', (date) => {
])('returns true when given a date object of %s', (date) => {
expect(isDate(date)).toBe(true);
});

forEach([
test.each([
[100],
['100'],
[false],
[{ a: 100 }],
[[100, 101, 102]],
[Date.parse('2016')],
[Date.now()],
]).test('returns false when not given a date object of %s', (x) => {
])('returns false when not given a date object of %s', (x) => {
expect(isDate(x)).toBe(false);
});
});
Expand Down Expand Up @@ -61,14 +59,14 @@ describe('utils', () => {
expect(isObject([])).toBe(true);
});

forEach([
test.each([
['int', 1],
['string', 'a'],
['boolean', true],
['null', null],
['undefined', undefined],
['function', () => ({})],
]).test('returns false when value is of type: %s', (type, value) => {
])('returns false when value is of type: %s', (type, value) => {
expect(isObject(value)).toBe(false);
});
});
Expand Down

0 comments on commit 6296889

Please sign in to comment.