-
Notifications
You must be signed in to change notification settings - Fork 138
Expand file tree
/
Copy pathparsePathsTest.js
More file actions
73 lines (58 loc) · 2 KB
/
Copy pathparsePathsTest.js
File metadata and controls
73 lines (58 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
var should = require('should');
var parsePaths = require('../../../lib/utils/parsePaths');
describe('parsePaths', function() {
describe('failures', function() {
var invalidPaths = [null, undefined, false, 0, NaN, '', {}, new Object, new Date, function() {}];
var calls = invalidPaths.map(
function(invalid) {
return function() {
it('should not accept ' + invalid + ' as paths', function() {
(function() { parsePaths( invalid ) }).should.throw('paths must be an array');
});
}
}
);
calls.forEach( function(checkCall){
checkCall();
});
it ('should not accept a marker without points', function() {
var input = [
{
color: '0x0000ff',
weight: 5
}
];
(function() { parsePaths(input).should.throw('Each path must have an array of points') });
});
});
describe('success', function() {
it('should transform an array of paths into a string', function() {
var input = [
{
points: [
'40.737102,-73.990318',
'40.749825,-73.987963',
'40.752946,-73.987384',
'40.755823,-73.986397'
],
color: '0x0000ff',
weight: 5
},
{
color: '0x00000000',
weight: 5,
fillcolor: '0xFFFF0033',
points: [
'8th+Avenue+%26+34th+St,New+York,NY',
'8th+Avenue+%26+42nd+St,New+York,NY',
'Park+Ave+%26+42nd+St,New+York,NY,NY',
'Park+Ave+%26+34th+St,New+York,NY,NY'
]
}
];
var output = "weight:5|color:0x0000ff|40.737102,-73.990318|40.749825,-73.987963|40.752946,-73.987384|40.755823,-73.986397|weight:5|color:0x00000000|fillcolor:0xFFFF0033|8th+Avenue+%26+34th+St,New+York,NY|8th+Avenue+%26+42nd+St,New+York,NY|Park+Ave+%26+42nd+St,New+York,NY,NY|Park+Ave+%26+34th+St,New+York,NY,NY";
var result = parsePaths(input);
result.should.equal(output);
});
});
});