This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
self-important-test-data.js
76 lines (70 loc) · 1.78 KB
/
self-important-test-data.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Subject under test
function isGpsWithinLocation (gps, location) {
var boundaries = boundariesForZip(location.zip)
return boundaries.northWest.lat >= gps.lat &&
boundaries.southEast.lat <= gps.lat &&
boundaries.northEast.lng >= gps.lng &&
boundaries.southWest.lng <= gps.lng
}
// Test
module.exports = {
gpsInsideLocation: function () {
var gps = {
altitude: 3000,
course: 3.62,
horizontalAccuracy: 10,
lat: 43,
lng: -77,
secondsSinceLastUpdate: 4,
speed: 3,
utcOfLastFix: 180145,
verticalAccuracy: 15
}
var location = {
name: 'Cup O Joe',
streetLine1: '8312 Mulberry St',
streetLine2: 'Lot #326 c/o very detailed test data',
city: 'Grandview Heights',
state: 'OH',
stateFullName: 'Ohio',
zip: 43221,
zipPlus4: 8312
}
var result = isGpsWithinLocation(gps, location)
assert.equal(result, true)
},
gpsNotInsideLocation: function () {
var gps = {
altitude: 4000,
course: 14.18,
horizontalAccuracy: 5,
lat: 48,
lng: -77,
secondsSinceLastUpdate: 2,
speed: 1,
utcOfLastFix: 141445,
verticalAccuracy: 25
}
var location = {
name: 'J.F.K Elementary School',
streetLine1: '1438 Soledad St',
streetLine2: null,
city: 'Columbus',
state: 'OH',
stateFullName: 'Ohio',
zip: 43221,
zipPlus4: 4294
}
var result = isGpsWithinLocation(gps, location)
assert.equal(result, false)
}
}
// Fake production implementations to simplify example test of subject
function boundariesForZip (zip) {
return {
northWest: {lat: 45, lng: -80},
southWest: {lat: 40, lng: -80},
southEast: {lat: 40, lng: -75},
northEast: {lat: 45, lng: -75}
}
}