Files
react/scripts/babel/__tests__/transform-prevent-infinite-loops-test.js
Jack Hou e8e62ebb59 use different eslint config for es6 and es5 (#11794)
* use different eslint config for es6 and es5

* remove confusing eslint/baseConfig.js & add more eslint setting for es5, es6

* more clear way to run eslint on es5 & es6 file

* seperate ESNext, ES6, ES6 path, and use different lint config

* rename eslint config file & update eslint rules

* Undo yarn.lock changes

* Rename a file

* Remove unnecessary exceptions

* Refactor a little bit

* Refactor and tweak the logic

* Minor issues
2017-12-11 15:52:46 +00:00

40 lines
1.2 KiB
JavaScript

/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
describe('transform-prevent-infinite-loops', () => {
// Note: instead of testing the transform by applying it,
// we assume that it *is* already applied. Since we expect
// it to be applied to all our tests.
it('fails the test for `while` loops', () => {
expect(global.infiniteLoopError).toBe(null);
expect(() => {
while (true) {
// do nothing
}
}).toThrow(RangeError);
// Make sure this gets set so the test would fail regardless.
expect(global.infiniteLoopError).not.toBe(null);
// Clear the flag since otherwise *this* test would fail.
global.infiniteLoopError = null;
});
it('fails the test for `for` loops', () => {
expect(global.infiniteLoopError).toBe(null);
expect(() => {
for (;;) {
// do nothing
}
}).toThrow(RangeError);
// Make sure this gets set so the test would fail regardless.
expect(global.infiniteLoopError).not.toBe(null);
// Clear the flag since otherwise *this* test would fail.
global.infiniteLoopError = null;
});
});