Upgrade to Jest 23 (#12894)
* Upgrade to Jest 23 beta * prefer `.toHaveBeenCalledTimes` * 23 stable
This commit is contained in:
parent
a32f857ac7
commit
aa85b0fd5f
|
@ -11,7 +11,7 @@
|
||||||
"babel-code-frame": "^6.26.0",
|
"babel-code-frame": "^6.26.0",
|
||||||
"babel-core": "^6.0.0",
|
"babel-core": "^6.0.0",
|
||||||
"babel-eslint": "^8.0.0",
|
"babel-eslint": "^8.0.0",
|
||||||
"babel-jest": "^22.4.4",
|
"babel-jest": "^23.0.1",
|
||||||
"babel-plugin-check-es2015-constants": "^6.5.0",
|
"babel-plugin-check-es2015-constants": "^6.5.0",
|
||||||
"babel-plugin-external-helpers": "^6.22.0",
|
"babel-plugin-external-helpers": "^6.22.0",
|
||||||
"babel-plugin-syntax-trailing-function-commas": "^6.5.0",
|
"babel-plugin-syntax-trailing-function-commas": "^6.5.0",
|
||||||
|
@ -69,8 +69,8 @@
|
||||||
"gzip-js": "~0.3.2",
|
"gzip-js": "~0.3.2",
|
||||||
"gzip-size": "^3.0.0",
|
"gzip-size": "^3.0.0",
|
||||||
"jasmine-check": "^1.0.0-rc.0",
|
"jasmine-check": "^1.0.0-rc.0",
|
||||||
"jest": "^22.4.4",
|
"jest": "^23.0.1",
|
||||||
"jest-diff": "^22.4.3",
|
"jest-diff": "^23.0.1",
|
||||||
"merge-stream": "^1.0.0",
|
"merge-stream": "^1.0.0",
|
||||||
"minimatch": "^3.0.4",
|
"minimatch": "^3.0.4",
|
||||||
"minimist": "^1.2.0",
|
"minimist": "^1.2.0",
|
||||||
|
|
|
@ -123,7 +123,7 @@ describe('DOMPropertyOperations', () => {
|
||||||
spyOnDevAndProd(container.firstChild, 'setAttribute');
|
spyOnDevAndProd(container.firstChild, 'setAttribute');
|
||||||
ReactDOM.render(<progress value={30} />, container);
|
ReactDOM.render(<progress value={30} />, container);
|
||||||
ReactDOM.render(<progress value="30" />, container);
|
ReactDOM.render(<progress value="30" />, container);
|
||||||
expect(container.firstChild.setAttribute.calls.count()).toBe(2);
|
expect(container.firstChild.setAttribute).toHaveBeenCalledTimes(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -151,17 +151,17 @@ describe('ReactBrowserEventEmitter', () => {
|
||||||
it('should invoke a simple handler registered on a node', () => {
|
it('should invoke a simple handler registered on a node', () => {
|
||||||
registerSimpleTestHandler();
|
registerSimpleTestHandler();
|
||||||
ReactTestUtils.Simulate.click(CHILD);
|
ReactTestUtils.Simulate.click(CHILD);
|
||||||
expect(LISTENER.mock.calls.length).toBe(1);
|
expect(LISTENER).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not invoke handlers if ReactBrowserEventEmitter is disabled', () => {
|
it('should not invoke handlers if ReactBrowserEventEmitter is disabled', () => {
|
||||||
registerSimpleTestHandler();
|
registerSimpleTestHandler();
|
||||||
ReactBrowserEventEmitter.setEnabled(false);
|
ReactBrowserEventEmitter.setEnabled(false);
|
||||||
ReactTestUtils.SimulateNative.click(CHILD);
|
ReactTestUtils.SimulateNative.click(CHILD);
|
||||||
expect(LISTENER.mock.calls.length).toBe(0);
|
expect(LISTENER).toHaveBeenCalledTimes(0);
|
||||||
ReactBrowserEventEmitter.setEnabled(true);
|
ReactBrowserEventEmitter.setEnabled(true);
|
||||||
ReactTestUtils.SimulateNative.click(CHILD);
|
ReactTestUtils.SimulateNative.click(CHILD);
|
||||||
expect(LISTENER.mock.calls.length).toBe(1);
|
expect(LISTENER).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should bubble simply', () => {
|
it('should bubble simply', () => {
|
||||||
|
@ -301,7 +301,7 @@ describe('ReactBrowserEventEmitter', () => {
|
||||||
putListener(CHILD, ON_CLICK_KEY, handleChildClick);
|
putListener(CHILD, ON_CLICK_KEY, handleChildClick);
|
||||||
putListener(PARENT, ON_CLICK_KEY, handleParentClick);
|
putListener(PARENT, ON_CLICK_KEY, handleParentClick);
|
||||||
ReactTestUtils.Simulate.click(CHILD);
|
ReactTestUtils.Simulate.click(CHILD);
|
||||||
expect(handleParentClick.mock.calls.length).toBe(1);
|
expect(handleParentClick).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not invoke newly inserted handlers while bubbling', () => {
|
it('should not invoke newly inserted handlers while bubbling', () => {
|
||||||
|
@ -311,7 +311,7 @@ describe('ReactBrowserEventEmitter', () => {
|
||||||
};
|
};
|
||||||
putListener(CHILD, ON_CLICK_KEY, handleChildClick);
|
putListener(CHILD, ON_CLICK_KEY, handleChildClick);
|
||||||
ReactTestUtils.Simulate.click(CHILD);
|
ReactTestUtils.Simulate.click(CHILD);
|
||||||
expect(handleParentClick.mock.calls.length).toBe(0);
|
expect(handleParentClick).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have mouse enter simulated by test utils', () => {
|
it('should have mouse enter simulated by test utils', () => {
|
||||||
|
@ -325,7 +325,7 @@ describe('ReactBrowserEventEmitter', () => {
|
||||||
spyOnDevAndProd(EventTarget.prototype, 'addEventListener');
|
spyOnDevAndProd(EventTarget.prototype, 'addEventListener');
|
||||||
ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document);
|
ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document);
|
||||||
ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document);
|
ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document);
|
||||||
expect(EventTarget.prototype.addEventListener.calls.count()).toBe(1);
|
expect(EventTarget.prototype.addEventListener).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work with event plugins without dependencies', () => {
|
it('should work with event plugins without dependencies', () => {
|
||||||
|
|
|
@ -387,11 +387,11 @@ describe('ReactComponent', () => {
|
||||||
const callback = jest.fn();
|
const callback = jest.fn();
|
||||||
const container = document.createElement('div');
|
const container = document.createElement('div');
|
||||||
ReactDOM.render(<div />, container, callback);
|
ReactDOM.render(<div />, container, callback);
|
||||||
expect(callback.mock.calls.length).toBe(1);
|
expect(callback).toHaveBeenCalledTimes(1);
|
||||||
ReactDOM.render(<div className="foo" />, container, callback);
|
ReactDOM.render(<div className="foo" />, container, callback);
|
||||||
expect(callback.mock.calls.length).toBe(2);
|
expect(callback).toHaveBeenCalledTimes(2);
|
||||||
ReactDOM.render(<span />, container, callback);
|
ReactDOM.render(<span />, container, callback);
|
||||||
expect(callback.mock.calls.length).toBe(3);
|
expect(callback).toHaveBeenCalledTimes(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws usefully when rendering badly-typed elements', () => {
|
it('throws usefully when rendering badly-typed elements', () => {
|
||||||
|
|
|
@ -738,28 +738,28 @@ describe('ReactDOMComponent', () => {
|
||||||
node.removeAttribute.mockImplementation(nodeRemoveAttribute);
|
node.removeAttribute.mockImplementation(nodeRemoveAttribute);
|
||||||
|
|
||||||
ReactDOM.render(<div id="" />, container);
|
ReactDOM.render(<div id="" />, container);
|
||||||
expect(node.setAttribute.mock.calls.length).toBe(0);
|
expect(node.setAttribute).toHaveBeenCalledTimes(0);
|
||||||
expect(node.removeAttribute.mock.calls.length).toBe(0);
|
expect(node.removeAttribute).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
ReactDOM.render(<div id="foo" />, container);
|
ReactDOM.render(<div id="foo" />, container);
|
||||||
expect(node.setAttribute.mock.calls.length).toBe(1);
|
expect(node.setAttribute).toHaveBeenCalledTimes(1);
|
||||||
expect(node.removeAttribute.mock.calls.length).toBe(0);
|
expect(node.removeAttribute).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
ReactDOM.render(<div id="foo" />, container);
|
ReactDOM.render(<div id="foo" />, container);
|
||||||
expect(node.setAttribute.mock.calls.length).toBe(1);
|
expect(node.setAttribute).toHaveBeenCalledTimes(1);
|
||||||
expect(node.removeAttribute.mock.calls.length).toBe(0);
|
expect(node.removeAttribute).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
ReactDOM.render(<div />, container);
|
ReactDOM.render(<div />, container);
|
||||||
expect(node.setAttribute.mock.calls.length).toBe(1);
|
expect(node.setAttribute).toHaveBeenCalledTimes(1);
|
||||||
expect(node.removeAttribute.mock.calls.length).toBe(1);
|
expect(node.removeAttribute).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
ReactDOM.render(<div id="" />, container);
|
ReactDOM.render(<div id="" />, container);
|
||||||
expect(node.setAttribute.mock.calls.length).toBe(2);
|
expect(node.setAttribute).toHaveBeenCalledTimes(2);
|
||||||
expect(node.removeAttribute.mock.calls.length).toBe(1);
|
expect(node.removeAttribute).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
ReactDOM.render(<div />, container);
|
ReactDOM.render(<div />, container);
|
||||||
expect(node.setAttribute.mock.calls.length).toBe(2);
|
expect(node.setAttribute).toHaveBeenCalledTimes(2);
|
||||||
expect(node.removeAttribute.mock.calls.length).toBe(2);
|
expect(node.removeAttribute).toHaveBeenCalledTimes(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not incur unnecessary DOM mutations for string properties', () => {
|
it('should not incur unnecessary DOM mutations for string properties', () => {
|
||||||
|
@ -768,7 +768,7 @@ describe('ReactDOMComponent', () => {
|
||||||
|
|
||||||
const node = container.firstChild;
|
const node = container.firstChild;
|
||||||
|
|
||||||
const nodeValueSetter = jest.genMockFn();
|
const nodeValueSetter = jest.fn();
|
||||||
|
|
||||||
const oldSetAttribute = node.setAttribute.bind(node);
|
const oldSetAttribute = node.setAttribute.bind(node);
|
||||||
node.setAttribute = function(key, value) {
|
node.setAttribute = function(key, value) {
|
||||||
|
@ -777,22 +777,22 @@ describe('ReactDOMComponent', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
ReactDOM.render(<div value="foo" />, container);
|
ReactDOM.render(<div value="foo" />, container);
|
||||||
expect(nodeValueSetter.mock.calls.length).toBe(1);
|
expect(nodeValueSetter).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
ReactDOM.render(<div value="foo" />, container);
|
ReactDOM.render(<div value="foo" />, container);
|
||||||
expect(nodeValueSetter.mock.calls.length).toBe(1);
|
expect(nodeValueSetter).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
ReactDOM.render(<div />, container);
|
ReactDOM.render(<div />, container);
|
||||||
expect(nodeValueSetter.mock.calls.length).toBe(1);
|
expect(nodeValueSetter).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
ReactDOM.render(<div value={null} />, container);
|
ReactDOM.render(<div value={null} />, container);
|
||||||
expect(nodeValueSetter.mock.calls.length).toBe(1);
|
expect(nodeValueSetter).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
ReactDOM.render(<div value="" />, container);
|
ReactDOM.render(<div value="" />, container);
|
||||||
expect(nodeValueSetter.mock.calls.length).toBe(2);
|
expect(nodeValueSetter).toHaveBeenCalledTimes(2);
|
||||||
|
|
||||||
ReactDOM.render(<div />, container);
|
ReactDOM.render(<div />, container);
|
||||||
expect(nodeValueSetter.mock.calls.length).toBe(2);
|
expect(nodeValueSetter).toHaveBeenCalledTimes(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not incur unnecessary DOM mutations for boolean properties', () => {
|
it('should not incur unnecessary DOM mutations for boolean properties', () => {
|
||||||
|
@ -812,16 +812,16 @@ describe('ReactDOMComponent', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
ReactDOM.render(<div checked={true} />, container);
|
ReactDOM.render(<div checked={true} />, container);
|
||||||
expect(nodeValueSetter.mock.calls.length).toBe(0);
|
expect(nodeValueSetter).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
ReactDOM.render(<div />, container);
|
ReactDOM.render(<div />, container);
|
||||||
expect(nodeValueSetter.mock.calls.length).toBe(1);
|
expect(nodeValueSetter).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
ReactDOM.render(<div checked={false} />, container);
|
ReactDOM.render(<div checked={false} />, container);
|
||||||
expect(nodeValueSetter.mock.calls.length).toBe(2);
|
expect(nodeValueSetter).toHaveBeenCalledTimes(2);
|
||||||
|
|
||||||
ReactDOM.render(<div checked={true} />, container);
|
ReactDOM.render(<div checked={true} />, container);
|
||||||
expect(nodeValueSetter.mock.calls.length).toBe(3);
|
expect(nodeValueSetter).toHaveBeenCalledTimes(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should ignore attribute whitelist for elements with the "is" attribute', () => {
|
it('should ignore attribute whitelist for elements with the "is" attribute', () => {
|
||||||
|
@ -850,9 +850,9 @@ describe('ReactDOMComponent', () => {
|
||||||
ReactDOM.render(<div dir={null} />, container);
|
ReactDOM.render(<div dir={null} />, container);
|
||||||
ReactDOM.render(<div dir={undefined} />, container);
|
ReactDOM.render(<div dir={undefined} />, container);
|
||||||
ReactDOM.render(<div />, container);
|
ReactDOM.render(<div />, container);
|
||||||
expect(setter.mock.calls.length).toBe(0);
|
expect(setter).toHaveBeenCalledTimes(0);
|
||||||
ReactDOM.render(<div dir="ltr" />, container);
|
ReactDOM.render(<div dir="ltr" />, container);
|
||||||
expect(setter.mock.calls.length).toBe(1);
|
expect(setter).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles multiple child updates without interference', () => {
|
it('handles multiple child updates without interference', () => {
|
||||||
|
@ -984,7 +984,7 @@ describe('ReactDOMComponent', () => {
|
||||||
container.getElementsByTagName('source')[0].dispatchEvent(errorEvent);
|
container.getElementsByTagName('source')[0].dispatchEvent(errorEvent);
|
||||||
|
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
expect(console.log.calls.count()).toBe(1);
|
expect(console.log).toHaveBeenCalledTimes(1);
|
||||||
expect(console.log.calls.argsFor(0)[0]).toContain('onError called');
|
expect(console.log.calls.argsFor(0)[0]).toContain('onError called');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1315,7 +1315,7 @@ describe('ReactDOMComponent', () => {
|
||||||
container.getElementsByTagName('image')[0].dispatchEvent(loadEvent);
|
container.getElementsByTagName('image')[0].dispatchEvent(loadEvent);
|
||||||
|
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
expect(console.log.calls.count()).toBe(2);
|
expect(console.log).toHaveBeenCalledTimes(2);
|
||||||
expect(console.log.calls.argsFor(0)[0]).toContain('onError called');
|
expect(console.log.calls.argsFor(0)[0]).toContain('onError called');
|
||||||
expect(console.log.calls.argsFor(1)[0]).toContain('onLoad called');
|
expect(console.log.calls.argsFor(1)[0]).toContain('onLoad called');
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ describe('ReactDOMEventListener', () => {
|
||||||
childNode.dispatchEvent(nativeEvent);
|
childNode.dispatchEvent(nativeEvent);
|
||||||
|
|
||||||
expect(mouseOut).toBeCalled();
|
expect(mouseOut).toBeCalled();
|
||||||
expect(mouseOut.mock.calls.length).toBe(2);
|
expect(mouseOut).toHaveBeenCalledTimes(2);
|
||||||
expect(mouseOut.mock.calls[0][0]).toEqual(childNode);
|
expect(mouseOut.mock.calls[0][0]).toEqual(childNode);
|
||||||
expect(mouseOut.mock.calls[1][0]).toEqual(parentNode);
|
expect(mouseOut.mock.calls[1][0]).toEqual(parentNode);
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ describe('ReactDOMEventListener', () => {
|
||||||
childNode.dispatchEvent(nativeEvent);
|
childNode.dispatchEvent(nativeEvent);
|
||||||
|
|
||||||
expect(mouseOut).toBeCalled();
|
expect(mouseOut).toBeCalled();
|
||||||
expect(mouseOut.mock.calls.length).toBe(3);
|
expect(mouseOut).toHaveBeenCalledTimes(3);
|
||||||
expect(mouseOut.mock.calls[0][0]).toEqual(childNode);
|
expect(mouseOut.mock.calls[0][0]).toEqual(childNode);
|
||||||
expect(mouseOut.mock.calls[1][0]).toEqual(parentNode);
|
expect(mouseOut.mock.calls[1][0]).toEqual(parentNode);
|
||||||
expect(mouseOut.mock.calls[2][0]).toEqual(grandParentNode);
|
expect(mouseOut.mock.calls[2][0]).toEqual(grandParentNode);
|
||||||
|
@ -169,7 +169,7 @@ describe('ReactDOMEventListener', () => {
|
||||||
childNode.dispatchEvent(nativeEvent);
|
childNode.dispatchEvent(nativeEvent);
|
||||||
|
|
||||||
// Child and parent should both call from event handlers.
|
// Child and parent should both call from event handlers.
|
||||||
expect(mock.mock.calls.length).toBe(2);
|
expect(mock).toHaveBeenCalledTimes(2);
|
||||||
// The first call schedules a render of '1' into the 'Child'.
|
// The first call schedules a render of '1' into the 'Child'.
|
||||||
// However, we're batching so it isn't flushed yet.
|
// However, we're batching so it isn't flushed yet.
|
||||||
expect(mock.mock.calls[0][0]).toBe('Child');
|
expect(mock.mock.calls[0][0]).toBe('Child');
|
||||||
|
@ -213,7 +213,7 @@ describe('ReactDOMEventListener', () => {
|
||||||
instance.getInner().dispatchEvent(nativeEvent);
|
instance.getInner().dispatchEvent(nativeEvent);
|
||||||
|
|
||||||
expect(mouseOut).toBeCalled();
|
expect(mouseOut).toBeCalled();
|
||||||
expect(mouseOut.mock.calls.length).toBe(1);
|
expect(mouseOut).toHaveBeenCalledTimes(1);
|
||||||
expect(mouseOut.mock.calls[0][0]).toEqual(instance.getInner());
|
expect(mouseOut.mock.calls[0][0]).toEqual(instance.getInner());
|
||||||
document.body.removeChild(container);
|
document.body.removeChild(container);
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,7 +21,7 @@ describe('ReactDOMIframe', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should trigger load events', () => {
|
it('should trigger load events', () => {
|
||||||
const onLoadSpy = jasmine.createSpy();
|
const onLoadSpy = jest.fn();
|
||||||
let iframe = React.createElement('iframe', {onLoad: onLoadSpy});
|
let iframe = React.createElement('iframe', {onLoad: onLoadSpy});
|
||||||
iframe = ReactTestUtils.renderIntoDocument(iframe);
|
iframe = ReactTestUtils.renderIntoDocument(iframe);
|
||||||
|
|
||||||
|
|
|
@ -535,7 +535,7 @@ describe('ReactDOMInput', () => {
|
||||||
|
|
||||||
const node = container.firstChild;
|
const node = container.firstChild;
|
||||||
let nodeValue = 'a';
|
let nodeValue = 'a';
|
||||||
const nodeValueSetter = jest.genMockFn();
|
const nodeValueSetter = jest.fn();
|
||||||
Object.defineProperty(node, 'value', {
|
Object.defineProperty(node, 'value', {
|
||||||
get: function() {
|
get: function() {
|
||||||
return nodeValue;
|
return nodeValue;
|
||||||
|
@ -546,10 +546,10 @@ describe('ReactDOMInput', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
ReactDOM.render(<input value="a" onChange={() => {}} />, container);
|
ReactDOM.render(<input value="a" onChange={() => {}} />, container);
|
||||||
expect(nodeValueSetter.mock.calls.length).toBe(0);
|
expect(nodeValueSetter).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
ReactDOM.render(<input value="b" onChange={() => {}} />, container);
|
ReactDOM.render(<input value="b" onChange={() => {}} />, container);
|
||||||
expect(nodeValueSetter.mock.calls.length).toBe(1);
|
expect(nodeValueSetter).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not incur unnecessary DOM mutations for numeric type conversion', () => {
|
it('should not incur unnecessary DOM mutations for numeric type conversion', () => {
|
||||||
|
@ -558,7 +558,7 @@ describe('ReactDOMInput', () => {
|
||||||
|
|
||||||
const node = container.firstChild;
|
const node = container.firstChild;
|
||||||
let nodeValue = '0';
|
let nodeValue = '0';
|
||||||
const nodeValueSetter = jest.genMockFn();
|
const nodeValueSetter = jest.fn();
|
||||||
Object.defineProperty(node, 'value', {
|
Object.defineProperty(node, 'value', {
|
||||||
get: function() {
|
get: function() {
|
||||||
return nodeValue;
|
return nodeValue;
|
||||||
|
@ -569,7 +569,7 @@ describe('ReactDOMInput', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
ReactDOM.render(<input value={0} onChange={() => {}} />, container);
|
ReactDOM.render(<input value={0} onChange={() => {}} />, container);
|
||||||
expect(nodeValueSetter.mock.calls.length).toBe(0);
|
expect(nodeValueSetter).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not incur unnecessary DOM mutations for the boolean type conversion', () => {
|
it('should not incur unnecessary DOM mutations for the boolean type conversion', () => {
|
||||||
|
@ -578,7 +578,7 @@ describe('ReactDOMInput', () => {
|
||||||
|
|
||||||
const node = container.firstChild;
|
const node = container.firstChild;
|
||||||
let nodeValue = 'true';
|
let nodeValue = 'true';
|
||||||
const nodeValueSetter = jest.genMockFn();
|
const nodeValueSetter = jest.fn();
|
||||||
Object.defineProperty(node, 'value', {
|
Object.defineProperty(node, 'value', {
|
||||||
get: function() {
|
get: function() {
|
||||||
return nodeValue;
|
return nodeValue;
|
||||||
|
@ -589,7 +589,7 @@ describe('ReactDOMInput', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
ReactDOM.render(<input value={true} onChange={() => {}} />, container);
|
ReactDOM.render(<input value={true} onChange={() => {}} />, container);
|
||||||
expect(nodeValueSetter.mock.calls.length).toBe(0);
|
expect(nodeValueSetter).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should properly control a value of number `0`', () => {
|
it('should properly control a value of number `0`', () => {
|
||||||
|
|
|
@ -218,7 +218,7 @@ describe('ReactDOMTextarea', () => {
|
||||||
|
|
||||||
const node = container.firstChild;
|
const node = container.firstChild;
|
||||||
let nodeValue = 'a';
|
let nodeValue = 'a';
|
||||||
const nodeValueSetter = jest.genMockFn();
|
const nodeValueSetter = jest.fn();
|
||||||
Object.defineProperty(node, 'value', {
|
Object.defineProperty(node, 'value', {
|
||||||
get: function() {
|
get: function() {
|
||||||
return nodeValue;
|
return nodeValue;
|
||||||
|
@ -229,10 +229,10 @@ describe('ReactDOMTextarea', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
ReactDOM.render(<textarea value="a" onChange={emptyFunction} />, container);
|
ReactDOM.render(<textarea value="a" onChange={emptyFunction} />, container);
|
||||||
expect(nodeValueSetter.mock.calls.length).toBe(0);
|
expect(nodeValueSetter).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
ReactDOM.render(<textarea value="b" onChange={emptyFunction} />, container);
|
ReactDOM.render(<textarea value="b" onChange={emptyFunction} />, container);
|
||||||
expect(nodeValueSetter.mock.calls.length).toBe(1);
|
expect(nodeValueSetter).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should properly control a value of number `0`', () => {
|
it('should properly control a value of number `0`', () => {
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe('ReactEmptyComponent', () => {
|
||||||
ReactDOM = require('react-dom');
|
ReactDOM = require('react-dom');
|
||||||
ReactTestUtils = require('react-dom/test-utils');
|
ReactTestUtils = require('react-dom/test-utils');
|
||||||
|
|
||||||
log = jasmine.createSpy();
|
log = jest.fn();
|
||||||
|
|
||||||
TogglingComponent = class extends React.Component {
|
TogglingComponent = class extends React.Component {
|
||||||
state = {component: this.props.firstComponent};
|
state = {component: this.props.firstComponent};
|
||||||
|
@ -91,11 +91,17 @@ describe('ReactEmptyComponent', () => {
|
||||||
ReactTestUtils.renderIntoDocument(instance1);
|
ReactTestUtils.renderIntoDocument(instance1);
|
||||||
ReactTestUtils.renderIntoDocument(instance2);
|
ReactTestUtils.renderIntoDocument(instance2);
|
||||||
|
|
||||||
expect(log.calls.count()).toBe(4);
|
expect(log).toHaveBeenCalledTimes(4);
|
||||||
expect(log.calls.argsFor(0)[0]).toBe(null);
|
expect(log).toHaveBeenNthCalledWith(1, null);
|
||||||
expect(log.calls.argsFor(1)[0].tagName).toBe('DIV');
|
expect(log).toHaveBeenNthCalledWith(
|
||||||
expect(log.calls.argsFor(2)[0].tagName).toBe('DIV');
|
2,
|
||||||
expect(log.calls.argsFor(3)[0]).toBe(null);
|
expect.objectContaining({tagName: 'DIV'}),
|
||||||
|
);
|
||||||
|
expect(log).toHaveBeenNthCalledWith(
|
||||||
|
3,
|
||||||
|
expect.objectContaining({tagName: 'DIV'}),
|
||||||
|
);
|
||||||
|
expect(log).toHaveBeenNthCalledWith(4, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to switch in a list of children', () => {
|
it('should be able to switch in a list of children', () => {
|
||||||
|
@ -111,13 +117,22 @@ describe('ReactEmptyComponent', () => {
|
||||||
</div>,
|
</div>,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(log.calls.count()).toBe(6);
|
expect(log).toHaveBeenCalledTimes(6);
|
||||||
expect(log.calls.argsFor(0)[0]).toBe(null);
|
expect(log).toHaveBeenNthCalledWith(1, null);
|
||||||
expect(log.calls.argsFor(1)[0]).toBe(null);
|
expect(log).toHaveBeenNthCalledWith(2, null);
|
||||||
expect(log.calls.argsFor(2)[0]).toBe(null);
|
expect(log).toHaveBeenNthCalledWith(3, null);
|
||||||
expect(log.calls.argsFor(3)[0].tagName).toBe('DIV');
|
expect(log).toHaveBeenNthCalledWith(
|
||||||
expect(log.calls.argsFor(4)[0].tagName).toBe('DIV');
|
4,
|
||||||
expect(log.calls.argsFor(5)[0].tagName).toBe('DIV');
|
expect.objectContaining({tagName: 'DIV'}),
|
||||||
|
);
|
||||||
|
expect(log).toHaveBeenNthCalledWith(
|
||||||
|
5,
|
||||||
|
expect.objectContaining({tagName: 'DIV'}),
|
||||||
|
);
|
||||||
|
expect(log).toHaveBeenNthCalledWith(
|
||||||
|
6,
|
||||||
|
expect.objectContaining({tagName: 'DIV'}),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should distinguish between a script placeholder and an actual script tag', () => {
|
it('should distinguish between a script placeholder and an actual script tag', () => {
|
||||||
|
@ -135,11 +150,17 @@ describe('ReactEmptyComponent', () => {
|
||||||
ReactTestUtils.renderIntoDocument(instance2);
|
ReactTestUtils.renderIntoDocument(instance2);
|
||||||
}).not.toThrow();
|
}).not.toThrow();
|
||||||
|
|
||||||
expect(log.calls.count()).toBe(4);
|
expect(log).toHaveBeenCalledTimes(4);
|
||||||
expect(log.calls.argsFor(0)[0]).toBe(null);
|
expect(log).toHaveBeenNthCalledWith(1, null);
|
||||||
expect(log.calls.argsFor(1)[0].tagName).toBe('SCRIPT');
|
expect(log).toHaveBeenNthCalledWith(
|
||||||
expect(log.calls.argsFor(2)[0].tagName).toBe('SCRIPT');
|
2,
|
||||||
expect(log.calls.argsFor(3)[0]).toBe(null);
|
expect.objectContaining({tagName: 'SCRIPT'}),
|
||||||
|
);
|
||||||
|
expect(log).toHaveBeenNthCalledWith(
|
||||||
|
3,
|
||||||
|
expect.objectContaining({tagName: 'SCRIPT'}),
|
||||||
|
);
|
||||||
|
expect(log).toHaveBeenNthCalledWith(4, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(
|
it(
|
||||||
|
@ -172,11 +193,17 @@ describe('ReactEmptyComponent', () => {
|
||||||
ReactTestUtils.renderIntoDocument(instance2);
|
ReactTestUtils.renderIntoDocument(instance2);
|
||||||
}).not.toThrow();
|
}).not.toThrow();
|
||||||
|
|
||||||
expect(log.calls.count()).toBe(4);
|
expect(log).toHaveBeenCalledTimes(4);
|
||||||
expect(log.calls.argsFor(0)[0].tagName).toBe('DIV');
|
expect(log).toHaveBeenNthCalledWith(
|
||||||
expect(log.calls.argsFor(1)[0]).toBe(null);
|
1,
|
||||||
expect(log.calls.argsFor(2)[0]).toBe(null);
|
expect.objectContaining({tagName: 'DIV'}),
|
||||||
expect(log.calls.argsFor(3)[0].tagName).toBe('DIV');
|
);
|
||||||
|
expect(log).toHaveBeenNthCalledWith(2, null);
|
||||||
|
expect(log).toHaveBeenNthCalledWith(3, null);
|
||||||
|
expect(log).toHaveBeenNthCalledWith(
|
||||||
|
4,
|
||||||
|
expect.objectContaining({tagName: 'DIV'}),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -91,25 +91,25 @@ describe('ReactMount', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(mockMount.mock.calls.length).toBe(0);
|
expect(mockMount).toHaveBeenCalledTimes(0);
|
||||||
expect(mockUnmount.mock.calls.length).toBe(0);
|
expect(mockUnmount).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
ReactDOM.render(<Component text="orange" key="A" />, container);
|
ReactDOM.render(<Component text="orange" key="A" />, container);
|
||||||
expect(container.firstChild.innerHTML).toBe('orange');
|
expect(container.firstChild.innerHTML).toBe('orange');
|
||||||
expect(mockMount.mock.calls.length).toBe(1);
|
expect(mockMount).toHaveBeenCalledTimes(1);
|
||||||
expect(mockUnmount.mock.calls.length).toBe(0);
|
expect(mockUnmount).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
// If we change the key, the component is unmounted and remounted
|
// If we change the key, the component is unmounted and remounted
|
||||||
ReactDOM.render(<Component text="green" key="B" />, container);
|
ReactDOM.render(<Component text="green" key="B" />, container);
|
||||||
expect(container.firstChild.innerHTML).toBe('green');
|
expect(container.firstChild.innerHTML).toBe('green');
|
||||||
expect(mockMount.mock.calls.length).toBe(2);
|
expect(mockMount).toHaveBeenCalledTimes(2);
|
||||||
expect(mockUnmount.mock.calls.length).toBe(1);
|
expect(mockUnmount).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
// But if we don't change the key, the component instance is reused
|
// But if we don't change the key, the component instance is reused
|
||||||
ReactDOM.render(<Component text="blue" key="B" />, container);
|
ReactDOM.render(<Component text="blue" key="B" />, container);
|
||||||
expect(container.firstChild.innerHTML).toBe('blue');
|
expect(container.firstChild.innerHTML).toBe('blue');
|
||||||
expect(mockMount.mock.calls.length).toBe(2);
|
expect(mockMount).toHaveBeenCalledTimes(2);
|
||||||
expect(mockUnmount.mock.calls.length).toBe(1);
|
expect(mockUnmount).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reuse markup if rendering to the same target twice', () => {
|
it('should reuse markup if rendering to the same target twice', () => {
|
||||||
|
|
|
@ -36,9 +36,9 @@ describe('ReactMultiChild', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(mockMount.mock.calls.length).toBe(0);
|
expect(mockMount).toHaveBeenCalledTimes(0);
|
||||||
expect(mockUpdate.mock.calls.length).toBe(0);
|
expect(mockUpdate).toHaveBeenCalledTimes(0);
|
||||||
expect(mockUnmount.mock.calls.length).toBe(0);
|
expect(mockUnmount).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<div>
|
<div>
|
||||||
|
@ -47,9 +47,9 @@ describe('ReactMultiChild', () => {
|
||||||
container,
|
container,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mockMount.mock.calls.length).toBe(1);
|
expect(mockMount).toHaveBeenCalledTimes(1);
|
||||||
expect(mockUpdate.mock.calls.length).toBe(0);
|
expect(mockUpdate).toHaveBeenCalledTimes(0);
|
||||||
expect(mockUnmount.mock.calls.length).toBe(0);
|
expect(mockUnmount).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<div>
|
<div>
|
||||||
|
@ -58,9 +58,9 @@ describe('ReactMultiChild', () => {
|
||||||
container,
|
container,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mockMount.mock.calls.length).toBe(1);
|
expect(mockMount).toHaveBeenCalledTimes(1);
|
||||||
expect(mockUpdate.mock.calls.length).toBe(1);
|
expect(mockUpdate).toHaveBeenCalledTimes(1);
|
||||||
expect(mockUnmount.mock.calls.length).toBe(0);
|
expect(mockUnmount).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should replace children with different constructors', () => {
|
it('should replace children with different constructors', () => {
|
||||||
|
@ -77,8 +77,8 @@ describe('ReactMultiChild', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(mockMount.mock.calls.length).toBe(0);
|
expect(mockMount).toHaveBeenCalledTimes(0);
|
||||||
expect(mockUnmount.mock.calls.length).toBe(0);
|
expect(mockUnmount).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<div>
|
<div>
|
||||||
|
@ -87,8 +87,8 @@ describe('ReactMultiChild', () => {
|
||||||
container,
|
container,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mockMount.mock.calls.length).toBe(1);
|
expect(mockMount).toHaveBeenCalledTimes(1);
|
||||||
expect(mockUnmount.mock.calls.length).toBe(0);
|
expect(mockUnmount).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<div>
|
<div>
|
||||||
|
@ -97,8 +97,8 @@ describe('ReactMultiChild', () => {
|
||||||
container,
|
container,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mockMount.mock.calls.length).toBe(1);
|
expect(mockMount).toHaveBeenCalledTimes(1);
|
||||||
expect(mockUnmount.mock.calls.length).toBe(1);
|
expect(mockUnmount).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should NOT replace children with different owners', () => {
|
it('should NOT replace children with different owners', () => {
|
||||||
|
@ -121,13 +121,13 @@ describe('ReactMultiChild', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(mockMount.mock.calls.length).toBe(0);
|
expect(mockMount).toHaveBeenCalledTimes(0);
|
||||||
expect(mockUnmount.mock.calls.length).toBe(0);
|
expect(mockUnmount).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
ReactDOM.render(<WrapperComponent />, container);
|
ReactDOM.render(<WrapperComponent />, container);
|
||||||
|
|
||||||
expect(mockMount.mock.calls.length).toBe(1);
|
expect(mockMount).toHaveBeenCalledTimes(1);
|
||||||
expect(mockUnmount.mock.calls.length).toBe(0);
|
expect(mockUnmount).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<WrapperComponent>
|
<WrapperComponent>
|
||||||
|
@ -136,8 +136,8 @@ describe('ReactMultiChild', () => {
|
||||||
container,
|
container,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mockMount.mock.calls.length).toBe(1);
|
expect(mockMount).toHaveBeenCalledTimes(1);
|
||||||
expect(mockUnmount.mock.calls.length).toBe(0);
|
expect(mockUnmount).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should replace children with different keys', () => {
|
it('should replace children with different keys', () => {
|
||||||
|
@ -154,8 +154,8 @@ describe('ReactMultiChild', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(mockMount.mock.calls.length).toBe(0);
|
expect(mockMount).toHaveBeenCalledTimes(0);
|
||||||
expect(mockUnmount.mock.calls.length).toBe(0);
|
expect(mockUnmount).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<div>
|
<div>
|
||||||
|
@ -164,8 +164,8 @@ describe('ReactMultiChild', () => {
|
||||||
container,
|
container,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mockMount.mock.calls.length).toBe(1);
|
expect(mockMount).toHaveBeenCalledTimes(1);
|
||||||
expect(mockUnmount.mock.calls.length).toBe(0);
|
expect(mockUnmount).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<div>
|
<div>
|
||||||
|
@ -174,8 +174,8 @@ describe('ReactMultiChild', () => {
|
||||||
container,
|
container,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mockMount.mock.calls.length).toBe(2);
|
expect(mockMount).toHaveBeenCalledTimes(2);
|
||||||
expect(mockUnmount.mock.calls.length).toBe(1);
|
expect(mockUnmount).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should warn for duplicated array keys with component stack info', () => {
|
it('should warn for duplicated array keys with component stack info', () => {
|
||||||
|
|
|
@ -290,7 +290,7 @@ describe('ReactTestUtils', () => {
|
||||||
ReactTestUtils.Simulate.change(node);
|
ReactTestUtils.Simulate.change(node);
|
||||||
|
|
||||||
expect(obj.handler).toHaveBeenCalledWith(
|
expect(obj.handler).toHaveBeenCalledWith(
|
||||||
jasmine.objectContaining({target: node}),
|
expect.objectContaining({target: node}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ describe('ReactTestUtils', () => {
|
||||||
ReactTestUtils.Simulate.change(node);
|
ReactTestUtils.Simulate.change(node);
|
||||||
|
|
||||||
expect(obj.handler).toHaveBeenCalledWith(
|
expect(obj.handler).toHaveBeenCalledWith(
|
||||||
jasmine.objectContaining({target: node}),
|
expect.objectContaining({target: node}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ describe('ReactTestUtils', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handler = jasmine.createSpy('spy');
|
const handler = jest.fn().mockName('spy');
|
||||||
const shallowRenderer = createRenderer();
|
const shallowRenderer = createRenderer();
|
||||||
const result = shallowRenderer.render(
|
const result = shallowRenderer.render(
|
||||||
<SomeComponent handleClick={handler} />,
|
<SomeComponent handleClick={handler} />,
|
||||||
|
@ -358,7 +358,7 @@ describe('ReactTestUtils', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handler = jasmine.createSpy('spy');
|
const handler = jest.fn().mockName('spy');
|
||||||
const container = document.createElement('div');
|
const container = document.createElement('div');
|
||||||
const instance = ReactDOM.render(
|
const instance = ReactDOM.render(
|
||||||
<SomeComponent handleClick={handler} />,
|
<SomeComponent handleClick={handler} />,
|
||||||
|
@ -394,7 +394,7 @@ describe('ReactTestUtils', () => {
|
||||||
|
|
||||||
it('should set the type of the event', () => {
|
it('should set the type of the event', () => {
|
||||||
let event;
|
let event;
|
||||||
const stub = jest.genMockFn().mockImplementation(e => {
|
const stub = jest.fn().mockImplementation(e => {
|
||||||
e.persist();
|
e.persist();
|
||||||
event = e;
|
event = e;
|
||||||
});
|
});
|
||||||
|
@ -431,7 +431,7 @@ describe('ReactTestUtils', () => {
|
||||||
ReactTestUtils.Simulate.change(input);
|
ReactTestUtils.Simulate.change(input);
|
||||||
|
|
||||||
expect(onChange).toHaveBeenCalledWith(
|
expect(onChange).toHaveBeenCalledWith(
|
||||||
jasmine.objectContaining({target: input}),
|
expect.objectContaining({target: input}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -63,7 +63,7 @@ module.exports = function(initModules) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
expect(console.error.calls.count()).toBe(count);
|
expect(console.error).toHaveBeenCalledTimes(count);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,9 +200,9 @@ describe('BeforeInputEventPlugin', () => {
|
||||||
spyOnBeforeInput,
|
spyOnBeforeInput,
|
||||||
spyOnCompositionStart,
|
spyOnCompositionStart,
|
||||||
}) => {
|
}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
expect(spyOnCompositionStart.mock.calls.length).toBe(1);
|
expect(spyOnCompositionStart).toHaveBeenCalledTimes(1);
|
||||||
expect(compositionStartEvent.type).toBe('compositionstart');
|
expect(compositionStartEvent.type).toBe('compositionstart');
|
||||||
expect(compositionStartEvent.data).toBe('test');
|
expect(compositionStartEvent.data).toBe('test');
|
||||||
},
|
},
|
||||||
|
@ -214,116 +214,116 @@ describe('BeforeInputEventPlugin', () => {
|
||||||
spyOnBeforeInput,
|
spyOnBeforeInput,
|
||||||
spyOnCompositionUpdate,
|
spyOnCompositionUpdate,
|
||||||
}) => {
|
}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
expect(spyOnCompositionUpdate.mock.calls.length).toBe(1);
|
expect(spyOnCompositionUpdate).toHaveBeenCalledTimes(1);
|
||||||
expect(compositionUpdateEvent.type).toBe('compositionupdate');
|
expect(compositionUpdateEvent.type).toBe('compositionupdate');
|
||||||
expect(compositionUpdateEvent.data).toBe('test string');
|
expect(compositionUpdateEvent.data).toBe('test string');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('compositionend');
|
expect(beforeInputEvent.type).toBe('compositionend');
|
||||||
expect(beforeInputEvent.data).toBe('test string 3');
|
expect(beforeInputEvent.data).toBe('test string 3');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('textInput');
|
expect(beforeInputEvent.type).toBe('textInput');
|
||||||
expect(beforeInputEvent.data).toBe('abcß');
|
expect(beforeInputEvent.data).toBe('abcß');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('keypress');
|
expect(beforeInputEvent.type).toBe('keypress');
|
||||||
expect(beforeInputEvent.data).toBe(' ');
|
expect(beforeInputEvent.data).toBe(' ');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('textInput');
|
expect(beforeInputEvent.type).toBe('textInput');
|
||||||
expect(beforeInputEvent.data).toBe('\uD83D\uDE0A');
|
expect(beforeInputEvent.data).toBe('\uD83D\uDE0A');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -334,119 +334,119 @@ describe('BeforeInputEventPlugin', () => {
|
||||||
assertions: [
|
assertions: [
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('keypress');
|
expect(beforeInputEvent.type).toBe('keypress');
|
||||||
expect(beforeInputEvent.data).toBe('a');
|
expect(beforeInputEvent.data).toBe('a');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('keypress');
|
expect(beforeInputEvent.type).toBe('keypress');
|
||||||
expect(beforeInputEvent.data).toBe(' ');
|
expect(beforeInputEvent.data).toBe(' ');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('keypress');
|
expect(beforeInputEvent.type).toBe('keypress');
|
||||||
expect(beforeInputEvent.data).toBe('c');
|
expect(beforeInputEvent.data).toBe('c');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('keypress');
|
expect(beforeInputEvent.type).toBe('keypress');
|
||||||
expect(beforeInputEvent.data).toBe('\uD83D\uDE0A');
|
expect(beforeInputEvent.data).toBe('\uD83D\uDE0A');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -457,122 +457,122 @@ describe('BeforeInputEventPlugin', () => {
|
||||||
assertions: [
|
assertions: [
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('keypress');
|
expect(beforeInputEvent.type).toBe('keypress');
|
||||||
expect(beforeInputEvent.data).toBe('a');
|
expect(beforeInputEvent.data).toBe('a');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('keypress');
|
expect(beforeInputEvent.type).toBe('keypress');
|
||||||
expect(beforeInputEvent.data).toBe(' ');
|
expect(beforeInputEvent.data).toBe(' ');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('keypress');
|
expect(beforeInputEvent.type).toBe('keypress');
|
||||||
expect(beforeInputEvent.data).toBe('c');
|
expect(beforeInputEvent.data).toBe('c');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('keypress');
|
expect(beforeInputEvent.type).toBe('keypress');
|
||||||
expect(beforeInputEvent.data).toBe('\uD83D\uDE0A');
|
expect(beforeInputEvent.data).toBe('\uD83D\uDE0A');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('keydown');
|
expect(beforeInputEvent.type).toBe('keydown');
|
||||||
expect(beforeInputEvent.data).toBe('bar');
|
expect(beforeInputEvent.data).toBe('bar');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('keyup');
|
expect(beforeInputEvent.type).toBe('keyup');
|
||||||
expect(beforeInputEvent.data).toBe('BAR');
|
expect(beforeInputEvent.data).toBe('BAR');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('keypress');
|
expect(beforeInputEvent.type).toBe('keypress');
|
||||||
expect(beforeInputEvent.data).toBe('Bar');
|
expect(beforeInputEvent.data).toBe('Bar');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -583,120 +583,120 @@ describe('BeforeInputEventPlugin', () => {
|
||||||
assertions: [
|
assertions: [
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('compositionend');
|
expect(beforeInputEvent.type).toBe('compositionend');
|
||||||
expect(beforeInputEvent.data).toBe('test string 3');
|
expect(beforeInputEvent.data).toBe('test string 3');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('keypress');
|
expect(beforeInputEvent.type).toBe('keypress');
|
||||||
expect(beforeInputEvent.data).toBe('a');
|
expect(beforeInputEvent.data).toBe('a');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('keypress');
|
expect(beforeInputEvent.type).toBe('keypress');
|
||||||
expect(beforeInputEvent.data).toBe(' ');
|
expect(beforeInputEvent.data).toBe(' ');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('keypress');
|
expect(beforeInputEvent.type).toBe('keypress');
|
||||||
expect(beforeInputEvent.data).toBe('c');
|
expect(beforeInputEvent.data).toBe('c');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(1);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
|
||||||
expect(beforeInputEvent.type).toBe('keypress');
|
expect(beforeInputEvent.type).toBe('keypress');
|
||||||
expect(beforeInputEvent.data).toBe('\uD83D\uDE0A');
|
expect(beforeInputEvent.data).toBe('\uD83D\uDE0A');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
run: ({beforeInputEvent, spyOnBeforeInput}) => {
|
||||||
expect(spyOnBeforeInput.mock.calls.length).toBe(0);
|
expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);
|
||||||
expect(beforeInputEvent).toBeNull();
|
expect(beforeInputEvent).toBeNull();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -72,7 +72,7 @@ describe('SelectEventPlugin', () => {
|
||||||
// Verify that it doesn't get "stuck" waiting for
|
// Verify that it doesn't get "stuck" waiting for
|
||||||
// a `mouseup` event that it has "missed" because
|
// a `mouseup` event that it has "missed" because
|
||||||
// a top-level listener didn't exist yet.
|
// a top-level listener didn't exist yet.
|
||||||
expect(select.mock.calls.length).toBe(1);
|
expect(select).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fire `onSelect` when a listener is present', () => {
|
it('should fire `onSelect` when a listener is present', () => {
|
||||||
|
@ -95,17 +95,17 @@ describe('SelectEventPlugin', () => {
|
||||||
cancelable: true,
|
cancelable: true,
|
||||||
});
|
});
|
||||||
node.dispatchEvent(nativeEvent);
|
node.dispatchEvent(nativeEvent);
|
||||||
expect(select.mock.calls.length).toBe(0);
|
expect(select).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
nativeEvent = new MouseEvent('mousedown', {
|
nativeEvent = new MouseEvent('mousedown', {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
cancelable: true,
|
cancelable: true,
|
||||||
});
|
});
|
||||||
node.dispatchEvent(nativeEvent);
|
node.dispatchEvent(nativeEvent);
|
||||||
expect(select.mock.calls.length).toBe(0);
|
expect(select).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
nativeEvent = new MouseEvent('mouseup', {bubbles: true, cancelable: true});
|
nativeEvent = new MouseEvent('mouseup', {bubbles: true, cancelable: true});
|
||||||
node.dispatchEvent(nativeEvent);
|
node.dispatchEvent(nativeEvent);
|
||||||
expect(select.mock.calls.length).toBe(1);
|
expect(select).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,12 +19,12 @@ describe('SimpleEventPlugin', function() {
|
||||||
|
|
||||||
function expectClickThru(element) {
|
function expectClickThru(element) {
|
||||||
ReactTestUtils.SimulateNative.click(ReactDOM.findDOMNode(element));
|
ReactTestUtils.SimulateNative.click(ReactDOM.findDOMNode(element));
|
||||||
expect(onClick.mock.calls.length).toBe(1);
|
expect(onClick).toHaveBeenCalledTimes(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function expectNoClickThru(element) {
|
function expectNoClickThru(element) {
|
||||||
ReactTestUtils.SimulateNative.click(ReactDOM.findDOMNode(element));
|
ReactTestUtils.SimulateNative.click(ReactDOM.findDOMNode(element));
|
||||||
expect(onClick.mock.calls.length).toBe(0);
|
expect(onClick).toHaveBeenCalledTimes(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function mounted(element) {
|
function mounted(element) {
|
||||||
|
@ -79,7 +79,7 @@ describe('SimpleEventPlugin', function() {
|
||||||
const child = ReactDOM.findDOMNode(element).firstChild;
|
const child = ReactDOM.findDOMNode(element).firstChild;
|
||||||
|
|
||||||
ReactTestUtils.SimulateNative.click(child);
|
ReactTestUtils.SimulateNative.click(child);
|
||||||
expect(onClick.mock.calls.length).toBe(1);
|
expect(onClick).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not register a click when clicking a child of a disabled element', function() {
|
it('does not register a click when clicking a child of a disabled element', function() {
|
||||||
|
@ -91,7 +91,7 @@ describe('SimpleEventPlugin', function() {
|
||||||
const child = ReactDOM.findDOMNode(element).querySelector('span');
|
const child = ReactDOM.findDOMNode(element).querySelector('span');
|
||||||
|
|
||||||
ReactTestUtils.SimulateNative.click(child);
|
ReactTestUtils.SimulateNative.click(child);
|
||||||
expect(onClick.mock.calls.length).toBe(0);
|
expect(onClick).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('triggers click events for children of disabled elements', function() {
|
it('triggers click events for children of disabled elements', function() {
|
||||||
|
@ -103,7 +103,7 @@ describe('SimpleEventPlugin', function() {
|
||||||
const child = ReactDOM.findDOMNode(element).querySelector('span');
|
const child = ReactDOM.findDOMNode(element).querySelector('span');
|
||||||
|
|
||||||
ReactTestUtils.SimulateNative.click(child);
|
ReactTestUtils.SimulateNative.click(child);
|
||||||
expect(onClick.mock.calls.length).toBe(1);
|
expect(onClick).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('triggers parent captured click events when target is a child of a disabled elements', function() {
|
it('triggers parent captured click events when target is a child of a disabled elements', function() {
|
||||||
|
@ -117,7 +117,7 @@ describe('SimpleEventPlugin', function() {
|
||||||
const child = ReactDOM.findDOMNode(element).querySelector('span');
|
const child = ReactDOM.findDOMNode(element).querySelector('span');
|
||||||
|
|
||||||
ReactTestUtils.SimulateNative.click(child);
|
ReactTestUtils.SimulateNative.click(child);
|
||||||
expect(onClick.mock.calls.length).toBe(1);
|
expect(onClick).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('triggers captured click events for children of disabled elements', function() {
|
it('triggers captured click events for children of disabled elements', function() {
|
||||||
|
@ -129,7 +129,7 @@ describe('SimpleEventPlugin', function() {
|
||||||
const child = ReactDOM.findDOMNode(element).querySelector('span');
|
const child = ReactDOM.findDOMNode(element).querySelector('span');
|
||||||
|
|
||||||
ReactTestUtils.SimulateNative.click(child);
|
ReactTestUtils.SimulateNative.click(child);
|
||||||
expect(onClick.mock.calls.length).toBe(1);
|
expect(onClick).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
['button', 'input', 'select', 'textarea'].forEach(function(tagName) {
|
['button', 'input', 'select', 'textarea'].forEach(function(tagName) {
|
||||||
|
@ -467,7 +467,7 @@ describe('SimpleEventPlugin', function() {
|
||||||
|
|
||||||
node.dispatchEvent(new MouseEvent('click'));
|
node.dispatchEvent(new MouseEvent('click'));
|
||||||
|
|
||||||
expect(onClick.mock.calls.length).toBe(0);
|
expect(onClick).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds a local click listener to non-interactive elements', function() {
|
it('adds a local click listener to non-interactive elements', function() {
|
||||||
|
@ -479,7 +479,7 @@ describe('SimpleEventPlugin', function() {
|
||||||
|
|
||||||
node.dispatchEvent(new MouseEvent('click'));
|
node.dispatchEvent(new MouseEvent('click'));
|
||||||
|
|
||||||
expect(onClick.mock.calls.length).toBe(0);
|
expect(onClick).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -56,12 +56,12 @@ describe('ReactFabric', () => {
|
||||||
|
|
||||||
ReactFabric.render(<View foo="foo" />, 11);
|
ReactFabric.render(<View foo="foo" />, 11);
|
||||||
|
|
||||||
expect(FabricUIManager.createNode.mock.calls.length).toBe(1);
|
expect(FabricUIManager.createNode).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
ReactFabric.render(<View foo="bar" />, 11);
|
ReactFabric.render(<View foo="bar" />, 11);
|
||||||
|
|
||||||
expect(FabricUIManager.createNode.mock.calls.length).toBe(1);
|
expect(FabricUIManager.createNode).toHaveBeenCalledTimes(1);
|
||||||
expect(FabricUIManager.cloneNodeWithNewProps.mock.calls.length).toBe(1);
|
expect(FabricUIManager.cloneNodeWithNewProps).toHaveBeenCalledTimes(1);
|
||||||
expect(FabricUIManager.cloneNodeWithNewProps.mock.calls[0][0]).toBe(
|
expect(FabricUIManager.cloneNodeWithNewProps.mock.calls[0][0]).toBe(
|
||||||
firstNode,
|
firstNode,
|
||||||
);
|
);
|
||||||
|
@ -93,24 +93,24 @@ describe('ReactFabric', () => {
|
||||||
ReactFabric.render(<Text foo="b">1</Text>, 11);
|
ReactFabric.render(<Text foo="b">1</Text>, 11);
|
||||||
expect(FabricUIManager.cloneNode).not.toBeCalled();
|
expect(FabricUIManager.cloneNode).not.toBeCalled();
|
||||||
expect(FabricUIManager.cloneNodeWithNewChildren).not.toBeCalled();
|
expect(FabricUIManager.cloneNodeWithNewChildren).not.toBeCalled();
|
||||||
expect(FabricUIManager.cloneNodeWithNewProps.mock.calls.length).toBe(1);
|
expect(FabricUIManager.cloneNodeWithNewProps).toHaveBeenCalledTimes(1);
|
||||||
expect(FabricUIManager.cloneNodeWithNewChildrenAndProps).not.toBeCalled();
|
expect(FabricUIManager.cloneNodeWithNewChildrenAndProps).not.toBeCalled();
|
||||||
|
|
||||||
// Only call cloneNode for the changed text (and no other properties).
|
// Only call cloneNode for the changed text (and no other properties).
|
||||||
ReactFabric.render(<Text foo="b">2</Text>, 11);
|
ReactFabric.render(<Text foo="b">2</Text>, 11);
|
||||||
expect(FabricUIManager.cloneNode).not.toBeCalled();
|
expect(FabricUIManager.cloneNode).not.toBeCalled();
|
||||||
expect(FabricUIManager.cloneNodeWithNewChildren.mock.calls.length).toBe(1);
|
expect(FabricUIManager.cloneNodeWithNewChildren).toHaveBeenCalledTimes(1);
|
||||||
expect(FabricUIManager.cloneNodeWithNewProps.mock.calls.length).toBe(1);
|
expect(FabricUIManager.cloneNodeWithNewProps).toHaveBeenCalledTimes(1);
|
||||||
expect(FabricUIManager.cloneNodeWithNewChildrenAndProps).not.toBeCalled();
|
expect(FabricUIManager.cloneNodeWithNewChildrenAndProps).not.toBeCalled();
|
||||||
|
|
||||||
// Call cloneNode for both changed text and properties.
|
// Call cloneNode for both changed text and properties.
|
||||||
ReactFabric.render(<Text foo="c">3</Text>, 11);
|
ReactFabric.render(<Text foo="c">3</Text>, 11);
|
||||||
expect(FabricUIManager.cloneNode).not.toBeCalled();
|
expect(FabricUIManager.cloneNode).not.toBeCalled();
|
||||||
expect(FabricUIManager.cloneNodeWithNewChildren.mock.calls.length).toBe(1);
|
expect(FabricUIManager.cloneNodeWithNewChildren).toHaveBeenCalledTimes(1);
|
||||||
expect(FabricUIManager.cloneNodeWithNewProps.mock.calls.length).toBe(1);
|
expect(FabricUIManager.cloneNodeWithNewProps).toHaveBeenCalledTimes(1);
|
||||||
expect(
|
expect(
|
||||||
FabricUIManager.cloneNodeWithNewChildrenAndProps.mock.calls.length,
|
FabricUIManager.cloneNodeWithNewChildrenAndProps,
|
||||||
).toBe(1);
|
).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should only pass props diffs to FabricUIManager.cloneNode', () => {
|
it('should only pass props diffs to FabricUIManager.cloneNode', () => {
|
||||||
|
@ -186,7 +186,7 @@ describe('ReactFabric', () => {
|
||||||
expect(UIManager.updateView).not.toBeCalled();
|
expect(UIManager.updateView).not.toBeCalled();
|
||||||
|
|
||||||
viewRef.setNativeProps({foo: 'baz'});
|
viewRef.setNativeProps({foo: 'baz'});
|
||||||
expect(UIManager.updateView.mock.calls.length).toBe(1);
|
expect(UIManager.updateView).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -74,14 +74,14 @@ beforeEach(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fails if unknown/unsupported event types are dispatched', () => {
|
it('fails if unknown/unsupported event types are dispatched', () => {
|
||||||
expect(RCTEventEmitter.register.mock.calls.length).toBe(1);
|
expect(RCTEventEmitter.register).toHaveBeenCalledTimes(1);
|
||||||
const EventEmitter = RCTEventEmitter.register.mock.calls[0][0];
|
const EventEmitter = RCTEventEmitter.register.mock.calls[0][0];
|
||||||
const View = fakeRequireNativeComponent('View', {});
|
const View = fakeRequireNativeComponent('View', {});
|
||||||
|
|
||||||
ReactNative.render(<View onUnspecifiedEvent={() => {}} />, 1);
|
ReactNative.render(<View onUnspecifiedEvent={() => {}} />, 1);
|
||||||
|
|
||||||
expect(UIManager.__dumpHierarchyForJestTestsOnly()).toMatchSnapshot();
|
expect(UIManager.__dumpHierarchyForJestTestsOnly()).toMatchSnapshot();
|
||||||
expect(UIManager.createView.mock.calls.length).toBe(1);
|
expect(UIManager.createView).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
const target = UIManager.createView.mock.calls[0][0];
|
const target = UIManager.createView.mock.calls[0][0];
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ it('fails if unknown/unsupported event types are dispatched', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles events', () => {
|
it('handles events', () => {
|
||||||
expect(RCTEventEmitter.register.mock.calls.length).toBe(1);
|
expect(RCTEventEmitter.register).toHaveBeenCalledTimes(1);
|
||||||
const EventEmitter = RCTEventEmitter.register.mock.calls[0][0];
|
const EventEmitter = RCTEventEmitter.register.mock.calls[0][0];
|
||||||
const View = fakeRequireNativeComponent('View', {foo: true});
|
const View = fakeRequireNativeComponent('View', {foo: true});
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ it('handles events', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(UIManager.__dumpHierarchyForJestTestsOnly()).toMatchSnapshot();
|
expect(UIManager.__dumpHierarchyForJestTestsOnly()).toMatchSnapshot();
|
||||||
expect(UIManager.createView.mock.calls.length).toBe(2);
|
expect(UIManager.createView).toHaveBeenCalledTimes(2);
|
||||||
|
|
||||||
// Don't depend on the order of createView() calls.
|
// Don't depend on the order of createView() calls.
|
||||||
// Stack creates views outside-in; fiber creates them inside-out.
|
// Stack creates views outside-in; fiber creates them inside-out.
|
||||||
|
@ -151,7 +151,7 @@ it('handles events', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles events on text nodes', () => {
|
it('handles events on text nodes', () => {
|
||||||
expect(RCTEventEmitter.register.mock.calls.length).toBe(1);
|
expect(RCTEventEmitter.register).toHaveBeenCalledTimes(1);
|
||||||
const EventEmitter = RCTEventEmitter.register.mock.calls[0][0];
|
const EventEmitter = RCTEventEmitter.register.mock.calls[0][0];
|
||||||
const Text = fakeRequireNativeComponent('RCTText', {});
|
const Text = fakeRequireNativeComponent('RCTText', {});
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ it('handles events on text nodes', () => {
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(UIManager.createView.mock.calls.length).toBe(5);
|
expect(UIManager.createView).toHaveBeenCalledTimes(5);
|
||||||
|
|
||||||
// Don't depend on the order of createView() calls.
|
// Don't depend on the order of createView() calls.
|
||||||
// Stack creates views outside-in; fiber creates them inside-out.
|
// Stack creates views outside-in; fiber creates them inside-out.
|
||||||
|
|
|
@ -47,15 +47,15 @@ describe('ReactNative', () => {
|
||||||
|
|
||||||
ReactNative.render(<View foo="foo" />, 11);
|
ReactNative.render(<View foo="foo" />, 11);
|
||||||
|
|
||||||
expect(UIManager.createView.mock.calls.length).toBe(1);
|
expect(UIManager.createView).toHaveBeenCalledTimes(1);
|
||||||
expect(UIManager.setChildren.mock.calls.length).toBe(1);
|
expect(UIManager.setChildren).toHaveBeenCalledTimes(1);
|
||||||
expect(UIManager.manageChildren).not.toBeCalled();
|
expect(UIManager.manageChildren).not.toBeCalled();
|
||||||
expect(UIManager.updateView).not.toBeCalled();
|
expect(UIManager.updateView).not.toBeCalled();
|
||||||
|
|
||||||
ReactNative.render(<View foo="bar" />, 11);
|
ReactNative.render(<View foo="bar" />, 11);
|
||||||
|
|
||||||
expect(UIManager.createView.mock.calls.length).toBe(1);
|
expect(UIManager.createView).toHaveBeenCalledTimes(1);
|
||||||
expect(UIManager.setChildren.mock.calls.length).toBe(1);
|
expect(UIManager.setChildren).toHaveBeenCalledTimes(1);
|
||||||
expect(UIManager.manageChildren).not.toBeCalled();
|
expect(UIManager.manageChildren).not.toBeCalled();
|
||||||
expect(UIManager.updateView).toBeCalledWith(3, 'RCTView', {foo: 'bar'});
|
expect(UIManager.updateView).toBeCalledWith(3, 'RCTView', {foo: 'bar'});
|
||||||
});
|
});
|
||||||
|
@ -75,15 +75,15 @@ describe('ReactNative', () => {
|
||||||
|
|
||||||
// Only call updateView for the changed property (and not for text).
|
// Only call updateView for the changed property (and not for text).
|
||||||
ReactNative.render(<Text foo="b">1</Text>, 11);
|
ReactNative.render(<Text foo="b">1</Text>, 11);
|
||||||
expect(UIManager.updateView.mock.calls.length).toBe(1);
|
expect(UIManager.updateView).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
// Only call updateView for the changed text (and no other properties).
|
// Only call updateView for the changed text (and no other properties).
|
||||||
ReactNative.render(<Text foo="b">2</Text>, 11);
|
ReactNative.render(<Text foo="b">2</Text>, 11);
|
||||||
expect(UIManager.updateView.mock.calls.length).toBe(2);
|
expect(UIManager.updateView).toHaveBeenCalledTimes(2);
|
||||||
|
|
||||||
// Call updateView for both changed text and properties.
|
// Call updateView for both changed text and properties.
|
||||||
ReactNative.render(<Text foo="c">3</Text>, 11);
|
ReactNative.render(<Text foo="c">3</Text>, 11);
|
||||||
expect(UIManager.updateView.mock.calls.length).toBe(4);
|
expect(UIManager.updateView).toHaveBeenCalledTimes(4);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not call UIManager.updateView from setNativeProps for properties that have not changed', () => {
|
it('should not call UIManager.updateView from setNativeProps for properties that have not changed', () => {
|
||||||
|
@ -117,7 +117,7 @@ describe('ReactNative', () => {
|
||||||
expect(UIManager.updateView).not.toBeCalled();
|
expect(UIManager.updateView).not.toBeCalled();
|
||||||
|
|
||||||
viewRef.setNativeProps({foo: 'baz'});
|
viewRef.setNativeProps({foo: 'baz'});
|
||||||
expect(UIManager.updateView.mock.calls.length).toBe(1);
|
expect(UIManager.updateView).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1198,12 +1198,12 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||||
expect(ReactNoop.getChildren()).toEqual([span('Caught an error: oops')]);
|
expect(ReactNoop.getChildren()).toEqual([span('Caught an error: oops')]);
|
||||||
|
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
expect(console.error.calls.count()).toBe(1);
|
expect(console.error).toHaveBeenCalledTimes(1);
|
||||||
expect(console.error.calls.argsFor(0)[0]).toContain(
|
expect(console.error.calls.argsFor(0)[0]).toContain(
|
||||||
'The above error occurred in the <BadRender> component:',
|
'The above error occurred in the <BadRender> component:',
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
expect(console.error.calls.count()).toBe(1);
|
expect(console.error).toHaveBeenCalledTimes(1);
|
||||||
expect(console.error.calls.argsFor(0)[0]).toBe(notAnError);
|
expect(console.error.calls.argsFor(0)[0]).toBe(notAnError);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -145,7 +145,7 @@ describe('ReactIncrementalErrorLogging', () => {
|
||||||
expect(logCapturedErrorCalls.length).toBe(1);
|
expect(logCapturedErrorCalls.length).toBe(1);
|
||||||
|
|
||||||
// The error thrown in logCapturedError should also be logged
|
// The error thrown in logCapturedError should also be logged
|
||||||
expect(console.error.calls.count()).toBe(1);
|
expect(console.error).toHaveBeenCalledTimes(1);
|
||||||
expect(console.error.calls.argsFor(0)[0].message).toContain(
|
expect(console.error.calls.argsFor(0)[0].message).toContain(
|
||||||
'logCapturedError error',
|
'logCapturedError error',
|
||||||
);
|
);
|
||||||
|
|
|
@ -716,7 +716,7 @@ describe('ReactNewContext', () => {
|
||||||
ReactNoop.flush();
|
ReactNoop.flush();
|
||||||
|
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
expect(console.error.calls.count()).toBe(1);
|
expect(console.error).toHaveBeenCalledTimes(1);
|
||||||
expect(console.error.calls.argsFor(0)[0]).toContain(
|
expect(console.error.calls.argsFor(0)[0]).toContain(
|
||||||
'calculateChangedBits: Expected the return value to be a 31-bit ' +
|
'calculateChangedBits: Expected the return value to be a 31-bit ' +
|
||||||
'integer. Instead received: 4294967295',
|
'integer. Instead received: 4294967295',
|
||||||
|
|
|
@ -88,7 +88,7 @@ describe('ReactScheduler', () => {
|
||||||
const cb = jest.fn();
|
const cb = jest.fn();
|
||||||
scheduleWork(cb);
|
scheduleWork(cb);
|
||||||
advanceOneFrame({timeLeftInFrame: 15});
|
advanceOneFrame({timeLeftInFrame: 15});
|
||||||
expect(cb.mock.calls.length).toBe(1);
|
expect(cb).toHaveBeenCalledTimes(1);
|
||||||
// should not have timed out and should include a timeRemaining method
|
// should not have timed out and should include a timeRemaining method
|
||||||
expect(cb.mock.calls[0][0].didTimeout).toBe(false);
|
expect(cb.mock.calls[0][0].didTimeout).toBe(false);
|
||||||
expect(typeof cb.mock.calls[0][0].timeRemaining()).toBe('number');
|
expect(typeof cb.mock.calls[0][0].timeRemaining()).toBe('number');
|
||||||
|
@ -333,10 +333,10 @@ describe('ReactScheduler', () => {
|
||||||
const {scheduleWork, cancelScheduledWork} = ReactScheduler;
|
const {scheduleWork, cancelScheduledWork} = ReactScheduler;
|
||||||
const cb = jest.fn();
|
const cb = jest.fn();
|
||||||
const callbackId = scheduleWork(cb);
|
const callbackId = scheduleWork(cb);
|
||||||
expect(cb.mock.calls.length).toBe(0);
|
expect(cb).toHaveBeenCalledTimes(0);
|
||||||
cancelScheduledWork(callbackId);
|
cancelScheduledWork(callbackId);
|
||||||
advanceOneFrame({timeLeftInFrame: 15});
|
advanceOneFrame({timeLeftInFrame: 15});
|
||||||
expect(cb.mock.calls.length).toBe(0);
|
expect(cb).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('with multiple callbacks', () => {
|
describe('with multiple callbacks', () => {
|
||||||
|
@ -356,7 +356,7 @@ describe('ReactScheduler', () => {
|
||||||
advanceOneFrame({timeLeftInFrame: 15});
|
advanceOneFrame({timeLeftInFrame: 15});
|
||||||
// B should not get called because A cancelled B
|
// B should not get called because A cancelled B
|
||||||
expect(callbackLog).toEqual(['A']);
|
expect(callbackLog).toEqual(['A']);
|
||||||
expect(callbackB.mock.calls.length).toBe(0);
|
expect(callbackB).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1237,12 +1237,12 @@ describe('ReactShallowRenderer', () => {
|
||||||
|
|
||||||
shallowRenderer.render(<Component />);
|
shallowRenderer.render(<Component />);
|
||||||
|
|
||||||
expect(mockFn.mock.calls.length).toBe(2);
|
expect(mockFn).toHaveBeenCalledTimes(2);
|
||||||
|
|
||||||
// Ensure the callback queue is cleared after the callbacks are invoked
|
// Ensure the callback queue is cleared after the callbacks are invoked
|
||||||
const mountedInstance = shallowRenderer.getMountedInstance();
|
const mountedInstance = shallowRenderer.getMountedInstance();
|
||||||
mountedInstance.setState({foo: 'bar'}, () => mockFn());
|
mountedInstance.setState({foo: 'bar'}, () => mockFn());
|
||||||
expect(mockFn.mock.calls.length).toBe(3);
|
expect(mockFn).toHaveBeenCalledTimes(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call the setState callback even if shouldComponentUpdate = false', done => {
|
it('should call the setState callback even if shouldComponentUpdate = false', done => {
|
||||||
|
|
|
@ -21,7 +21,7 @@ describe('ReactChildren', () => {
|
||||||
|
|
||||||
it('should support identity for simple', () => {
|
it('should support identity for simple', () => {
|
||||||
const context = {};
|
const context = {};
|
||||||
const callback = jasmine.createSpy().and.callFake(function(kid, index) {
|
const callback = jest.fn().mockImplementation(function(kid, index) {
|
||||||
expect(this).toBe(context);
|
expect(this).toBe(context);
|
||||||
return kid;
|
return kid;
|
||||||
});
|
});
|
||||||
|
@ -34,7 +34,7 @@ describe('ReactChildren', () => {
|
||||||
const instance = <div>{simpleKid}</div>;
|
const instance = <div>{simpleKid}</div>;
|
||||||
React.Children.forEach(instance.props.children, callback, context);
|
React.Children.forEach(instance.props.children, callback, context);
|
||||||
expect(callback).toHaveBeenCalledWith(simpleKid, 0);
|
expect(callback).toHaveBeenCalledWith(simpleKid, 0);
|
||||||
callback.calls.reset();
|
callback.mockClear();
|
||||||
const mappedChildren = React.Children.map(
|
const mappedChildren = React.Children.map(
|
||||||
instance.props.children,
|
instance.props.children,
|
||||||
callback,
|
callback,
|
||||||
|
@ -46,7 +46,7 @@ describe('ReactChildren', () => {
|
||||||
|
|
||||||
it('should support Portal components', () => {
|
it('should support Portal components', () => {
|
||||||
const context = {};
|
const context = {};
|
||||||
const callback = jasmine.createSpy().and.callFake(function(kid, index) {
|
const callback = jest.fn().mockImplementation(function(kid, index) {
|
||||||
expect(this).toBe(context);
|
expect(this).toBe(context);
|
||||||
return kid;
|
return kid;
|
||||||
});
|
});
|
||||||
|
@ -59,7 +59,7 @@ describe('ReactChildren', () => {
|
||||||
const parentInstance = <div>{reactPortal}</div>;
|
const parentInstance = <div>{reactPortal}</div>;
|
||||||
React.Children.forEach(parentInstance.props.children, callback, context);
|
React.Children.forEach(parentInstance.props.children, callback, context);
|
||||||
expect(callback).toHaveBeenCalledWith(reactPortal, 0);
|
expect(callback).toHaveBeenCalledWith(reactPortal, 0);
|
||||||
callback.calls.reset();
|
callback.mockClear();
|
||||||
const mappedChildren = React.Children.map(
|
const mappedChildren = React.Children.map(
|
||||||
parentInstance.props.children,
|
parentInstance.props.children,
|
||||||
callback,
|
callback,
|
||||||
|
@ -71,7 +71,7 @@ describe('ReactChildren', () => {
|
||||||
|
|
||||||
it('should treat single arrayless child as being in array', () => {
|
it('should treat single arrayless child as being in array', () => {
|
||||||
const context = {};
|
const context = {};
|
||||||
const callback = jasmine.createSpy().and.callFake(function(kid, index) {
|
const callback = jest.fn().mockImplementation(function(kid, index) {
|
||||||
expect(this).toBe(context);
|
expect(this).toBe(context);
|
||||||
return kid;
|
return kid;
|
||||||
});
|
});
|
||||||
|
@ -80,7 +80,7 @@ describe('ReactChildren', () => {
|
||||||
const instance = <div>{simpleKid}</div>;
|
const instance = <div>{simpleKid}</div>;
|
||||||
React.Children.forEach(instance.props.children, callback, context);
|
React.Children.forEach(instance.props.children, callback, context);
|
||||||
expect(callback).toHaveBeenCalledWith(simpleKid, 0);
|
expect(callback).toHaveBeenCalledWith(simpleKid, 0);
|
||||||
callback.calls.reset();
|
callback.mockClear();
|
||||||
const mappedChildren = React.Children.map(
|
const mappedChildren = React.Children.map(
|
||||||
instance.props.children,
|
instance.props.children,
|
||||||
callback,
|
callback,
|
||||||
|
@ -92,7 +92,7 @@ describe('ReactChildren', () => {
|
||||||
|
|
||||||
it('should treat single child in array as expected', () => {
|
it('should treat single child in array as expected', () => {
|
||||||
const context = {};
|
const context = {};
|
||||||
const callback = jasmine.createSpy().and.callFake(function(kid, index) {
|
const callback = jest.fn().mockImplementation(function(kid, index) {
|
||||||
expect(this).toBe(context);
|
expect(this).toBe(context);
|
||||||
return kid;
|
return kid;
|
||||||
});
|
});
|
||||||
|
@ -101,7 +101,7 @@ describe('ReactChildren', () => {
|
||||||
const instance = <div>{[simpleKid]}</div>;
|
const instance = <div>{[simpleKid]}</div>;
|
||||||
React.Children.forEach(instance.props.children, callback, context);
|
React.Children.forEach(instance.props.children, callback, context);
|
||||||
expect(callback).toHaveBeenCalledWith(simpleKid, 0);
|
expect(callback).toHaveBeenCalledWith(simpleKid, 0);
|
||||||
callback.calls.reset();
|
callback.mockClear();
|
||||||
const mappedChildren = React.Children.map(
|
const mappedChildren = React.Children.map(
|
||||||
instance.props.children,
|
instance.props.children,
|
||||||
callback,
|
callback,
|
||||||
|
@ -119,7 +119,7 @@ describe('ReactChildren', () => {
|
||||||
const four = <div key="keyFour" />;
|
const four = <div key="keyFour" />;
|
||||||
const context = {};
|
const context = {};
|
||||||
|
|
||||||
const callback = jasmine.createSpy().and.callFake(function(kid) {
|
const callback = jest.fn().mockImplementation(function(kid) {
|
||||||
expect(this).toBe(context);
|
expect(this).toBe(context);
|
||||||
return kid;
|
return kid;
|
||||||
});
|
});
|
||||||
|
@ -140,7 +140,7 @@ describe('ReactChildren', () => {
|
||||||
expect(callback).toHaveBeenCalledWith(two, 2);
|
expect(callback).toHaveBeenCalledWith(two, 2);
|
||||||
expect(callback).toHaveBeenCalledWith(three, 3);
|
expect(callback).toHaveBeenCalledWith(three, 3);
|
||||||
expect(callback).toHaveBeenCalledWith(four, 4);
|
expect(callback).toHaveBeenCalledWith(four, 4);
|
||||||
callback.calls.reset();
|
callback.mockClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
React.Children.forEach(instance.props.children, callback, context);
|
React.Children.forEach(instance.props.children, callback, context);
|
||||||
|
@ -165,7 +165,7 @@ describe('ReactChildren', () => {
|
||||||
const a = <a key="aNode" />;
|
const a = <a key="aNode" />;
|
||||||
|
|
||||||
const context = {};
|
const context = {};
|
||||||
const callback = jasmine.createSpy().and.callFake(function(kid) {
|
const callback = jest.fn().mockImplementation(function(kid) {
|
||||||
expect(this).toBe(context);
|
expect(this).toBe(context);
|
||||||
return kid;
|
return kid;
|
||||||
});
|
});
|
||||||
|
@ -185,7 +185,7 @@ describe('ReactChildren', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
function assertCalls() {
|
function assertCalls() {
|
||||||
expect(callback.calls.count()).toBe(9);
|
expect(callback).toHaveBeenCalledTimes(9);
|
||||||
expect(callback).toHaveBeenCalledWith(div, 0);
|
expect(callback).toHaveBeenCalledWith(div, 0);
|
||||||
expect(callback).toHaveBeenCalledWith(span, 1);
|
expect(callback).toHaveBeenCalledWith(span, 1);
|
||||||
expect(callback).toHaveBeenCalledWith(a, 2);
|
expect(callback).toHaveBeenCalledWith(a, 2);
|
||||||
|
@ -195,7 +195,7 @@ describe('ReactChildren', () => {
|
||||||
expect(callback).toHaveBeenCalledWith(null, 6);
|
expect(callback).toHaveBeenCalledWith(null, 6);
|
||||||
expect(callback).toHaveBeenCalledWith(null, 7);
|
expect(callback).toHaveBeenCalledWith(null, 7);
|
||||||
expect(callback).toHaveBeenCalledWith(null, 8);
|
expect(callback).toHaveBeenCalledWith(null, 8);
|
||||||
callback.calls.reset();
|
callback.mockClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
React.Children.forEach(instance.props.children, callback, context);
|
React.Children.forEach(instance.props.children, callback, context);
|
||||||
|
@ -225,21 +225,21 @@ describe('ReactChildren', () => {
|
||||||
const five = <div key="keyFive" />;
|
const five = <div key="keyFive" />;
|
||||||
|
|
||||||
const context = {};
|
const context = {};
|
||||||
const callback = jasmine.createSpy().and.callFake(function(kid) {
|
const callback = jest.fn().mockImplementation(function(kid) {
|
||||||
return kid;
|
return kid;
|
||||||
});
|
});
|
||||||
|
|
||||||
const instance = <div>{[[zero, one, two], [three, four], five]}</div>;
|
const instance = <div>{[[zero, one, two], [three, four], five]}</div>;
|
||||||
|
|
||||||
function assertCalls() {
|
function assertCalls() {
|
||||||
expect(callback.calls.count()).toBe(6);
|
expect(callback).toHaveBeenCalledTimes(6);
|
||||||
expect(callback).toHaveBeenCalledWith(zero, 0);
|
expect(callback).toHaveBeenCalledWith(zero, 0);
|
||||||
expect(callback).toHaveBeenCalledWith(one, 1);
|
expect(callback).toHaveBeenCalledWith(one, 1);
|
||||||
expect(callback).toHaveBeenCalledWith(two, 2);
|
expect(callback).toHaveBeenCalledWith(two, 2);
|
||||||
expect(callback).toHaveBeenCalledWith(three, 3);
|
expect(callback).toHaveBeenCalledWith(three, 3);
|
||||||
expect(callback).toHaveBeenCalledWith(four, 4);
|
expect(callback).toHaveBeenCalledWith(four, 4);
|
||||||
expect(callback).toHaveBeenCalledWith(five, 5);
|
expect(callback).toHaveBeenCalledWith(five, 5);
|
||||||
callback.calls.reset();
|
callback.mockClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
React.Children.forEach(instance.props.children, callback, context);
|
React.Children.forEach(instance.props.children, callback, context);
|
||||||
|
@ -263,7 +263,7 @@ describe('ReactChildren', () => {
|
||||||
const zeroForceKey = <div key="keyZero" />;
|
const zeroForceKey = <div key="keyZero" />;
|
||||||
const oneForceKey = <div key="keyOne" />;
|
const oneForceKey = <div key="keyOne" />;
|
||||||
const context = {};
|
const context = {};
|
||||||
const callback = jasmine.createSpy().and.callFake(function(kid) {
|
const callback = jest.fn().mockImplementation(function(kid) {
|
||||||
expect(this).toBe(context);
|
expect(this).toBe(context);
|
||||||
return kid;
|
return kid;
|
||||||
});
|
});
|
||||||
|
@ -278,7 +278,7 @@ describe('ReactChildren', () => {
|
||||||
function assertCalls() {
|
function assertCalls() {
|
||||||
expect(callback).toHaveBeenCalledWith(zeroForceKey, 0);
|
expect(callback).toHaveBeenCalledWith(zeroForceKey, 0);
|
||||||
expect(callback).toHaveBeenCalledWith(oneForceKey, 1);
|
expect(callback).toHaveBeenCalledWith(oneForceKey, 1);
|
||||||
callback.calls.reset();
|
callback.mockClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
React.Children.forEach(forcedKeys.props.children, callback, context);
|
React.Children.forEach(forcedKeys.props.children, callback, context);
|
||||||
|
@ -313,7 +313,7 @@ describe('ReactChildren', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const context = {};
|
const context = {};
|
||||||
const callback = jasmine.createSpy().and.callFake(function(kid) {
|
const callback = jest.fn().mockImplementation(function(kid) {
|
||||||
expect(this).toBe(context);
|
expect(this).toBe(context);
|
||||||
return kid;
|
return kid;
|
||||||
});
|
});
|
||||||
|
@ -324,11 +324,11 @@ describe('ReactChildren', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
function assertCalls() {
|
function assertCalls() {
|
||||||
expect(callback.calls.count()).toBe(3);
|
expect(callback).toHaveBeenCalledTimes(3);
|
||||||
expect(callback).toHaveBeenCalledWith(<div />, 0);
|
expect(callback).toHaveBeenCalledWith(<div />, 0);
|
||||||
expect(callback).toHaveBeenCalledWith(<div />, 1);
|
expect(callback).toHaveBeenCalledWith(<div />, 1);
|
||||||
expect(callback).toHaveBeenCalledWith(<div />, 2);
|
expect(callback).toHaveBeenCalledWith(<div />, 2);
|
||||||
callback.calls.reset();
|
callback.mockClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
React.Children.forEach(instance.props.children, callback, context);
|
React.Children.forEach(instance.props.children, callback, context);
|
||||||
|
@ -364,7 +364,7 @@ describe('ReactChildren', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const context = {};
|
const context = {};
|
||||||
const callback = jasmine.createSpy().and.callFake(function(kid) {
|
const callback = jest.fn().mockImplementation(function(kid) {
|
||||||
expect(this).toBe(context);
|
expect(this).toBe(context);
|
||||||
return kid;
|
return kid;
|
||||||
});
|
});
|
||||||
|
@ -372,11 +372,11 @@ describe('ReactChildren', () => {
|
||||||
const instance = <div>{threeDivIterable}</div>;
|
const instance = <div>{threeDivIterable}</div>;
|
||||||
|
|
||||||
function assertCalls() {
|
function assertCalls() {
|
||||||
expect(callback.calls.count()).toBe(3);
|
expect(callback).toHaveBeenCalledTimes(3);
|
||||||
expect(callback).toHaveBeenCalledWith(<div key="#1" />, 0);
|
expect(callback).toHaveBeenCalledWith(<div key="#1" />, 0);
|
||||||
expect(callback).toHaveBeenCalledWith(<div key="#2" />, 1);
|
expect(callback).toHaveBeenCalledWith(<div key="#2" />, 1);
|
||||||
expect(callback).toHaveBeenCalledWith(<div key="#3" />, 2);
|
expect(callback).toHaveBeenCalledWith(<div key="#3" />, 2);
|
||||||
callback.calls.reset();
|
callback.mockClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
React.Children.forEach(instance.props.children, callback, context);
|
React.Children.forEach(instance.props.children, callback, context);
|
||||||
|
@ -412,17 +412,17 @@ describe('ReactChildren', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
const context = {};
|
const context = {};
|
||||||
const callback = jasmine.createSpy().and.callFake(function(kid) {
|
const callback = jest.fn().mockImplementation(function(kid) {
|
||||||
expect(this).toBe(context);
|
expect(this).toBe(context);
|
||||||
return kid;
|
return kid;
|
||||||
});
|
});
|
||||||
|
|
||||||
const assertCalls = function() {
|
const assertCalls = function() {
|
||||||
expect(callback.calls.count()).toBe(3);
|
expect(callback).toHaveBeenCalledTimes(3);
|
||||||
expect(callback).toHaveBeenCalledWith(5, 0);
|
expect(callback).toHaveBeenCalledWith(5, 0);
|
||||||
expect(callback).toHaveBeenCalledWith(12, 1);
|
expect(callback).toHaveBeenCalledWith(12, 1);
|
||||||
expect(callback).toHaveBeenCalledWith(13, 2);
|
expect(callback).toHaveBeenCalledWith(13, 2);
|
||||||
callback.calls.reset();
|
callback.mockClear();
|
||||||
};
|
};
|
||||||
|
|
||||||
React.Children.forEach(instance.props.children, callback, context);
|
React.Children.forEach(instance.props.children, callback, context);
|
||||||
|
@ -454,16 +454,16 @@ describe('ReactChildren', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
const context = {};
|
const context = {};
|
||||||
const callback = jasmine.createSpy().and.callFake(function(kid) {
|
const callback = jest.fn().mockImplementation(function(kid) {
|
||||||
expect(this).toBe(context);
|
expect(this).toBe(context);
|
||||||
return kid;
|
return kid;
|
||||||
});
|
});
|
||||||
|
|
||||||
function assertCalls() {
|
function assertCalls() {
|
||||||
expect(callback.calls.count()).toBe(2, 0);
|
expect(callback).toHaveBeenCalledTimes(2, 0);
|
||||||
expect(callback).toHaveBeenCalledWith('a', 0);
|
expect(callback).toHaveBeenCalledWith('a', 0);
|
||||||
expect(callback).toHaveBeenCalledWith(13, 1);
|
expect(callback).toHaveBeenCalledWith(13, 1);
|
||||||
callback.calls.reset();
|
callback.mockClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
React.Children.forEach(instance.props.children, callback, context);
|
React.Children.forEach(instance.props.children, callback, context);
|
||||||
|
@ -536,7 +536,7 @@ describe('ReactChildren', () => {
|
||||||
<span />, // Map from null to something.
|
<span />, // Map from null to something.
|
||||||
<div key="keyFour" />,
|
<div key="keyFour" />,
|
||||||
];
|
];
|
||||||
const callback = jasmine.createSpy().and.callFake(function(kid, index) {
|
const callback = jest.fn().mockImplementation(function(kid, index) {
|
||||||
return mapped[index];
|
return mapped[index];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -556,13 +556,13 @@ describe('ReactChildren', () => {
|
||||||
expect(callback).toHaveBeenCalledWith(two, 2);
|
expect(callback).toHaveBeenCalledWith(two, 2);
|
||||||
expect(callback).toHaveBeenCalledWith(three, 3);
|
expect(callback).toHaveBeenCalledWith(three, 3);
|
||||||
expect(callback).toHaveBeenCalledWith(four, 4);
|
expect(callback).toHaveBeenCalledWith(four, 4);
|
||||||
callback.calls.reset();
|
callback.mockClear();
|
||||||
|
|
||||||
const mappedChildren = React.Children.map(
|
const mappedChildren = React.Children.map(
|
||||||
instance.props.children,
|
instance.props.children,
|
||||||
callback,
|
callback,
|
||||||
);
|
);
|
||||||
expect(callback.calls.count()).toBe(5);
|
expect(callback).toHaveBeenCalledTimes(5);
|
||||||
expect(React.Children.count(mappedChildren)).toBe(4);
|
expect(React.Children.count(mappedChildren)).toBe(4);
|
||||||
// Keys default to indices.
|
// Keys default to indices.
|
||||||
expect([
|
expect([
|
||||||
|
@ -597,7 +597,7 @@ describe('ReactChildren', () => {
|
||||||
const fourMapped = <div key="keyFour" />;
|
const fourMapped = <div key="keyFour" />;
|
||||||
const fiveMapped = <div />;
|
const fiveMapped = <div />;
|
||||||
|
|
||||||
const callback = jasmine.createSpy().and.callFake(function(kid) {
|
const callback = jest.fn().mockImplementation(function(kid) {
|
||||||
switch (kid) {
|
switch (kid) {
|
||||||
case zero:
|
case zero:
|
||||||
return zeroMapped;
|
return zeroMapped;
|
||||||
|
@ -616,20 +616,20 @@ describe('ReactChildren', () => {
|
||||||
const instance = <div>{[frag]}</div>;
|
const instance = <div>{[frag]}</div>;
|
||||||
|
|
||||||
React.Children.forEach(instance.props.children, callback);
|
React.Children.forEach(instance.props.children, callback);
|
||||||
expect(callback.calls.count()).toBe(6);
|
expect(callback).toHaveBeenCalledTimes(6);
|
||||||
expect(callback).toHaveBeenCalledWith(zero, 0);
|
expect(callback).toHaveBeenCalledWith(zero, 0);
|
||||||
expect(callback).toHaveBeenCalledWith(one, 1);
|
expect(callback).toHaveBeenCalledWith(one, 1);
|
||||||
expect(callback).toHaveBeenCalledWith(two, 2);
|
expect(callback).toHaveBeenCalledWith(two, 2);
|
||||||
expect(callback).toHaveBeenCalledWith(three, 3);
|
expect(callback).toHaveBeenCalledWith(three, 3);
|
||||||
expect(callback).toHaveBeenCalledWith(four, 4);
|
expect(callback).toHaveBeenCalledWith(four, 4);
|
||||||
expect(callback).toHaveBeenCalledWith(five, 5);
|
expect(callback).toHaveBeenCalledWith(five, 5);
|
||||||
callback.calls.reset();
|
callback.mockClear();
|
||||||
|
|
||||||
const mappedChildren = React.Children.map(
|
const mappedChildren = React.Children.map(
|
||||||
instance.props.children,
|
instance.props.children,
|
||||||
callback,
|
callback,
|
||||||
);
|
);
|
||||||
expect(callback.calls.count()).toBe(6);
|
expect(callback).toHaveBeenCalledTimes(6);
|
||||||
expect(callback).toHaveBeenCalledWith(zero, 0);
|
expect(callback).toHaveBeenCalledWith(zero, 0);
|
||||||
expect(callback).toHaveBeenCalledWith(one, 1);
|
expect(callback).toHaveBeenCalledWith(one, 1);
|
||||||
expect(callback).toHaveBeenCalledWith(two, 2);
|
expect(callback).toHaveBeenCalledWith(two, 2);
|
||||||
|
|
|
@ -2,13 +2,6 @@
|
||||||
|
|
||||||
const jestDiff = require('jest-diff');
|
const jestDiff = require('jest-diff');
|
||||||
|
|
||||||
function diffString(a, b) {
|
|
||||||
// jest-diff does not currently handle single line strings correctly
|
|
||||||
// The easiest work around is to ensure that both strings are multiline
|
|
||||||
// https://github.com/facebook/jest/issues/5657
|
|
||||||
return jestDiff(a + '\n', b + '\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizeCodeLocInfo(str) {
|
function normalizeCodeLocInfo(str) {
|
||||||
return str && str.replace(/at .+?:\d+/g, 'at **');
|
return str && str.replace(/at .+?:\d+/g, 'at **');
|
||||||
}
|
}
|
||||||
|
@ -56,11 +49,11 @@ const createMatcherFor = consoleMethod =>
|
||||||
} else if (expectedMessages.length === 1) {
|
} else if (expectedMessages.length === 1) {
|
||||||
errorMessage =
|
errorMessage =
|
||||||
'Unexpected warning recorded: ' +
|
'Unexpected warning recorded: ' +
|
||||||
diffString(normalizedMessage, expectedMessages[0]);
|
jestDiff(normalizedMessage, expectedMessages[0]);
|
||||||
} else {
|
} else {
|
||||||
errorMessage =
|
errorMessage =
|
||||||
'Unexpected warning recorded: ' +
|
'Unexpected warning recorded: ' +
|
||||||
diffString([normalizedMessage], expectedMessages);
|
jestDiff([normalizedMessage], expectedMessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record the call stack for unexpected warnings.
|
// Record the call stack for unexpected warnings.
|
||||||
|
|
Loading…
Reference in New Issue