From 07960948ac7a227d27445861f207d57e15118d78 Mon Sep 17 00:00:00 2001 From: ismay Date: Wed, 29 Nov 2023 11:51:49 +0100 Subject: [PATCH] refactor: rely on cypress for jobswitch test --- package.json | 3 +- src/components/Switches/JobSwitch.test.js | 66 +---------------------- yarn.lock | 5 -- 3 files changed, 2 insertions(+), 72 deletions(-) diff --git a/package.json b/package.json index b4c602028..d578371d3 100644 --- a/package.json +++ b/package.json @@ -52,8 +52,7 @@ "stylelint": "^13.13.1", "stylelint-config-prettier": "^8.0.2", "stylelint-config-standard": "^22.0.0", - "stylelint-no-unsupported-browser-features": "^5.0.1", - "wait-for-expect": "^3.0.2" + "stylelint-no-unsupported-browser-features": "^5.0.1" }, "jest": { "setupFilesAfterEnv": [ diff --git a/src/components/Switches/JobSwitch.test.js b/src/components/Switches/JobSwitch.test.js index b66000251..00949c0a9 100644 --- a/src/components/Switches/JobSwitch.test.js +++ b/src/components/Switches/JobSwitch.test.js @@ -1,7 +1,5 @@ import React from 'react' -import waitForExpect from 'wait-for-expect' -import { shallow, mount } from 'enzyme' -import { CustomDataProvider } from '@dhis2/app-runtime' +import { shallow } from 'enzyme' import JobSwitch from './JobSwitch' describe('', () => { @@ -15,66 +13,4 @@ describe('', () => { /> ) }) - - it('enables an inactive job and refetches when toggle is clicked', async () => { - const answerSpy = jest.fn(() => 'response') - const refetchSpy = jest.fn(() => Promise.resolve()) - - const props = { - id: 'id', - checked: false, - disabled: false, - refetch: refetchSpy, - } - const data = { 'jobConfigurations/id/enable': answerSpy } - const wrapper = mount(, { - wrappingComponent: CustomDataProvider, - wrappingComponentProps: { data }, - }) - - wrapper - .find('input') - .find({ name: 'toggle-job-id' }) - .simulate('change', { target: { checked: !props.checked } }) - - await waitForExpect(() => { - expect(answerSpy).toHaveBeenCalledWith( - 'create', - expect.anything(), - expect.anything() - ) - expect(refetchSpy).toHaveBeenCalled() - }) - }) - - it('disables an active job and refetches when toggle is clicked', async () => { - const answerSpy = jest.fn(() => 'response') - const refetchSpy = jest.fn(() => Promise.resolve()) - - const props = { - id: 'id', - checked: true, - disabled: false, - refetch: refetchSpy, - } - const data = { 'jobConfigurations/id/disable': answerSpy } - const wrapper = mount(, { - wrappingComponent: CustomDataProvider, - wrappingComponentProps: { data }, - }) - - wrapper - .find('input') - .find({ name: 'toggle-job-id' }) - .simulate('change', { target: { checked: !props.checked } }) - - await waitForExpect(() => { - expect(answerSpy).toHaveBeenCalledWith( - 'create', - expect.anything(), - expect.anything() - ) - expect(refetchSpy).toHaveBeenCalled() - }) - }) }) diff --git a/yarn.lock b/yarn.lock index ef45bf29e..89d33d4a3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16147,11 +16147,6 @@ w3c-xmlserializer@^2.0.0: dependencies: xml-name-validator "^3.0.0" -wait-for-expect@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/wait-for-expect/-/wait-for-expect-3.0.2.tgz#d2f14b2f7b778c9b82144109c8fa89ceaadaa463" - integrity sha512-cfS1+DZxuav1aBYbaO/kE06EOS8yRw7qOFoD3XtjTkYvCvh3zUvNST8DXK/nPaeqIzIv3P3kL3lRJn8iwOiSag== - wait-on@5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/wait-on/-/wait-on-5.3.0.tgz#584e17d4b3fe7b46ac2b9f8e5e102c005c2776c7"