@@ -16,6 +16,7 @@ import {
1616import { render } from "@testing-library/react" ;
1717import { INITIAL } from "../../../config" ;
1818import { fakeAddPlantProps } from "../../../../__test_support__/fake_props" ;
19+ import { fakeDrawnPoint } from "../../../../__test_support__/fake_designer_state" ;
1920import { clone } from "lodash" ;
2021import { Path } from "../../../../internal_urls" ;
2122import { Vector3 } from "three" ;
@@ -130,6 +131,42 @@ describe("soilClick()", () => {
130131 gardenCoords : { x : 1360 , y : 660 } ,
131132 } ) ) ;
132133 } ) ;
134+
135+ it ( "doesn't create a plant after a drag" , ( ) => {
136+ location . pathname = Path . mock ( Path . cropSearch ( "mint" ) ) ;
137+ mockIsMobile = false ;
138+ const p = fakeProps ( ) ;
139+ const e = {
140+ stopPropagation : jest . fn ( ) ,
141+ point : { x : 1 , y : 2 } ,
142+ delta : 3 ,
143+ } as unknown as ThreeEvent < MouseEvent > ;
144+ soilClick ( p ) ( e ) ;
145+ expect ( e . stopPropagation ) . toHaveBeenCalled ( ) ;
146+ expect ( dropPlantSpy ) . not . toHaveBeenCalled ( ) ;
147+ } ) ;
148+
149+ it . each ( [
150+ [ "point" , Path . points ( "add" ) ] ,
151+ [ "weed" , Path . weeds ( "add" ) ] ,
152+ ] ) ( "doesn't set %s location after a drag" , ( _label , path ) => {
153+ location . pathname = Path . mock ( path ) ;
154+ mockIsMobile = false ;
155+ const p = fakeProps ( ) ;
156+ const point = fakeDrawnPoint ( ) ;
157+ point . cx = undefined ;
158+ point . cy = undefined ;
159+ point . r = 0 ;
160+ p . addPlantProps . designer . drawnPoint = point ;
161+ const e = {
162+ stopPropagation : jest . fn ( ) ,
163+ point : { x : 1 , y : 2 } ,
164+ delta : 3 ,
165+ } as unknown as ThreeEvent < MouseEvent > ;
166+ soilClick ( p ) ( e ) ;
167+ expect ( e . stopPropagation ) . toHaveBeenCalled ( ) ;
168+ expect ( p . addPlantProps . dispatch ) . not . toHaveBeenCalled ( ) ;
169+ } ) ;
133170} ) ;
134171
135172describe ( "soilPointerMove()" , ( ) => {
0 commit comments