11/*
2- Copyright 2022 The Matrix.org Foundation C.I.C.
2+ Copyright 2022, 2023 The Matrix.org Foundation C.I.C.
33
44Licensed under the Apache License, Version 2.0 (the "License");
55you may not use this file except in compliance with the License.
@@ -15,48 +15,39 @@ limitations under the License.
1515*/
1616
1717import React from "react" ;
18- // eslint-disable-next-line deprecate/import
19- import { mount } from "enzyme" ;
2018import * as maplibregl from "maplibre-gl" ;
21- import { act } from "react-dom/test-utils " ;
19+ import { render , screen } from "@testing-library/react " ;
2220
2321import ZoomButtons from "../../../../src/components/views/location/ZoomButtons" ;
24- import { findByTestId } from "../../../test-utils" ;
2522
2623describe ( "<ZoomButtons />" , ( ) => {
2724 const mapOptions = { container : { } as unknown as HTMLElement , style : "" } ;
2825 const mockMap = new maplibregl . Map ( mapOptions ) ;
2926 const defaultProps = {
3027 map : mockMap ,
3128 } ;
32- const getComponent = ( props = { } ) => mount ( < ZoomButtons { ...defaultProps } { ...props } /> ) ;
29+ const getComponent = ( props = { } ) => render ( < ZoomButtons { ...defaultProps } { ...props } /> ) ;
3330
3431 beforeEach ( ( ) => {
3532 jest . clearAllMocks ( ) ;
3633 } ) ;
3734
3835 it ( "renders buttons" , ( ) => {
3936 const component = getComponent ( ) ;
40- expect ( component ) . toMatchSnapshot ( ) ;
37+ expect ( component . asFragment ( ) ) . toMatchSnapshot ( ) ;
4138 } ) ;
4239
4340 it ( "calls map zoom in on zoom in click" , ( ) => {
4441 const component = getComponent ( ) ;
45-
46- act ( ( ) => {
47- findByTestId ( component , "map-zoom-in-button" ) . at ( 0 ) . simulate ( "click" ) ;
48- } ) ;
42+ screen . getByTestId ( "map-zoom-in-button" ) . click ( ) ;
4943
5044 expect ( mockMap . zoomIn ) . toHaveBeenCalled ( ) ;
5145 expect ( component ) . toBeTruthy ( ) ;
5246 } ) ;
5347
5448 it ( "calls map zoom out on zoom out click" , ( ) => {
5549 const component = getComponent ( ) ;
56-
57- act ( ( ) => {
58- findByTestId ( component , "map-zoom-out-button" ) . at ( 0 ) . simulate ( "click" ) ;
59- } ) ;
50+ screen . getByTestId ( "map-zoom-out-button" ) . click ( ) ;
6051
6152 expect ( mockMap . zoomOut ) . toHaveBeenCalled ( ) ;
6253 expect ( component ) . toBeTruthy ( ) ;
0 commit comments