Reduce warnings in tests (#6132)

* Change i18next from wait to suspense (resolves console warning in app and in tests)

* Reduce error and warning output in fast tests
This commit is contained in:
Krzysztof Jelski 2021-09-16 15:08:53 +02:00 committed by GitHub
parent b70db161a6
commit ca8bbd1836
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 9 deletions

View File

@ -49,10 +49,14 @@ describe('Account store', () => {
});
it('get returns null if account does not exist', async () => {
jest.spyOn(console, 'error').mockImplementationOnce(() => { /**/ });
expect(await accountStore['account-store-get']('1')).toEqual(null);
});
it('account disappears from list after it is removed', async () => {
jest.spyOn(console, 'error').mockImplementationOnce(() => { /**/ });
await accountStore['account-store-set']('1', exampleAccount('a'));
await accountStore['account-store-remove']('1');

View File

@ -64,6 +64,7 @@ describe('Create an account modal', () => {
await expectThirdStep();
pressEnterKey();
await waitForElementToBeRemoved(() => screen.queryByText('Add an account via seed 3/3'));
expectCreateAnAccountCall();
});

View File

@ -2,13 +2,14 @@
// SPDX-License-Identifier: Apache-2.0
import { fireEvent, render, screen } from '@testing-library/react';
import React from 'react';
import React, { Suspense } from 'react';
import { ThemeProvider } from 'styled-components';
import { lightTheme } from '@polkadot/apps/themes';
import { useToggle } from '@polkadot/react-hooks';
import Button from '../Button';
import i18next from '../i18n';
import Modal from './index';
function TestModal () {
@ -45,13 +46,19 @@ function TestModal () {
function renderModal () {
return render(
<ThemeProvider theme={lightTheme}>
<TestModal />
</ThemeProvider>
<Suspense fallback='...'>
<ThemeProvider theme={lightTheme}>
<TestModal />
</ThemeProvider>
</Suspense>
);
}
describe('Modal Component', () => {
beforeAll(async () => {
await i18next.changeLanguage('en');
});
it('opens and closes modal', async () => {
renderModal();

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
import { fireEvent, render, screen } from '@testing-library/react';
import React from 'react';
import React, { Suspense } from 'react';
import { Popup } from '@polkadot/react-components';
import i18next from '@polkadot/react-components/i18n';
function TestPopup () {
return (
@ -23,11 +24,17 @@ function TestPopup () {
function renderPopup () {
return render(
<TestPopup />
<Suspense fallback='...'>
<TestPopup />
</Suspense>
);
}
describe('Popup Component', () => {
beforeAll(async () => {
await i18next.changeLanguage('en');
});
it('opens and closes', async () => {
renderPopup();

View File

@ -73,7 +73,7 @@ i18next
],
nsSeparator: false,
react: {
wait: true
useSuspense: true
},
returnEmptyString: false,
returnNull: false

View File

@ -20,11 +20,12 @@ export class Table {
async assertRowsOrder (balancesExpectedOrder: number[]): Promise<void> {
const orderedRows = await this.getRows();
await Promise.all(orderedRows.map(async (row, index) => {
for (let index = 0; index < orderedRows.length; index++) {
const row = orderedRows[index];
const expectedBalanceTextContent = showBalance(balancesExpectedOrder[index]);
expect(await row.getBalanceSummary()).toHaveTextContent(expectedBalanceTextContent);
}));
}
}
async assertColoring (): Promise<void> {