Skip to content

Commit

Permalink
[Tests] fail early if describeIf/itIf receives a non-boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 27, 2018
1 parent d602a22 commit 30b7970
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4235,7 +4235,7 @@ describeWithDOM('mount', () => {
});
});

describeIf(ITERATOR_SYMBOL, '@@iterator', () => {
describeIf(!!ITERATOR_SYMBOL, '@@iterator', () => {
it('should be iterable', () => {
class Foo extends React.Component {
render() {
Expand Down
2 changes: 1 addition & 1 deletion packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5173,7 +5173,7 @@ describe('shallow', () => {
});
});

describeIf(ITERATOR_SYMBOL, '@@iterator', () => {
describeIf(!!ITERATOR_SYMBOL, '@@iterator', () => {
it('should be iterable', () => {
class Foo extends React.Component {
render() {
Expand Down
8 changes: 8 additions & 0 deletions packages/enzyme-test-suite/test/_helpers/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import React from 'react';
* determines whether or not the test will be run
*/
export function describeIf(test, a, b) {
if (typeof test !== 'boolean') {
throw new TypeError(`a boolean is required, you passed a ${typeof test}`);
}

if (test) {
describe(a, b);
} else {
Expand All @@ -19,6 +23,10 @@ export function describeIf(test, a, b) {
* determines whether or not the test will be run
*/
export function itIf(test, a, b) {
if (typeof test !== 'boolean') {
throw new TypeError(`a boolean is required, you passed a ${typeof test}`);
}

if (test) {
it(a, b);
} else {
Expand Down

0 comments on commit 30b7970

Please sign in to comment.