Skip to content

Commit

Permalink
Upgrade to Babel 7 (jest-community#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
keeganwitt authored Jul 9, 2021
1 parent 0013709 commit 671bbdd
Show file tree
Hide file tree
Showing 25 changed files with 1,350 additions and 956 deletions.
6 changes: 5 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"env": {
"node": true,
"es6": true,
Expand Down
25 changes: 15 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@
"license": "MIT",
"repository": "jest-community/jest-extended",
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/eslint-parser": "^7.14.7",
"@babel/preset-env": "^7.14.7",
"@types/jest": "^24.0.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.1",
"babel-jest": "^24.0.0",
"babel-jest-assertions": "^0.1.0",
"babel-plugin-gwt": "^1.0.0",
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"codecov": "^3.0.0",
"eslint": "^4.9.0",
"eslint-plugin-import": "^2.8.0",
Expand Down Expand Up @@ -95,11 +93,18 @@
]
},
"babel": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "12"
}
}
]
],
"plugins": [
"babel-plugin-transform-es2015-modules-commonjs",
"transform-object-rest-spread",
"transform-async-to-generator",
"./node_modules/babel-jest-assertions",
"module:babel-jest-assertions",
"gwt",
"macros"
]
Expand Down
18 changes: 6 additions & 12 deletions src/matchers/toBeArrayOfSize/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,12 @@ describe('.toBeArrayOfSize', () => {
expect(() => expect(false).toBeArrayOfSize(1)).toThrowErrorMatchingSnapshot();
});

each([
[false],
[true],
[0],
[{}],
[() => {}],
[undefined],
[null],
[NaN]
]).test('fails when given type of %s which is not an array', given => {
expect(() => expect(given).toBeArrayOfSize(1)).toThrowErrorMatchingSnapshot();
});
each([[false], [true], [0], [{}], [() => {}], [undefined], [null], [NaN]]).test(
'fails when given type of %s which is not an array',
given => {
expect(() => expect(given).toBeArrayOfSize(1)).toThrowErrorMatchingSnapshot();
}
);

test('fails when not given an array', () => {
expect(() => expect().toBeArrayOfSize(5)).toThrowErrorMatchingSnapshot();
Expand Down
18 changes: 6 additions & 12 deletions src/matchers/toBeBoolean/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,12 @@ describe('.toBeBoolean', () => {
});

describe('.not.toBeBoolean', () => {
each([
['true'],
[0],
[{}],
[[]],
[() => {}],
[undefined],
[null],
[NaN]
]).test('passes when item is not of type boolean: %s', given => {
expect(given).not.toBeBoolean();
});
each([['true'], [0], [{}], [[]], [() => {}], [undefined], [null], [NaN]]).test(
'passes when item is not of type boolean: %s',
given => {
expect(given).not.toBeBoolean();
}
);

test('fails when given a boolean', () => {
expect(() => expect(true).not.toBeBoolean()).toThrowErrorMatchingSnapshot();
Expand Down
19 changes: 6 additions & 13 deletions src/matchers/toBeDate/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,12 @@ describe('.toBeDate', () => {
});

describe('.not.toBeDate', () => {
each([
[false],
[true],
[0],
[''],
[{}],
[() => {}],
[undefined],
[null],
[NaN]
]).test('passes when not given a date: %s', given => {
expect(given).not.toBeDate();
});
each([[false], [true], [0], [''], [{}], [() => {}], [undefined], [null], [NaN]]).test(
'passes when not given a date: %s',
given => {
expect(given).not.toBeDate();
}
);

test('fails when given a date', () => {
expect(() => expect(new Date('2018-01-01T13:00:00.000Z')).not.toBeDate()).toThrowErrorMatchingSnapshot();
Expand Down
39 changes: 12 additions & 27 deletions src/matchers/toBeEven/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,23 @@ describe('.toBeEven', () => {
expect(2).toBeEven();
});

each([
[false],
[true],
[''],
[1],
[{}],
[() => {}],
[undefined],
[null],
[NaN]
]).test('fails when not given an even number', given => {
expect(() => expect(given).toBeEven()).toThrowErrorMatchingSnapshot();
});
each([[false], [true], [''], [1], [{}], [() => {}], [undefined], [null], [NaN]]).test(
'fails when not given an even number',
given => {
expect(() => expect(given).toBeEven()).toThrowErrorMatchingSnapshot();
}
);
});

describe('.not.toBeEven', () => {
test('fails when given an even number', () => {
expect(() => expect(2).not.toBeEven()).toThrowErrorMatchingSnapshot();
});

each([
[false],
[true],
[''],
[1],
[[]],
[{}],
[() => {}],
[undefined],
[null],
[NaN]
]).test('passes when not given an even number: %s', given => {
expect(given).not.toBeEven();
});
each([[false], [true], [''], [1], [[]], [{}], [() => {}], [undefined], [null], [NaN]]).test(
'passes when not given an even number: %s',
given => {
expect(given).not.toBeEven();
}
);
});
36 changes: 12 additions & 24 deletions src/matchers/toBeExtensible/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,21 @@ describe('.toBeExtensible', () => {
expect(given).toBeExtensible();
});

each([
[false],
[''],
[0],
[undefined],
[null],
[NaN],
[Object.seal({})],
[Object.freeze({})]
]).test('fails when not given an extensible object: %s', given => {
expect(() => expect(given).toBeExtensible()).toThrowErrorMatchingSnapshot();
});
each([[false], [''], [0], [undefined], [null], [NaN], [Object.seal({})], [Object.freeze({})]]).test(
'fails when not given an extensible object: %s',
given => {
expect(() => expect(given).toBeExtensible()).toThrowErrorMatchingSnapshot();
}
);
});

describe('.not.toBeExtensible', () => {
each([
[false],
[''],
[0],
[undefined],
[null],
[NaN],
[Object.seal({})],
[Object.freeze({})]
]).test('passes when not given extensible object: %s', given => {
expect(given).not.toBeExtensible();
});
each([[false], [''], [0], [undefined], [null], [NaN], [Object.seal({})], [Object.freeze({})]]).test(
'passes when not given extensible object: %s',
given => {
expect(given).not.toBeExtensible();
}
);

each([[{}], [[]], [() => {}]]).test('fails when given an extensible object: %s', given => {
expect(() => expect(given).not.toBeExtensible()).toThrowErrorMatchingSnapshot();
Expand Down
18 changes: 6 additions & 12 deletions src/matchers/toBeExtensible/predicate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@ describe('toBeExpected Predicate', () => {
expect(predicate(given)).toBe(true);
});

each([
[false],
[''],
[0],
[undefined],
[null],
[NaN],
[Object.seal({})],
[Object.freeze({})]
]).test('returns false when given non-extensible object: %s', given => {
expect(predicate(given)).toBe(false);
});
each([[false], [''], [0], [undefined], [null], [NaN], [Object.seal({})], [Object.freeze({})]]).test(
'returns false when given non-extensible object: %s',
given => {
expect(predicate(given)).toBe(false);
}
);
});
18 changes: 6 additions & 12 deletions src/matchers/toBeNumber/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,12 @@ describe('.toBeNumber', () => {
});

describe('.not.toBeNumber', () => {
each([
[false],
[true],
[[]],
[{}],
[() => {}],
[undefined],
[null],
['10']
]).test('passes when not given a number: %s', given => {
expect(given).not.toBeNumber();
});
each([[false], [true], [[]], [{}], [() => {}], [undefined], [null], ['10']]).test(
'passes when not given a number: %s',
given => {
expect(given).not.toBeNumber();
}
);

test('fails when given a number', () => {
expect(() => expect(1).not.toBeNumber()).toThrowErrorMatchingSnapshot();
Expand Down
39 changes: 12 additions & 27 deletions src/matchers/toBeOdd/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,21 @@ describe('.toBeOdd', () => {
expect(1).toBeOdd();
});

each([
[false],
[true],
[''],
[2],
[{}],
[() => {}],
[undefined],
[null],
[NaN]
]).test('fails when given not given an odd number', given => {
expect(() => expect(given).toBeOdd()).toThrowErrorMatchingSnapshot();
});
each([[false], [true], [''], [2], [{}], [() => {}], [undefined], [null], [NaN]]).test(
'fails when given not given an odd number',
given => {
expect(() => expect(given).toBeOdd()).toThrowErrorMatchingSnapshot();
}
);
});

describe('.not.toBeOdd', () => {
each([
[false],
[true],
[''],
[2],
[[]],
[{}],
[() => {}],
[undefined],
[null],
[NaN]
]).test('passes when not given an odd number: %s', given => {
expect(given).not.toBeOdd();
});
each([[false], [true], [''], [2], [[]], [{}], [() => {}], [undefined], [null], [NaN]]).test(
'passes when not given an odd number: %s',
given => {
expect(given).not.toBeOdd();
}
);

test('fails when given an odd number', () => {
expect(() => expect(1).not.toBeOdd()).toThrowErrorMatchingSnapshot();
Expand Down
17 changes: 6 additions & 11 deletions src/matchers/toBeOneOf/predicate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,10 @@ describe('.toBeOneOf', () => {
expect(predicate(value, [1, 2, { hello: 'world' }, ['foo']])).toBe(true);
});

each([
[0],
[null],
[undefined],
[false],
[''],
[{ hello: 'world' }],
[['foo']]
]).test('returns false when value: %s is not in given array', value => {
expect(predicate(value, [1, 2, 3])).toBe(false);
});
each([[0], [null], [undefined], [false], [''], [{ hello: 'world' }], [['foo']]]).test(
'returns false when value: %s is not in given array',
value => {
expect(predicate(value, [1, 2, 3])).toBe(false);
}
);
});
21 changes: 6 additions & 15 deletions src/matchers/toBePositive/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,12 @@ describe('.toBePositive', () => {
});

describe('.not.toBePositive', () => {
each([
[false],
[''],
[-1],
[0],
[{}],
[[]],
[() => {}],
[undefined],
[null],
[NaN],
[Infinity]
]).test('passes when not given a positive number: %s', given => {
expect(given).not.toBePositive();
});
each([[false], [''], [-1], [0], [{}], [[]], [() => {}], [undefined], [null], [NaN], [Infinity]]).test(
'passes when not given a positive number: %s',
given => {
expect(given).not.toBePositive();
}
);

test('fails when given a positive number', () => {
expect(() => expect(5).not.toBePositive()).toThrowErrorMatchingSnapshot();
Expand Down
Loading

0 comments on commit 671bbdd

Please sign in to comment.