@@ -3,11 +3,13 @@ import { expect, test, describe, beforeEach } from 'vitest';
3
3
import Map from 'ol/Map' ;
4
4
import Editor from './editor' ;
5
5
import CAD from './control/cad' ;
6
+ import ModifyControl from './control/modify' ;
6
7
7
8
describe ( 'editor' , ( ) => {
8
9
let map ;
9
10
let editor ;
10
11
let cad ;
12
+ let modify ;
11
13
12
14
beforeEach ( ( ) => {
13
15
// In the test we use pixel as coordinates.
@@ -16,6 +18,7 @@ describe('editor', () => {
16
18
} ) ;
17
19
editor = new Editor ( map ) ;
18
20
cad = new CAD ( ) ;
21
+ modify = new ModifyControl ( ) ;
19
22
} ) ;
20
23
21
24
test ( 'adds a control' , ( ) => {
@@ -46,14 +49,20 @@ describe('editor', () => {
46
49
} ) ;
47
50
48
51
test ( 'is removed' , ( ) => {
52
+ editor . addControl ( modify ) ;
49
53
editor . addControl ( cad ) ;
50
- cad . activate ( ) ;
51
- expect ( cad . getActive ( ) ) . toBe ( true ) ;
52
- expect ( editor . controls . getArray ( ) [ 0 ] ) . toBe ( cad ) ;
53
- expect ( editor . activeControls . getArray ( ) [ 0 ] ) . toBe ( cad ) ;
54
+ modify . activate ( ) ;
55
+ expect ( modify . getActive ( ) ) . toBe ( true ) ;
56
+ expect ( editor . controls . getArray ( ) [ 0 ] ) . toBe ( modify ) ;
57
+ expect ( editor . controls . getArray ( ) [ 1 ] ) . toBe ( cad ) ;
58
+ expect ( editor . activeControls . getArray ( ) [ 0 ] ) . toBe ( modify ) ;
59
+ expect ( editor . activeControls . getArray ( ) [ 0 ] ) . toBe ( modify ) ;
54
60
editor . remove ( ) ;
55
61
expect ( editor . controls . getLength ( ) ) . toBe ( 0 ) ;
56
62
expect ( editor . activeControls . getLength ( ) ) . toBe ( 0 ) ;
63
+ expect ( modify . map ) . toBe ( ) ;
64
+ expect ( modify . editor ) . toBe ( ) ;
65
+ expect ( modify . getActive ( ) ) . toBe ( false ) ;
57
66
expect ( cad . map ) . toBe ( ) ;
58
67
expect ( cad . editor ) . toBe ( ) ;
59
68
expect ( cad . getActive ( ) ) . toBe ( false ) ;
0 commit comments