Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #171 from barrymichaeldoyle/master
Updated all vars in test files to consts and lets.
  • Loading branch information
gaearon committed Jun 19, 2018
2 parents a7a5a64 + d65f80e commit 2ac742c
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 85 deletions.
62 changes: 31 additions & 31 deletions __tests__/PropTypesDevelopmentReact15.js
Expand Up @@ -9,8 +9,8 @@

'use strict';

var React;
var PropTypes;
let React;
let PropTypes;

function resetWarningCache() {
jest.resetModules();
Expand Down Expand Up @@ -51,31 +51,31 @@ function typeCheckFail(declaration, value, expectedMessage) {
}

function typeCheckFailRequiredValues(declaration) {
var specifiedButIsNullMsg = 'The prop `testProp` is marked as required in ' +
const specifiedButIsNullMsg = 'The prop `testProp` is marked as required in ' +
'`testComponent`, but its value is `null`.';
var unspecifiedMsg = 'The prop `testProp` is marked as required in ' +
const unspecifiedMsg = 'The prop `testProp` is marked as required in ' +
'`testComponent`, but its value is \`undefined\`.';

var propTypes = {testProp: declaration};
const propTypes = {testProp: declaration};

// Required prop is null
var message1 = getPropTypeWarningMessage(
const message1 = getPropTypeWarningMessage(
propTypes,
{testProp: null},
'testComponent',
);
expect(message1).toContain(specifiedButIsNullMsg);

// Required prop is undefined
var message2 = getPropTypeWarningMessage(
const message2 = getPropTypeWarningMessage(
propTypes,
{testProp: undefined},
'testComponent',
);
expect(message2).toContain(unspecifiedMsg);

// Required prop is not a member of props object
var message3 = getPropTypeWarningMessage(propTypes, {}, 'testComponent');
const message3 = getPropTypeWarningMessage(propTypes, {}, 'testComponent');
expect(message3).toContain(unspecifiedMsg);
}

Expand All @@ -92,10 +92,10 @@ function typeCheckPass(declaration, value) {

function expectWarningInDevelopment(declaration, value) {
resetWarningCache();
var props = {testProp: value};
var propName = 'testProp' + Math.random().toString();
var componentName = 'testComponent' + Math.random().toString();
for (var i = 0; i < 3; i++) {
const props = {testProp: value};
const propName = 'testProp' + Math.random().toString();
const componentName = 'testComponent' + Math.random().toString();
for (let i = 0; i < 3; i++) {
declaration(props, propName, componentName, 'prop');
}
expect(console.error.calls.count()).toBe(1);
Expand Down Expand Up @@ -363,7 +363,7 @@ describe('PropTypesDevelopmentReact15', () => {

it('should warn with invalid complex types', () => {
function Thing() {}
var name = Thing.name || '<<anonymous>>';
const name = Thing.name || '<<anonymous>>';

typeCheckFail(
PropTypes.arrayOf(PropTypes.instanceOf(Thing)),
Expand Down Expand Up @@ -494,9 +494,9 @@ describe('PropTypesDevelopmentReact15', () => {
it('should warn for invalid instances', () => {
function Person() {}
function Cat() {}
var personName = Person.name || '<<anonymous>>';
var dateName = Date.name || '<<anonymous>>';
var regExpName = RegExp.name || '<<anonymous>>';
const personName = Person.name || '<<anonymous>>';
const dateName = Date.name || '<<anonymous>>';
const regExpName = RegExp.name || '<<anonymous>>';

typeCheckFail(
PropTypes.instanceOf(Person),
Expand Down Expand Up @@ -591,7 +591,7 @@ describe('PropTypesDevelopmentReact15', () => {

describe('React Component Types', () => {
it('should warn for invalid values', () => {
var failMessage = 'Invalid prop `testProp` supplied to ' +
const failMessage = 'Invalid prop `testProp` supplied to ' +
'`testComponent`, expected a ReactNode.';
typeCheckFail(PropTypes.node, true, failMessage);
typeCheckFail(PropTypes.node, function() {}, failMessage);
Expand Down Expand Up @@ -625,12 +625,12 @@ describe('PropTypesDevelopmentReact15', () => {
MyComponent.prototype.render = function() {
return <div />;
};
var iterable = {
const iterable = {
'@@iterator': function() {
var i = 0;
let i = 0;
return {
next: function() {
var done = ++i > 2;
const done = ++i > 2;
return {value: done ? undefined : <MyComponent />, done: done};
},
};
Expand All @@ -645,12 +645,12 @@ describe('PropTypesDevelopmentReact15', () => {
MyComponent.prototype.render = function() {
return <div />;
};
var iterable = {
const iterable = {
'@@iterator': function() {
var i = 0;
let i = 0;
return {
next: function() {
var done = ++i > 2;
const done = ++i > 2;
return {
value: done ? undefined : ['#' + i, <MyComponent />],
done: done,
Expand Down Expand Up @@ -738,7 +738,7 @@ describe('PropTypesDevelopmentReact15', () => {

it('should warn with invalid complex types', () => {
function Thing() {}
var name = Thing.name || '<<anonymous>>';
const name = Thing.name || '<<anonymous>>';

typeCheckFail(
PropTypes.objectOf(PropTypes.instanceOf(Thing)),
Expand Down Expand Up @@ -892,11 +892,11 @@ describe('PropTypesDevelopmentReact15', () => {
it('should warn but for invalid argument type', () => {
spyOn(console, 'error');

var types = [undefined, null, false, new Date, /foo/, {}];
var expected = ['undefined', 'null', 'a boolean', 'a date', 'a regexp', 'an object'];
const types = [undefined, null, false, new Date, /foo/, {}];
const expected = ['undefined', 'null', 'a boolean', 'a date', 'a regexp', 'an object'];

for (var i = 0; i < expected.length; i++) {
var type = types[i];
for (let i = 0; i < expected.length; i++) {
const type = types[i];
PropTypes.oneOfType([type]);
expect(console.error).toHaveBeenCalled();
expect(console.error.calls.argsFor(0)[0]).toContain(
Expand All @@ -916,7 +916,7 @@ describe('PropTypesDevelopmentReact15', () => {
'Invalid prop `testProp` supplied to `testComponent`.',
);

var checker = PropTypes.oneOfType([
const checker = PropTypes.oneOfType([
PropTypes.shape({a: PropTypes.number.isRequired}),
PropTypes.shape({b: PropTypes.number.isRequired}),
]);
Expand All @@ -928,7 +928,7 @@ describe('PropTypesDevelopmentReact15', () => {
});

it('should not warn if one of the types are valid', () => {
var checker = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
let checker = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
typeCheckPass(checker, null);
typeCheckPass(checker, 'foo');
typeCheckPass(checker, 123);
Expand Down Expand Up @@ -1206,7 +1206,7 @@ describe('PropTypesDevelopmentReact15', () => {
});

it('should not warn for a polyfilled Symbol', () => {
var CoreSymbol = require('core-js/library/es6/symbol');
const CoreSymbol = require('core-js/library/es6/symbol');
typeCheckPass(PropTypes.symbol, CoreSymbol('core-js'));
});
});
Expand Down
56 changes: 28 additions & 28 deletions __tests__/PropTypesDevelopmentStandalone-test.js
Expand Up @@ -9,8 +9,8 @@

'use strict';

var React;
var PropTypes;
let React;
let PropTypes;

function resetWarningCache() {
jest.resetModules();
Expand Down Expand Up @@ -50,31 +50,31 @@ function typeCheckFail(declaration, value, expectedMessage) {
}

function typeCheckFailRequiredValues(declaration) {
var specifiedButIsNullMsg = 'The prop `testProp` is marked as required in ' +
const specifiedButIsNullMsg = 'The prop `testProp` is marked as required in ' +
'`testComponent`, but its value is `null`.';
var unspecifiedMsg = 'The prop `testProp` is marked as required in ' +
const unspecifiedMsg = 'The prop `testProp` is marked as required in ' +
'`testComponent`, but its value is \`undefined\`.';

var propTypes = {testProp: declaration};
const propTypes = {testProp: declaration};

// Required prop is null
var message1 = getPropTypeWarningMessage(
const message1 = getPropTypeWarningMessage(
propTypes,
{testProp: null},
'testComponent',
);
expect(message1).toContain(specifiedButIsNullMsg);

// Required prop is undefined
var message2 = getPropTypeWarningMessage(
const message2 = getPropTypeWarningMessage(
propTypes,
{testProp: undefined},
'testComponent',
);
expect(message2).toContain(unspecifiedMsg);

// Required prop is not a member of props object
var message3 = getPropTypeWarningMessage(propTypes, {}, 'testComponent');
const message3 = getPropTypeWarningMessage(propTypes, {}, 'testComponent');
expect(message3).toContain(unspecifiedMsg);
}

Expand All @@ -91,7 +91,7 @@ function typeCheckPass(declaration, value) {

function expectThrowsInDevelopment(declaration, value) {
resetWarningCache();
var props = {testProp: value};
const props = {testProp: value};
expect(() => {
declaration(props, 'testProp', 'testComponent', 'prop');
}).toThrowError(
Expand Down Expand Up @@ -359,7 +359,7 @@ describe('PropTypesDevelopmentStandalone', () => {

it('should warn with invalid complex types', () => {
function Thing() {}
var name = Thing.name || '<<anonymous>>';
const name = Thing.name || '<<anonymous>>';

typeCheckFail(
PropTypes.arrayOf(PropTypes.instanceOf(Thing)),
Expand Down Expand Up @@ -490,9 +490,9 @@ describe('PropTypesDevelopmentStandalone', () => {
it('should warn for invalid instances', () => {
function Person() {}
function Cat() {}
var personName = Person.name || '<<anonymous>>';
var dateName = Date.name || '<<anonymous>>';
var regExpName = RegExp.name || '<<anonymous>>';
const personName = Person.name || '<<anonymous>>';
const dateName = Date.name || '<<anonymous>>';
const regExpName = RegExp.name || '<<anonymous>>';

typeCheckFail(
PropTypes.instanceOf(Person),
Expand Down Expand Up @@ -587,7 +587,7 @@ describe('PropTypesDevelopmentStandalone', () => {

describe('React Component Types', () => {
it('should warn for invalid values', () => {
var failMessage = 'Invalid prop `testProp` supplied to ' +
const failMessage = 'Invalid prop `testProp` supplied to ' +
'`testComponent`, expected a ReactNode.';
typeCheckFail(PropTypes.node, true, failMessage);
typeCheckFail(PropTypes.node, function() {}, failMessage);
Expand Down Expand Up @@ -621,12 +621,12 @@ describe('PropTypesDevelopmentStandalone', () => {
MyComponent.prototype.render = function() {
return <div />;
};
var iterable = {
const iterable = {
'@@iterator': function() {
var i = 0;
let i = 0;
return {
next: function() {
var done = ++i > 2;
const done = ++i > 2;
return {value: done ? undefined : <MyComponent />, done: done};
},
};
Expand All @@ -641,12 +641,12 @@ describe('PropTypesDevelopmentStandalone', () => {
MyComponent.prototype.render = function() {
return <div />;
};
var iterable = {
const iterable = {
'@@iterator': function() {
var i = 0;
let i = 0;
return {
next: function() {
var done = ++i > 2;
const done = ++i > 2;
return {
value: done ? undefined : ['#' + i, <MyComponent />],
done: done,
Expand Down Expand Up @@ -734,7 +734,7 @@ describe('PropTypesDevelopmentStandalone', () => {

it('should warn with invalid complex types', () => {
function Thing() {}
var name = Thing.name || '<<anonymous>>';
const name = Thing.name || '<<anonymous>>';

typeCheckFail(
PropTypes.objectOf(PropTypes.instanceOf(Thing)),
Expand Down Expand Up @@ -888,11 +888,11 @@ describe('PropTypesDevelopmentStandalone', () => {
it('should warn but for invalid argument type', () => {
spyOn(console, 'error');

var types = [undefined, null, false, new Date, /foo/, {}];
var expected = ['undefined', 'null', 'a boolean', 'a date', 'a regexp', 'an object'];
const types = [undefined, null, false, new Date, /foo/, {}];
const expected = ['undefined', 'null', 'a boolean', 'a date', 'a regexp', 'an object'];

for (var i = 0; i < expected.length; i++) {
var type = types[i];
for (let i = 0; i < expected.length; i++) {
const type = types[i];
PropTypes.oneOfType([type]);
expect(console.error).toHaveBeenCalled();
expect(console.error.calls.argsFor(0)[0]).toContain(
Expand All @@ -912,7 +912,7 @@ describe('PropTypesDevelopmentStandalone', () => {
'Invalid prop `testProp` supplied to `testComponent`.',
);

var checker = PropTypes.oneOfType([
const checker = PropTypes.oneOfType([
PropTypes.shape({a: PropTypes.number.isRequired}),
PropTypes.shape({b: PropTypes.number.isRequired}),
]);
Expand All @@ -924,7 +924,7 @@ describe('PropTypesDevelopmentStandalone', () => {
});

it('should not warn if one of the types are valid', () => {
var checker = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
let checker = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
typeCheckPass(checker, null);
typeCheckPass(checker, 'foo');
typeCheckPass(checker, 123);
Expand Down Expand Up @@ -1095,7 +1095,7 @@ describe('PropTypesDevelopmentStandalone', () => {
});

it('should not warn for a polyfilled Symbol', () => {
var CoreSymbol = require('core-js/library/es6/symbol');
const CoreSymbol = require('core-js/library/es6/symbol');
typeCheckPass(PropTypes.symbol, CoreSymbol('core-js'));
});
});
Expand Down

0 comments on commit 2ac742c

Please sign in to comment.