Skip to content

Commit ca9200b

Browse files
committed
improve test - include all show* and test using react calls
1 parent 9448c8f commit ca9200b

File tree

1 file changed

+88
-50
lines changed

1 file changed

+88
-50
lines changed

test/jasmine/tests/geo_test.js

Lines changed: 88 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -740,56 +740,6 @@ describe('Test Geo layout defaults', function() {
740740
});
741741
});
742742
});
743-
744-
describe([
745-
'geo.visible should honor template.layout.geo.show* defaults',
746-
'when template.layout.geo.visible is set to false,',
747-
'and does NOT set layout.geo.visible template'
748-
].join(' '), function() {
749-
var keys = [
750-
'lonaxis.showgrid',
751-
'lataxis.showgrid',
752-
'showcoastlines',
753-
'showocean',
754-
'showland',
755-
'showlakes',
756-
'showrivers',
757-
'showcountries',
758-
'showsubunits',
759-
'showframe'
760-
];
761-
762-
function _assert(extra) {
763-
var geo = layoutOut.geo;
764-
keys.forEach(function(k) {
765-
var actual = Lib.nestedProperty(geo, k).get();
766-
if(extra && k in extra) {
767-
expect(actual).toBe(extra[k], k);
768-
} else {
769-
expect(actual).toBe(false, k);
770-
}
771-
});
772-
}
773-
774-
it('- disable geo.visible via template', function() {
775-
layoutIn = {
776-
template: {
777-
layout: {
778-
geo: {
779-
visible: false
780-
}
781-
}
782-
}
783-
};
784-
785-
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
786-
_assert({
787-
showcoastlines: true,
788-
showframe: true,
789-
showsubunits: undefined
790-
});
791-
});
792-
});
793743
});
794744

795745
describe('geojson / topojson utils', function() {
@@ -1670,6 +1620,94 @@ describe('Test geo interactions', function() {
16701620
.then(done);
16711621
});
16721622

1623+
it([
1624+
'geo.visible should honor template.layout.geo.show* defaults',
1625+
'when template.layout.geo.visible is set to false,',
1626+
'and does NOT set layout.geo.visible template'
1627+
].join(' '), function(done) {
1628+
var gd = createGraphDiv();
1629+
1630+
Plotly.react(gd, [{
1631+
type: 'scattergeo',
1632+
lat: [0],
1633+
lon: [0],
1634+
marker: { size: 100 }
1635+
}], {
1636+
template: {
1637+
layout: {
1638+
geo: {
1639+
visible: false,
1640+
showcoastlines: true,
1641+
showcountries: true,
1642+
showframe: true,
1643+
showland: true,
1644+
showlakes: true,
1645+
showocean: true,
1646+
showrivers: true,
1647+
showsubunits: true,
1648+
lonaxis: { showgrid: true },
1649+
lataxis: { showgrid: true }
1650+
}
1651+
}
1652+
},
1653+
geo: {}
1654+
})
1655+
.then(function() {
1656+
expect(gd._fullLayout.geo.showcoastlines).toBe(true);
1657+
expect(gd._fullLayout.geo.showcountries).toBe(true);
1658+
expect(gd._fullLayout.geo.showframe).toBe(true);
1659+
expect(gd._fullLayout.geo.showland).toBe(true);
1660+
expect(gd._fullLayout.geo.showlakes).toBe(true);
1661+
expect(gd._fullLayout.geo.showocean).toBe(true);
1662+
expect(gd._fullLayout.geo.showrivers).toBe(true);
1663+
expect(gd._fullLayout.geo.showsubunits).toBe(undefined);
1664+
expect(gd._fullLayout.geo.lonaxis.showgrid).toBe(true);
1665+
expect(gd._fullLayout.geo.lataxis.showgrid).toBe(true);
1666+
})
1667+
.then(function() {
1668+
return Plotly.react(gd, [{
1669+
type: 'scattergeo',
1670+
lat: [0],
1671+
lon: [0],
1672+
marker: {size: 100}
1673+
}], {
1674+
template: {
1675+
layout: {
1676+
geo: {
1677+
showcoastlines: true,
1678+
showcountries: true,
1679+
showframe: true,
1680+
showland: true,
1681+
showlakes: true,
1682+
showocean: true,
1683+
showrivers: true,
1684+
showsubunits: true,
1685+
lonaxis: { showgrid: true },
1686+
lataxis: { showgrid: true }
1687+
}
1688+
}
1689+
},
1690+
geo: {
1691+
visible: false
1692+
}
1693+
});
1694+
})
1695+
.then(function() {
1696+
expect(gd._fullLayout.geo.showcoastlines).toBe(false);
1697+
expect(gd._fullLayout.geo.showcountries).toBe(false);
1698+
expect(gd._fullLayout.geo.showframe).toBe(false);
1699+
expect(gd._fullLayout.geo.showland).toBe(false);
1700+
expect(gd._fullLayout.geo.showlakes).toBe(false);
1701+
expect(gd._fullLayout.geo.showocean).toBe(false);
1702+
expect(gd._fullLayout.geo.showrivers).toBe(false);
1703+
expect(gd._fullLayout.geo.showsubunits).toBe(undefined);
1704+
expect(gd._fullLayout.geo.lonaxis.showgrid).toBe(false);
1705+
expect(gd._fullLayout.geo.lataxis.showgrid).toBe(false);
1706+
})
1707+
.catch(failTest)
1708+
.then(done);
1709+
});
1710+
16731711
describe('should not make request for topojson when not needed', function() {
16741712
var gd;
16751713

0 commit comments

Comments
 (0)