Skip to content
Snippets Groups Projects
Commit 9c033d07 authored by Reinder Kraaij's avatar Reinder Kraaij :eye:
Browse files

ENhance waiting

parent 28a12bd5
No related branches found
No related tags found
1 merge request!1189Resolve TMSS-2810 "Skip legacy schedules"
import React from 'react';
// import ReactDOM, {unmountComponentAtNode} from 'react-dom';
import { BrowserRouter as Router } from 'react-router-dom'; import { BrowserRouter as Router } from 'react-router-dom';
// import { act } from 'react-dom/test-utils'; import { cleanup, render, fireEvent,waitFor,act} from '@testing-library/react';
import { cleanup, render, fireEvent} from '@testing-library/react';
import mockConsole from "jest-mock-console"; import mockConsole from "jest-mock-console";
import ProjectList from './list'; import ProjectList from './list';
import ProjectServiceMock from '../../__mocks__/project.service.data'; import ProjectServiceMock from '../../__mocks__/project.service.data';
...@@ -10,9 +7,8 @@ import ProjectService from '../../services/project.service'; ...@@ -10,9 +7,8 @@ import ProjectService from '../../services/project.service';
import 'regenerator-runtime/runtime' import 'regenerator-runtime/runtime'
import AuthUtil from '../../utils/auth.util'; import AuthUtil from '../../utils/auth.util';
import SUServiceMock from '../../__mocks__/scheduleunit.service.data'; import SUServiceMock from '../../__mocks__/scheduleunit.service.data';
import AuthServiceMock from '../../__mocks__/auth.service.data';
let container = null; let authSpy,projectListSpy, clusterSpy, fileSystemSpy, projectArchiveLocationSpy, projectStateSpy, rolesSpy, friendsSpy, resourceTypeSpy;
let authSpy, projectListSpy, clusterSpy, fileSystemSpy, projectArchiveLocationSpy, projectStateSpy, rolesSpy, friendsSpy, resourceTypeSpy;
let restoreConsole; let restoreConsole;
beforeEach(() =>{ beforeEach(() =>{
...@@ -57,9 +53,6 @@ const setMockSpy = (() => { ...@@ -57,9 +53,6 @@ const setMockSpy = (() => {
}) })
resourceTypeSpy = jest.spyOn(ProjectService, 'getResources'); resourceTypeSpy = jest.spyOn(ProjectService, 'getResources');
resourceTypeSpy.mockImplementation(() => { resourceTypeSpy.mockImplementation(() => {
let resourceType = {
result: ProjectServiceMock.resources
}
return Promise.resolve(ProjectServiceMock.resourceType) return Promise.resolve(ProjectServiceMock.resourceType)
}) })
rolesSpy = jest.spyOn(ProjectService, 'getMyRoles'); rolesSpy = jest.spyOn(ProjectService, 'getMyRoles');
...@@ -79,8 +72,11 @@ const clearMockSpy = (() => { ...@@ -79,8 +72,11 @@ const clearMockSpy = (() => {
}); });
it('render project list data in table without permission to add new project, project loading status and filter', async () => { it('render project list data in table without permission to add new project, project loading status and filter', async () => {
const content = render(<Router><ProjectList location={{pathname: "/project"}} /> </Router>); let content;
await new Promise((r) => setTimeout(r, 500)); await act(async () => {
content = render(<Router><ProjectList location={{pathname: "/project"}} /> </Router>);
});
// Checks page title // Checks page title
const titleElement = content.queryByText("Project - List"); const titleElement = content.queryByText("Project - List");
expect(titleElement).toBeInTheDocument() ; expect(titleElement).toBeInTheDocument() ;
...@@ -91,7 +87,8 @@ it('render project list data in table without permission to add new project, pro ...@@ -91,7 +87,8 @@ it('render project list data in table without permission to add new project, pro
expect(addAction).toBeInTheDocument(); expect(addAction).toBeInTheDocument();
// Checks if view table component loaded/rendered // Checks if view table component loaded/rendered
const tableElement = content.queryByTestId('viewtable'); const tableElement = content.queryByTestId('viewtable');
expect(tableElement).toBeInTheDocument(); await waitFor (()=> expect(tableElement).toBeInTheDocument());
// Checks if all mock data listed in the table with header // Checks if all mock data listed in the table with header
expect(content.queryAllByRole('row').length).toBe(5); expect(content.queryAllByRole('row').length).toBe(5);
...@@ -113,4 +110,5 @@ it('render project list data in table without permission to add new project, pro ...@@ -113,4 +110,5 @@ it('render project list data in table without permission to add new project, pro
expect(content.getByText('low')).toBeInTheDocument(); expect(content.getByText('low')).toBeInTheDocument();
expect(content.getByText('normal')).toBeInTheDocument(); expect(content.getByText('normal')).toBeInTheDocument();
}); });
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment