Skip to content

Commit 64cbf2f

Browse files
committed
flatten scattegeo_test.js
1 parent a705ed1 commit 64cbf2f

File tree

1 file changed

+66
-54
lines changed

1 file changed

+66
-54
lines changed

test/jasmine/tests/scattergeo_test.js

Lines changed: 66 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,85 @@
11
var ScatterGeo = require('@src/traces/scattergeo');
22

3-
describe('Test scattergeo', function() {
4-
'use strict';
53

6-
describe('supplyDefaults', function() {
7-
var traceIn,
8-
traceOut;
4+
describe('Test scattergeo defaults', function() {
5+
var traceIn,
6+
traceOut;
97

10-
var defaultColor = '#444',
11-
layout = {};
8+
var defaultColor = '#444',
9+
layout = {};
1210

13-
beforeEach(function() {
14-
traceOut = {};
15-
});
11+
beforeEach(function() {
12+
traceOut = {};
13+
});
14+
15+
it('should slice lat if it it longer than lon', function() {
16+
traceIn = {
17+
lon: [-75],
18+
lat: [45, 45, 45]
19+
};
1620

17-
it('should slice lat if it it longer than lon', function() {
18-
traceIn = {
19-
lon: [-75],
20-
lat: [45, 45, 45]
21-
};
21+
ScatterGeo.supplyDefaults(traceIn, traceOut, defaultColor, layout);
22+
expect(traceOut.lat).toEqual([45]);
23+
expect(traceOut.lon).toEqual([-75]);
24+
});
25+
26+
it('should slice lon if it it longer than lat', function() {
27+
traceIn = {
28+
lon: [-75, -75, -75],
29+
lat: [45]
30+
};
2231

32+
ScatterGeo.supplyDefaults(traceIn, traceOut, defaultColor, layout);
33+
expect(traceOut.lat).toEqual([45]);
34+
expect(traceOut.lon).toEqual([-75]);
35+
});
36+
37+
it('should not coerce lat and lon if locations is valid', function() {
38+
traceIn = {
39+
locations: ['CAN', 'USA'],
40+
lon: [20, 40],
41+
lat: [20, 40]
42+
};
43+
44+
ScatterGeo.supplyDefaults(traceIn, traceOut, defaultColor, layout);
45+
expect(traceOut.lon).toBeUndefined();
46+
expect(traceOut.lat).toBeUndefined();
47+
});
48+
49+
it('should make trace invisible if lon or lat is omitted and locations not given', function() {
50+
function testOne() {
2351
ScatterGeo.supplyDefaults(traceIn, traceOut, defaultColor, layout);
24-
expect(traceOut.lat).toEqual([45]);
25-
expect(traceOut.lon).toEqual([-75]);
52+
expect(traceOut.visible).toBe(false);
53+
}
54+
55+
traceIn = {
56+
lat: [45, 45, 45]
57+
};
58+
testOne();
59+
60+
traceIn = {
61+
lon: [-75, -75, -75]
62+
};
63+
traceOut = {};
64+
testOne();
65+
66+
traceIn = {};
67+
traceOut = {};
68+
testOne();
69+
});
70+
});
71+
2672
});
2773

28-
it('should slice lon if it it longer than lat', function() {
29-
traceIn = {
30-
lon: [-75, -75, -75],
31-
lat: [45]
32-
};
3374

34-
ScatterGeo.supplyDefaults(traceIn, traceOut, defaultColor, layout);
35-
expect(traceOut.lat).toEqual([45]);
36-
expect(traceOut.lon).toEqual([-75]);
3775
});
3876

39-
it('should not coerce lat and lon if locations is valid', function() {
40-
traceIn = {
41-
locations: ['CAN', 'USA'],
42-
lon: [20, 40],
43-
lat: [20, 40]
44-
};
4577

46-
ScatterGeo.supplyDefaults(traceIn, traceOut, defaultColor, layout);
47-
expect(traceOut.lon).toBeUndefined();
48-
expect(traceOut.lat).toBeUndefined();
4978
});
5079

51-
it('should make trace invisible if lon or lat is omitted and locations not given', function() {
52-
function testOne() {
53-
ScatterGeo.supplyDefaults(traceIn, traceOut, defaultColor, layout);
54-
expect(traceOut.visible).toBe(false);
55-
}
56-
57-
traceIn = {
58-
lat: [45, 45, 45]
59-
};
60-
testOne();
61-
62-
traceIn = {
63-
lon: [-75, -75, -75]
64-
};
65-
traceOut = {};
66-
testOne();
67-
68-
traceIn = {};
69-
traceOut = {};
70-
testOne();
80+
81+
82+
7183
});
7284
});
7385

0 commit comments

Comments
 (0)