Merge pull request #7625 from vjeux/jest15

Update to jest 15
This commit is contained in:
Christoph Pojer
2016-09-01 02:56:54 +01:00
committed by GitHub
11 changed files with 28 additions and 71 deletions
@@ -32,7 +32,11 @@ describe('ReactClassEquivalence', function() {
function runJest(testFile) {
var cwd = process.cwd();
var jestBin = path.resolve('node_modules', '.bin', 'jest');
var setupFile = path.resolve(__dirname, 'setupSpecEquivalenceReporter.js');
var setupFile = path.resolve(
'scripts',
'jest',
'setupSpecEquivalenceReporter.js'
);
var result = spawnSync('node', [
jestBin,
testFile,
@@ -60,7 +64,7 @@ function runJest(testFile) {
}
function compareResults(a, b) {
var regexp = /^EQUIVALENCE.*$/gm;
var regexp = /EQUIVALENCE.*$/gm;
var aSpecs = (a.match(regexp) || []).sort().join('\n');
var bSpecs = (b.match(regexp) || []).sort().join('\n');
@@ -1,31 +0,0 @@
/*!
* Copyright 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
var expect = global.expect;
var numExpectations = 0;
global.expect = function() {
numExpectations += 1;
return expect.apply(this, arguments);
};
beforeEach(() => numExpectations = 0);
jasmine.currentEnv_.addReporter({
specDone: (spec) => {
console.log(
`EQUIVALENCE: ${spec.description}, ` +
`status: ${spec.status}, ` +
`numExpectations: ${numExpectations}`
);
},
});
@@ -1,18 +0,0 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @emails react-core
*/
'use strict';
describe('ReactFlowPropTypes', function() {
// TODO: Test Flow integration and ensure that prop types works.
});
@@ -1,18 +0,0 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @emails react-core
*/
'use strict';
describe('ReactTypeScriptPropTypes', function() {
// TODO: Test TypeScript integration and ensure that prop types works.
});
@@ -13,9 +13,6 @@
'use strict';
jest
.unmock('ReactART');
var React = require('React');
var ReactDOM = require('ReactDOM');
var ReactTestUtils = require('ReactTestUtils');
@@ -45,33 +45,33 @@ describe('ReactServerRendering', function() {
var response = ReactServerRendering.renderToString(
<span>hello world</span>
);
expect(response).toMatch(
expect(response).toMatch(new RegExp(
'<span ' + ROOT_ATTRIBUTE_NAME + '="" ' +
ID_ATTRIBUTE_NAME + '="[^"]+" ' +
ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+">hello world</span>'
);
));
});
it('should generate simple markup for self-closing tags', function() {
var response = ReactServerRendering.renderToString(
<img />
);
expect(response).toMatch(
expect(response).toMatch(new RegExp(
'<img ' + ROOT_ATTRIBUTE_NAME + '="" ' +
ID_ATTRIBUTE_NAME + '="[^"]+" ' +
ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+"/>'
);
));
});
it('should generate simple markup for attribute with `>` symbol', function() {
var response = ReactServerRendering.renderToString(
<img data-attr=">" />
);
expect(response).toMatch(
expect(response).toMatch(new RegExp(
'<img data-attr="&gt;" ' + ROOT_ATTRIBUTE_NAME + '="" ' +
ID_ATTRIBUTE_NAME + '="[^"]+" ' +
ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+"/>'
);
));
});
it('should generate comment markup for component returns null', function() {
@@ -111,7 +111,7 @@ describe('ReactServerRendering', function() {
var response = ReactServerRendering.renderToString(
<Parent />
);
expect(response).toMatch(
expect(response).toMatch(new RegExp(
'<div ' + ROOT_ATTRIBUTE_NAME + '="" ' +
ID_ATTRIBUTE_NAME + '="[^"]+" ' +
ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+">' +
@@ -120,7 +120,7 @@ describe('ReactServerRendering', function() {
'<!-- react-text: [0-9]+ -->child<!-- /react-text -->' +
'</span>' +
'</div>'
);
));
});
it('should only execute certain lifecycle methods', function() {
@@ -172,14 +172,14 @@ describe('ReactServerRendering', function() {
<TestComponent />
);
expect(response).toMatch(
expect(response).toMatch(new RegExp(
'<span ' + ROOT_ATTRIBUTE_NAME + '="" ' +
ID_ATTRIBUTE_NAME + '="[^"]+" ' +
ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+">' +
'<!-- react-text: [0-9]+ -->Component name: <!-- /react-text -->' +
'<!-- react-text: [0-9]+ -->TestComponent<!-- /react-text -->' +
'</span>'
);
));
expect(lifecycle).toEqual(
['getInitialState', 'componentWillMount', 'render']
);
@@ -9,11 +9,6 @@
*/
'use strict';
jest.unmock('ReactNativeAttributePayload');
jest.unmock('ReactNativePropRegistry');
// jest.dontMock('deepDiffer');
// jest.dontMock('flattenStyle');
var ReactNativeAttributePayload = require('ReactNativeAttributePayload');
var ReactNativePropRegistry = require('ReactNativePropRegistry');
@@ -11,9 +11,7 @@
'use strict';
jest
.unmock('EventPluginHub')
.mock('isEventSupported');
jest.mock('isEventSupported');
describe('EventPluginHub', function() {
var EventPluginHub;
@@ -60,7 +60,7 @@ var expectChildren = function(d, children) {
openingCommentNode = outerNode.childNodes[mountIndex];
expect(openingCommentNode.nodeType).toBe(8);
expect(openingCommentNode.nodeValue).toMatch(' react-text: [0-9]+ ');
expect(openingCommentNode.nodeValue).toMatch(/ react-text: [0-9]+ /);
if (child === '') {
textNode = null;
@@ -11,9 +11,6 @@
'use strict';
jest
.unmock('accumulateInto');
var accumulateInto;
describe('accumulateInto', function() {