@@ -37,7 +37,7 @@ test('AttributionControl appears in the position specified by the position optio
37
37
38
38
test ( 'AttributionControl appears in compact mode if compact option is used' , ( t ) => {
39
39
const map = createMap ( t ) ;
40
- Object . defineProperty ( map . getCanvasContainer ( ) , 'offsetWidth' , { value : 700 , configurable : true } ) ;
40
+ const stub = t . stub ( map , 'getEffectiveWidth' ) . returns ( 700 ) ;
41
41
42
42
let attributionControl = new AttributionControl ( {
43
43
compact : true
@@ -49,7 +49,7 @@ test('AttributionControl appears in compact mode if compact option is used', (t)
49
49
t . equal ( container . querySelectorAll ( '.mapboxgl-ctrl-attrib.mapboxgl-compact' ) . length , 1 ) ;
50
50
map . removeControl ( attributionControl ) ;
51
51
52
- Object . defineProperty ( map . getCanvasContainer ( ) , 'offsetWidth' , { value : 600 , configurable : true } ) ;
52
+ stub . returns ( 600 ) ;
53
53
attributionControl = new AttributionControl ( {
54
54
compact : false
55
55
} ) ;
@@ -61,14 +61,14 @@ test('AttributionControl appears in compact mode if compact option is used', (t)
61
61
62
62
test ( 'AttributionControl appears in compact mode if container is less then 640 pixel wide' , ( t ) => {
63
63
const map = createMap ( t ) ;
64
- Object . defineProperty ( map . getCanvasContainer ( ) , 'offsetWidth' , { value : 700 , configurable : true } ) ;
64
+ const stub = t . stub ( map , 'getEffectiveWidth' ) . returns ( 700 ) ;
65
65
map . addControl ( new AttributionControl ( ) ) ;
66
66
67
67
const container = map . getContainer ( ) ;
68
68
69
69
t . equal ( container . querySelectorAll ( '.mapboxgl-ctrl-attrib:not(.mapboxgl-compact)' ) . length , 1 ) ;
70
70
71
- Object . defineProperty ( map . getCanvasContainer ( ) , 'offsetWidth' , { value : 600 , configurable : true } ) ;
71
+ stub . returns ( 600 ) ;
72
72
map . resize ( ) ;
73
73
74
74
t . equal ( container . querySelectorAll ( '.mapboxgl-ctrl-attrib.mapboxgl-compact' ) . length , 1 ) ;
0 commit comments