From b5fba461ee40efeb1e7a5169a4a82d2d3ca0aafa Mon Sep 17 00:00:00 2001 From: Rachel Dauns Date: Tue, 16 Apr 2024 12:16:32 -0400 Subject: [PATCH] text-menu enzyme removed --- .../__tests__/common/components/switch.test.js | 4 ---- .../__tests__/common/components/text-menu.test.js | 14 ++++++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/app/obojobo-document-engine/__tests__/common/components/switch.test.js b/packages/app/obojobo-document-engine/__tests__/common/components/switch.test.js index 70ece6882d..01e940775f 100644 --- a/packages/app/obojobo-document-engine/__tests__/common/components/switch.test.js +++ b/packages/app/obojobo-document-engine/__tests__/common/components/switch.test.js @@ -43,16 +43,12 @@ describe('Switch', () => { const component = TestRenderer.create() const checkbox = component.root.findByType('input') - // Initially, the onChange function should not have been called expect(onChecked).not.toHaveBeenCalled() - // Simulate the change event by directly setting the checked attribute of the input element checkbox.props.onChange({ target: { checked: true } }) - // After simulating the change event, the onChange function should have been called once expect(onChecked).toHaveBeenCalledTimes(1) - // Also, it should have been called with the expected argument expect(onChecked).toHaveBeenCalledWith(expect.objectContaining({ target: { checked: true } })) }) }) diff --git a/packages/app/obojobo-document-engine/__tests__/common/components/text-menu.test.js b/packages/app/obojobo-document-engine/__tests__/common/components/text-menu.test.js index 74b022ace7..9cd6fcaf52 100644 --- a/packages/app/obojobo-document-engine/__tests__/common/components/text-menu.test.js +++ b/packages/app/obojobo-document-engine/__tests__/common/components/text-menu.test.js @@ -1,7 +1,5 @@ import React from 'react' import renderer from 'react-test-renderer' -import { mount } from 'enzyme' - import TextMenu from '../../../src/scripts/common/components/text-menu' const createRect = () => { @@ -59,8 +57,12 @@ describe('TextMenu', () => { test('TextMenu calls mouseDown', () => { const mockCommandHandler = jest.fn() + const mockEvent = { + preventDefault: jest.fn(), + stopPropagation: jest.fn() + } - const component = mount( + const component = renderer.create( createRect() @@ -72,8 +74,12 @@ describe('TextMenu', () => { /> ) - component.find('a').simulate('mouseDown') + const linkElement = component.root.findByType('a') + + linkElement.props.onMouseDown(mockEvent, 'Label') + expect(mockEvent.preventDefault).toHaveBeenCalledTimes(1) + expect(mockEvent.stopPropagation).toHaveBeenCalledTimes(1) expect(mockCommandHandler).toHaveBeenCalledWith('Label') }) })