chore(deps): update dependency @testing-library/react to v10 (#4046)
This commit is contained in:
parent
6a1cbc9e32
commit
3640e2692e
@ -9,4 +9,5 @@ module.exports = {
|
||||
'netlify-cms-widget-object': '<rootDir>/packages/netlify-cms-widget-object/src/index.js',
|
||||
},
|
||||
testURL: 'http://localhost:8080',
|
||||
snapshotSerializers: ['jest-emotion'],
|
||||
};
|
||||
|
11
package.json
11
package.json
@ -92,8 +92,8 @@
|
||||
"@storybook/addon-actions": "^5.3.6",
|
||||
"@storybook/addon-links": "^5.3.6",
|
||||
"@storybook/react": "^5.3.6",
|
||||
"@testing-library/jest-dom": "^5.0.0",
|
||||
"@testing-library/react": "^9.3.2",
|
||||
"@testing-library/jest-dom": "^5.11.1",
|
||||
"@testing-library/react": "^10.0.0",
|
||||
"@types/common-tags": "^1.8.0",
|
||||
"@types/jest": "^26.0.0",
|
||||
"@types/js-base64": "^2.3.1",
|
||||
@ -139,10 +139,9 @@
|
||||
"gitlab": "^14.1.1",
|
||||
"http-server": "^0.12.0",
|
||||
"husky": "^3.0.9",
|
||||
"jest": "^24.9.0",
|
||||
"jest-cli": "^24.5.0",
|
||||
"jest-dom": "^3.1.3",
|
||||
"jest-emotion": "^10.0.9",
|
||||
"jest": "^26.1.0",
|
||||
"jest-cli": "^26.1.0",
|
||||
"jest-emotion": "^10.0.32",
|
||||
"js-yaml": "^3.13.1",
|
||||
"mockserver-client": "^5.8.0",
|
||||
"mockserver-node": "^5.8.0",
|
||||
|
@ -39,7 +39,7 @@
|
||||
"@types/morgan": "^1.7.37",
|
||||
"@types/node": "^13.1.7",
|
||||
"@types/vfile-message": "^2.0.0",
|
||||
"jest": "^24.9.0",
|
||||
"jest": "^26.1.0",
|
||||
"netlify-cms-lib-util": "^2.11.0",
|
||||
"nodemon": "^2.0.2",
|
||||
"ts-jest": "^24.3.0",
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { fromJS, Map } from 'immutable';
|
||||
import { last } from 'lodash';
|
||||
import { render, fireEvent, wait } from '@testing-library/react';
|
||||
import { render, fireEvent, waitFor } from '@testing-library/react';
|
||||
import { NetlifyCmsWidgetRelation } from '../';
|
||||
|
||||
jest.mock('react-window', () => {
|
||||
@ -235,7 +235,7 @@ describe('Relation widget', () => {
|
||||
const { getAllByText, input } = setup({ field });
|
||||
fireEvent.keyDown(input, { key: 'ArrowDown' });
|
||||
|
||||
await wait(() => {
|
||||
await waitFor(() => {
|
||||
expect(getAllByText(/^Post # (\d{1,2}) post-number-\1$/)).toHaveLength(20);
|
||||
});
|
||||
});
|
||||
@ -245,7 +245,7 @@ describe('Relation widget', () => {
|
||||
const { getAllByText, input } = setup({ field });
|
||||
fireEvent.keyDown(input, { key: 'ArrowDown' });
|
||||
|
||||
await wait(() => {
|
||||
await waitFor(() => {
|
||||
expect(getAllByText(/^Post # (\d{1,2}) post-number-\1$/)).toHaveLength(10);
|
||||
});
|
||||
});
|
||||
@ -255,7 +255,7 @@ describe('Relation widget', () => {
|
||||
const { getAllByText, input } = setup({ field });
|
||||
fireEvent.change(input, { target: { value: 'YAML' } });
|
||||
|
||||
await wait(() => {
|
||||
await waitFor(() => {
|
||||
expect(getAllByText('YAML post post-yaml')).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
@ -269,8 +269,9 @@ describe('Relation widget', () => {
|
||||
post: { posts: { 'Post # 1': { title: 'Post # 1', slug: 'post-number-1' } } },
|
||||
};
|
||||
|
||||
await wait(() => {
|
||||
fireEvent.keyDown(input, { key: 'ArrowDown' });
|
||||
fireEvent.keyDown(input, { key: 'ArrowDown' });
|
||||
|
||||
await waitFor(() => {
|
||||
fireEvent.click(getByText(label));
|
||||
expect(onChangeSpy).toHaveBeenCalledTimes(1);
|
||||
expect(onChangeSpy).toHaveBeenCalledWith(value, metadata);
|
||||
@ -288,7 +289,7 @@ describe('Relation widget', () => {
|
||||
|
||||
setQueryHitsSpy(generateHits(1));
|
||||
|
||||
await wait(() => {
|
||||
await waitFor(() => {
|
||||
expect(getByText(label)).toBeInTheDocument();
|
||||
expect(onChangeSpy).toHaveBeenCalledTimes(1);
|
||||
expect(onChangeSpy).toHaveBeenCalledWith(value, metadata);
|
||||
@ -300,7 +301,7 @@ describe('Relation widget', () => {
|
||||
const { getAllByText, input } = setup({ field });
|
||||
fireEvent.change(input, { target: { value: 'Nested' } });
|
||||
|
||||
await wait(() => {
|
||||
await waitFor(() => {
|
||||
expect(getAllByText('Nested post post-nested Nested field 1')).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
@ -310,7 +311,7 @@ describe('Relation widget', () => {
|
||||
const { getAllByText, input } = setup({ field });
|
||||
fireEvent.change(input, { target: { value: 'Deeply nested' } });
|
||||
|
||||
await wait(() => {
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
getAllByText('Deeply nested post post-deeply-nested Deeply nested field'),
|
||||
).toHaveLength(1);
|
||||
@ -334,8 +335,8 @@ describe('Relation widget', () => {
|
||||
post: { posts: { 'post-number-1': { title: 'Post # 1', slug: 'post-number-1' } } },
|
||||
};
|
||||
|
||||
await wait(() => {
|
||||
fireEvent.keyDown(input, { key: 'ArrowDown' });
|
||||
fireEvent.keyDown(input, { key: 'ArrowDown' });
|
||||
await waitFor(() => {
|
||||
fireEvent.click(getByText(label));
|
||||
expect(onChangeSpy).toHaveBeenCalledTimes(1);
|
||||
expect(onChangeSpy).toHaveBeenCalledWith(value, metadata);
|
||||
@ -347,7 +348,7 @@ describe('Relation widget', () => {
|
||||
const { getAllByText, input } = setup({ field });
|
||||
fireEvent.keyDown(input, { key: 'ArrowDown' });
|
||||
|
||||
await wait(() => {
|
||||
await waitFor(() => {
|
||||
expect(getAllByText(/^Post # (\d{1,2})$/)).toHaveLength(20);
|
||||
});
|
||||
});
|
||||
@ -364,7 +365,7 @@ describe('Relation widget', () => {
|
||||
const { getByText, getAllByText, input, onChangeSpy } = setup({ field });
|
||||
fireEvent.keyDown(input, { key: 'ArrowDown' });
|
||||
|
||||
await wait(() => {
|
||||
await waitFor(() => {
|
||||
expect(getAllByText(/^post # \d$/)).toHaveLength(2);
|
||||
});
|
||||
|
||||
@ -393,16 +394,19 @@ describe('Relation widget', () => {
|
||||
post: { posts: { 'Post # 2': { title: 'Post # 2', slug: 'post-number-2' } } },
|
||||
};
|
||||
|
||||
await wait(() => {
|
||||
fireEvent.keyDown(input, { key: 'ArrowDown' });
|
||||
fireEvent.keyDown(input, { key: 'ArrowDown' });
|
||||
await waitFor(() => {
|
||||
fireEvent.click(getByText('Post # 1 post-number-1'));
|
||||
fireEvent.keyDown(input, { key: 'ArrowDown' });
|
||||
fireEvent.click(getByText('Post # 2 post-number-2'));
|
||||
|
||||
expect(onChangeSpy).toHaveBeenCalledTimes(2);
|
||||
expect(onChangeSpy).toHaveBeenCalledWith(fromJS(['Post # 1']), metadata1);
|
||||
expect(onChangeSpy).toHaveBeenCalledWith(fromJS(['Post # 1', 'Post # 2']), metadata2);
|
||||
});
|
||||
|
||||
fireEvent.keyDown(input, { key: 'ArrowDown' });
|
||||
await waitFor(() => {
|
||||
fireEvent.click(getByText('Post # 2 post-number-2'));
|
||||
});
|
||||
|
||||
expect(onChangeSpy).toHaveBeenCalledTimes(2);
|
||||
expect(onChangeSpy).toHaveBeenCalledWith(fromJS(['Post # 1']), metadata1);
|
||||
expect(onChangeSpy).toHaveBeenCalledWith(fromJS(['Post # 1', 'Post # 2']), metadata2);
|
||||
});
|
||||
|
||||
it('should update metadata for initial preview', async () => {
|
||||
@ -418,7 +422,7 @@ describe('Relation widget', () => {
|
||||
|
||||
setQueryHitsSpy(generateHits(2));
|
||||
|
||||
await wait(() => {
|
||||
await waitFor(() => {
|
||||
expect(getByText('Post # 1 post-number-1')).toBeInTheDocument();
|
||||
expect(getByText('Post # 2 post-number-2')).toBeInTheDocument();
|
||||
|
||||
@ -443,7 +447,7 @@ describe('Relation widget', () => {
|
||||
const { getAllByText, input, getByText } = setup({ field });
|
||||
fireEvent.keyDown(input, { key: 'ArrowDown' });
|
||||
|
||||
await wait(() => {
|
||||
await waitFor(() => {
|
||||
expect(getAllByText(/category/)).toHaveLength(2);
|
||||
expect(getByText('category 1')).toBeInTheDocument();
|
||||
expect(getByText('category 2')).toBeInTheDocument();
|
||||
@ -460,7 +464,7 @@ describe('Relation widget', () => {
|
||||
const { getAllByText, input, getByText } = setup({ field });
|
||||
fireEvent.keyDown(input, { key: 'ArrowDown' });
|
||||
|
||||
await wait(() => {
|
||||
await waitFor(() => {
|
||||
expect(getAllByText(/category/)).toHaveLength(2);
|
||||
expect(getByText('category 1')).toBeInTheDocument();
|
||||
expect(getByText('category 2')).toBeInTheDocument();
|
||||
|
@ -1,8 +1,6 @@
|
||||
/* eslint-disable emotion/no-vanilla */
|
||||
import '@testing-library/jest-dom/extend-expect';
|
||||
import fetch from 'node-fetch';
|
||||
import * as emotion from 'emotion';
|
||||
import { createSerializer } from 'jest-emotion';
|
||||
|
||||
jest.mock('path', () => {
|
||||
const actual = jest.requireActual('path');
|
||||
@ -13,4 +11,3 @@ jest.mock('path', () => {
|
||||
|
||||
window.fetch = fetch;
|
||||
window.URL.createObjectURL = jest.fn();
|
||||
expect.addSnapshotSerializer(createSerializer(emotion));
|
||||
|
Loading…
x
Reference in New Issue
Block a user