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:
parent
b70db161a6
commit
ca8bbd1836
@ -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');
|
||||
|
||||
|
||||
@ -64,6 +64,7 @@ describe('Create an account modal', () => {
|
||||
await expectThirdStep();
|
||||
pressEnterKey();
|
||||
|
||||
await waitForElementToBeRemoved(() => screen.queryByText('Add an account via seed 3/3'));
|
||||
expectCreateAnAccountCall();
|
||||
});
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ i18next
|
||||
],
|
||||
nsSeparator: false,
|
||||
react: {
|
||||
wait: true
|
||||
useSuspense: true
|
||||
},
|
||||
returnEmptyString: false,
|
||||
returnNull: false
|
||||
|
||||
@ -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> {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user