Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hervedombya committed Aug 23, 2023
1 parent db3e9dd commit f26b7d4
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/react/databrowser/objects/__tests__/ObjectList.test.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { waitFor } from '@testing-library/react';
import { List } from 'immutable';
import router from 'react-router';
import { BUCKET_NAME } from '../../../actions/__tests__/utils/testUtil';
import * as s3object from '../../../actions/s3object';
import * as hooks from '../../../next-architecture/domain/business/buckets';
import * as queryHooks from '../../../utils/hooks';
import * as s3object from '../../../actions/s3object';
import { LIST_OBJECTS_S3_TYPE } from '../../../utils/s3';
import { checkBox, reduxMount } from '../../../utils/testUtil';
import ObjectList, { VEEAM_XML_PREFIX } from '../ObjectList';
import {
FIRST_FORMATTED_OBJECT,
SECOND_FORMATTED_OBJECT,
} from './utils/testUtil';
import { LIST_OBJECTS_S3_TYPE } from '../../../utils/s3';
import { checkBox, reduxMount } from '../../../utils/testUtil';
import { BUCKET_NAME } from '../../../actions/__tests__/utils/testUtil';
import { List } from 'immutable';
import ObjectList, { VEEAM_XML_PREFIX } from '../ObjectList';
import router from 'react-router';
import { waitFor } from '@testing-library/react';
describe('ObjectList', () => {
beforeAll(() => {
jest.spyOn(router, 'useLocation').mockReturnValue({
Expand Down Expand Up @@ -154,6 +154,10 @@ describe('ObjectList', () => {
jest.spyOn(hooks, 'useBucketVersionning').mockReturnValue({
versionning: { status: 'success', value: 'Enabled' },
});
jest
.spyOn(queryHooks, 'useQueryParams')
.mockReturnValueOnce(new URLSearchParams('?prefix=test'));

const { component } = reduxMount(
<ObjectList
objects={List([FIRST_FORMATTED_OBJECT])}
Expand All @@ -163,6 +167,7 @@ describe('ObjectList', () => {
listType={LIST_OBJECTS_S3_TYPE}
/>,
);

await waitFor(() => {
const toggle = component.find('ToggleSwitch#list-versions-toggle');
expect(toggle.prop('disabled')).toBe(false);
Expand All @@ -172,6 +177,10 @@ describe('ObjectList', () => {
jest.spyOn(hooks, 'useBucketVersionning').mockReturnValue({
versionning: { status: 'success', value: 'Suspended' },
});
jest
.spyOn(queryHooks, 'useQueryParams')
.mockReturnValueOnce(new URLSearchParams('?prefix=test'));

const { component } = reduxMount(
<ObjectList
objects={List([FIRST_FORMATTED_OBJECT])}
Expand Down Expand Up @@ -212,7 +221,9 @@ describe('ObjectList', () => {
});
jest
.spyOn(queryHooks, 'useQueryParams')
.mockReturnValue(new URLSearchParams(`?prefix=${VEEAM_XML_PREFIX}`));
.mockReturnValueOnce(
new URLSearchParams(`?prefix=${VEEAM_XML_PREFIX}?showversions=true`),
);

const { component } = reduxMount(
<ObjectList
Expand Down

0 comments on commit f26b7d4

Please sign in to comment.