1
1
/*
2
- Copyright 2022 The Matrix.org Foundation C.I.C.
2
+ Copyright 2022, 2023 The Matrix.org Foundation C.I.C.
3
3
4
4
Licensed under the Apache License, Version 2.0 (the "License");
5
5
you may not use this file except in compliance with the License.
@@ -15,48 +15,39 @@ limitations under the License.
15
15
*/
16
16
17
17
import React from "react" ;
18
- // eslint-disable-next-line deprecate/import
19
- import { mount } from "enzyme" ;
20
18
import * as maplibregl from "maplibre-gl" ;
21
- import { act } from "react-dom/test-utils " ;
19
+ import { render , screen } from "@testing-library/react " ;
22
20
23
21
import ZoomButtons from "../../../../src/components/views/location/ZoomButtons" ;
24
- import { findByTestId } from "../../../test-utils" ;
25
22
26
23
describe ( "<ZoomButtons />" , ( ) => {
27
24
const mapOptions = { container : { } as unknown as HTMLElement , style : "" } ;
28
25
const mockMap = new maplibregl . Map ( mapOptions ) ;
29
26
const defaultProps = {
30
27
map : mockMap ,
31
28
} ;
32
- const getComponent = ( props = { } ) => mount ( < ZoomButtons { ...defaultProps } { ...props } /> ) ;
29
+ const getComponent = ( props = { } ) => render ( < ZoomButtons { ...defaultProps } { ...props } /> ) ;
33
30
34
31
beforeEach ( ( ) => {
35
32
jest . clearAllMocks ( ) ;
36
33
} ) ;
37
34
38
35
it ( "renders buttons" , ( ) => {
39
36
const component = getComponent ( ) ;
40
- expect ( component ) . toMatchSnapshot ( ) ;
37
+ expect ( component . asFragment ( ) ) . toMatchSnapshot ( ) ;
41
38
} ) ;
42
39
43
40
it ( "calls map zoom in on zoom in click" , ( ) => {
44
41
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 ( ) ;
49
43
50
44
expect ( mockMap . zoomIn ) . toHaveBeenCalled ( ) ;
51
45
expect ( component ) . toBeTruthy ( ) ;
52
46
} ) ;
53
47
54
48
it ( "calls map zoom out on zoom out click" , ( ) => {
55
49
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 ( ) ;
60
51
61
52
expect ( mockMap . zoomOut ) . toHaveBeenCalled ( ) ;
62
53
expect ( component ) . toBeTruthy ( ) ;
0 commit comments