Skip to content

Commit

Permalink
change attribution and logo tests so that they use `getEffectiveWidth…
Browse files Browse the repository at this point in the history
…` stubs on map
  • Loading branch information
Arindam Bose committed Aug 21, 2019
1 parent cd8edda commit 4b105fc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/ui/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,8 @@ export type MapEvent =
| 'style.load'

/**
* Fired when any of the `padding` parameters on the map are changing.
* Fired when any of the `padding` parameters on the map are changing
* as a result of a transition.
*
* @event padding
* @memberof Map
Expand Down
8 changes: 4 additions & 4 deletions test/unit/ui/control/attribution.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test('AttributionControl appears in the position specified by the position optio

test('AttributionControl appears in compact mode if compact option is used', (t) => {
const map = createMap(t);
Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 700, configurable: true});
const stub = t.stub(map, 'getEffectiveWidth').returns(700);

let attributionControl = new AttributionControl({
compact: true
Expand All @@ -49,7 +49,7 @@ test('AttributionControl appears in compact mode if compact option is used', (t)
t.equal(container.querySelectorAll('.mapboxgl-ctrl-attrib.mapboxgl-compact').length, 1);
map.removeControl(attributionControl);

Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 600, configurable: true});
stub.returns(600);
attributionControl = new AttributionControl({
compact: false
});
Expand All @@ -61,14 +61,14 @@ test('AttributionControl appears in compact mode if compact option is used', (t)

test('AttributionControl appears in compact mode if container is less then 640 pixel wide', (t) => {
const map = createMap(t);
Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 700, configurable: true});
const stub = t.stub(map, 'getEffectiveWidth').returns(700);
map.addControl(new AttributionControl());

const container = map.getContainer();

t.equal(container.querySelectorAll('.mapboxgl-ctrl-attrib:not(.mapboxgl-compact)').length, 1);

Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 600, configurable: true});
stub.returns(600);
map.resize();

t.equal(container.querySelectorAll('.mapboxgl-ctrl-attrib.mapboxgl-compact').length, 1);
Expand Down
4 changes: 2 additions & 2 deletions test/unit/ui/control/logo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ test('LogoControl appears in compact mode if container is less then 250 pixel wi
const map = createMap(t);
const container = map.getContainer();

Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 255, configurable: true});
const stub = t.stub(map, 'getEffectiveWidth').returns(255);
map.resize();
t.equal(container.querySelectorAll('.mapboxgl-ctrl-logo:not(.mapboxgl-compact)').length, 1);

Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 245, configurable: true});
stub.returns(245);
map.resize();
t.equal(container.querySelectorAll('.mapboxgl-ctrl-logo.mapboxgl-compact').length, 1);

Expand Down

0 comments on commit 4b105fc

Please sign in to comment.