-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.js
54 lines (46 loc) · 1.71 KB
/
test.js
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
var assert = require('assert');
var parseCoords = require('./');
describe('parse-coordinates', function () {
it('should parse a coordinate pair seperated by a comma and space', function () {
var latLng = parseCoords('-80.21, 21.32');
assert.strictEqual(latLng.length,2);
assert.strictEqual(latLng[0], -80.21);
assert.strictEqual(latLng[1], 21.32);
})
it('should tolerate space on the outside of the numbers', function () {
var latLng = parseCoords(' -80.21, 21.32 ');
assert.strictEqual(latLng.length, 2);
assert.strictEqual(latLng[0], -80.21);
assert.strictEqual(latLng[1], 21.32);
})
it('should tolerate no space between numbers', function () {
var latLng = parseCoords(' -80.21,21.32 ');
assert.strictEqual(latLng.length, 2);
assert.strictEqual(latLng[0], -80.21);
assert.strictEqual(latLng[1], 21.32);
})
it('should not parse 3 numbers', function () {
var latLng = parseCoords('1,2,3');
assert.strictEqual(latLng, null);
})
it('should not parse one number' , function () {
var latLng = parseCoords('42');
assert.strictEqual(latLng, null);
})
it('should return null when given "abc, def"', function () {
var latLng = parseCoords('abc, def');
assert.strictEqual(latLng, null);
})
it("should return null when given 'BOOM'", function () {
assert.strictEqual(parseCoords("BOOM"),null);
})
it("should return null when given null", function () {
assert.strictEqual(parseCoords(null),null);
});
it("should return null when given undefined", function () {
assert.strictEqual(parseCoords(undefined),null);
});
it("should return null when given empty string", function () {
assert.strictEqual(parseCoords(''),null);
});
})