mirror of
https://github.com/ansible/awx.git
synced 2026-05-24 09:07:45 -02:30
update useWsJobs tests
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { act } from 'react-dom/test-utils';
|
import { act } from 'react-dom/test-utils';
|
||||||
import { mount } from 'enzyme';
|
|
||||||
import WS from 'jest-websocket-mock';
|
import WS from 'jest-websocket-mock';
|
||||||
|
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
||||||
import useWsJobs from './useWsJobs';
|
import useWsJobs from './useWsJobs';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -17,7 +17,8 @@ function TestInner() {
|
|||||||
return <div />;
|
return <div />;
|
||||||
}
|
}
|
||||||
function Test({ jobs, fetch }) {
|
function Test({ jobs, fetch }) {
|
||||||
const syncedJobs = useWsJobs(jobs, fetch);
|
const qsConfig = {};
|
||||||
|
const syncedJobs = useWsJobs(jobs, fetch, qsConfig);
|
||||||
return <TestInner jobs={syncedJobs} />;
|
return <TestInner jobs={syncedJobs} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ describe('useWsJobs hook', () => {
|
|||||||
|
|
||||||
test('should return jobs list', () => {
|
test('should return jobs list', () => {
|
||||||
const jobs = [{ id: 1 }];
|
const jobs = [{ id: 1 }];
|
||||||
wrapper = mount(<Test jobs={jobs} />);
|
wrapper = mountWithContexts(<Test jobs={jobs} />);
|
||||||
|
|
||||||
expect(wrapper.find('TestInner').prop('jobs')).toEqual(jobs);
|
expect(wrapper.find('TestInner').prop('jobs')).toEqual(jobs);
|
||||||
WS.clean();
|
WS.clean();
|
||||||
@@ -47,7 +48,7 @@ describe('useWsJobs hook', () => {
|
|||||||
|
|
||||||
const jobs = [{ id: 1 }];
|
const jobs = [{ id: 1 }];
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
wrapper = await mount(<Test jobs={jobs} />);
|
wrapper = await mountWithContexts(<Test jobs={jobs} />);
|
||||||
});
|
});
|
||||||
|
|
||||||
await mockServer.connected;
|
await mockServer.connected;
|
||||||
@@ -70,7 +71,7 @@ describe('useWsJobs hook', () => {
|
|||||||
|
|
||||||
const jobs = [{ id: 1, status: 'running' }];
|
const jobs = [{ id: 1, status: 'running' }];
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
wrapper = await mount(<Test jobs={jobs} />);
|
wrapper = await mountWithContexts(<Test jobs={jobs} />);
|
||||||
});
|
});
|
||||||
|
|
||||||
await mockServer.connected;
|
await mockServer.connected;
|
||||||
@@ -105,9 +106,9 @@ describe('useWsJobs hook', () => {
|
|||||||
global.document.cookie = 'csrftoken=abc123';
|
global.document.cookie = 'csrftoken=abc123';
|
||||||
const mockServer = new WS('wss://localhost/websocket/');
|
const mockServer = new WS('wss://localhost/websocket/');
|
||||||
const jobs = [{ id: 1 }];
|
const jobs = [{ id: 1 }];
|
||||||
const fetch = jest.fn();
|
const fetch = jest.fn(() => []);
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
wrapper = await mount(<Test jobs={jobs} fetch={fetch} />);
|
wrapper = await mountWithContexts(<Test jobs={jobs} fetch={fetch} />);
|
||||||
});
|
});
|
||||||
|
|
||||||
await mockServer.connected;
|
await mockServer.connected;
|
||||||
|
|||||||
Reference in New Issue
Block a user