@tak-ps/node-cot 12.17.1 → 12.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/lib/cot.js +1 -1
- package/dist/lib/cot.js.map +1 -1
- package/dist/lib/data-package.js +64 -16
- package/dist/lib/data-package.js.map +1 -1
- package/dist/lib/types/feature.js +3 -9
- package/dist/lib/types/feature.js.map +1 -1
- package/dist/lib/types/iconset.js +12 -4
- package/dist/lib/types/iconset.js.map +1 -1
- package/dist/lib/types/types.js +7 -6
- package/dist/lib/types/types.js.map +1 -1
- package/dist/lib/xml/basemap.js +1 -1
- package/dist/lib/xml/basemap.js.map +1 -1
- package/dist/lib/xml/iconset.js +29 -2
- package/dist/lib/xml/iconset.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/cot.ts +1 -1
- package/lib/data-package.ts +70 -17
- package/lib/types/feature.ts +3 -8
- package/lib/types/iconset.ts +14 -4
- package/lib/types/types.ts +8 -6
- package/lib/xml/basemap.ts +2 -2
- package/lib/xml/iconset.ts +36 -3
- package/lib/xml-document.ts +1 -1
- package/package.json +1 -1
- package/tsconfig.json +1 -0
- package/dist/test/basemaps.test.js +0 -16
- package/dist/test/basemaps.test.js.map +0 -1
- package/dist/test/chat.test.js +0 -97
- package/dist/test/chat.test.js.map +0 -1
- package/dist/test/cot-fileshare.test.js +0 -89
- package/dist/test/cot-fileshare.test.js.map +0 -1
- package/dist/test/cot-itak.test.js +0 -95
- package/dist/test/cot-itak.test.js.map +0 -1
- package/dist/test/cot-mma.test.js +0 -108
- package/dist/test/cot-mma.test.js.map +0 -1
- package/dist/test/cot-polyline.test.js +0 -98
- package/dist/test/cot-polyline.test.js.map +0 -1
- package/dist/test/cot-range-and-bearing.test.js +0 -98
- package/dist/test/cot-range-and-bearing.test.js.map +0 -1
- package/dist/test/cot-routes.test.js +0 -466
- package/dist/test/cot-routes.test.js.map +0 -1
- package/dist/test/cot-types.test.js +0 -7
- package/dist/test/cot-types.test.js.map +0 -1
- package/dist/test/cot-uas-tool.test.js +0 -286
- package/dist/test/cot-uas-tool.test.js.map +0 -1
- package/dist/test/cot-video.test.js +0 -196
- package/dist/test/cot-video.test.js.map +0 -1
- package/dist/test/cot_is.test.js +0 -353
- package/dist/test/cot_is.test.js.map +0 -1
- package/dist/test/data-package.test.js +0 -234
- package/dist/test/data-package.test.js.map +0 -1
- package/dist/test/diff.test.js +0 -73
- package/dist/test/diff.test.js.map +0 -1
- package/dist/test/flow-tags.test.js +0 -19
- package/dist/test/flow-tags.test.js.map +0 -1
- package/dist/test/force-delete.js +0 -46
- package/dist/test/force-delete.js.map +0 -1
- package/dist/test/from_geojson.test.js +0 -287
- package/dist/test/from_geojson.test.js.map +0 -1
- package/dist/test/newlines.test.js +0 -79
- package/dist/test/newlines.test.js.map +0 -1
- package/dist/test/reversal-geojson.test.js +0 -15
- package/dist/test/reversal-geojson.test.js.map +0 -1
- package/dist/test/reversal-proto.test.js +0 -54
- package/dist/test/reversal-proto.test.js.map +0 -1
- package/dist/test/stream.js +0 -10
- package/dist/test/stream.js.map +0 -1
- package/dist/test/taskings-mission.test.js +0 -140
- package/dist/test/taskings-mission.test.js.map +0 -1
- package/dist/test/util.test.js +0 -25
- package/dist/test/util.test.js.map +0 -1
- package/dist/test/validation.test.js +0 -13
- package/dist/test/validation.test.js.map +0 -1
- package/test/basemaps/Bing_Hybrid.xml +0 -12
- package/test/basemaps/Bing_Maps.xml +0 -10
- package/test/basemaps/USGSBasemap.xml +0 -10
- package/test/basemaps/USGSImageryOnly.xml +0 -10
- package/test/basemaps/USGSImageryTopo.xml +0 -10
- package/test/basemaps/USGSShadedRelief.xml +0 -10
- package/test/basemaps/opentopomap.xml +0 -10
- package/test/basemaps.test.ts +0 -19
- package/test/chat.test.ts +0 -103
- package/test/cot-fileshare.test.ts +0 -92
- package/test/cot-itak.test.ts +0 -100
- package/test/cot-mma.test.ts +0 -111
- package/test/cot-polyline.test.ts +0 -103
- package/test/cot-range-and-bearing.test.ts +0 -100
- package/test/cot-routes.test.ts +0 -468
- package/test/cot-types.test.ts +0 -8
- package/test/cot-uas-tool.test.ts +0 -295
- package/test/cot-video.test.ts +0 -204
- package/test/cot_is.test.ts +0 -431
- package/test/data-package.test.ts +0 -314
- package/test/diff.test.ts +0 -80
- package/test/fixtures/archived.geojson +0 -20
- package/test/fixtures/attachments.geojson +0 -20
- package/test/fixtures/basic.geojson +0 -19
- package/test/fixtures/circle.geojson +0 -30
- package/test/fixtures/color.geojson +0 -21
- package/test/fixtures/fileshare.geojson +0 -28
- package/test/fixtures/geofence.geojson +0 -25
- package/test/fixtures/hae.geojson +0 -19
- package/test/fixtures/icon.geojson +0 -20
- package/test/fixtures/linestring.geojson +0 -28
- package/test/fixtures/marti-mission.geojson +0 -22
- package/test/fixtures/metadata.geojson +0 -24
- package/test/fixtures/mission-layer.geojson +0 -31
- package/test/fixtures/mission.geojson +0 -25
- package/test/fixtures/polygon.geojson +0 -33
- package/test/fixtures/props.geojson +0 -22
- package/test/fixtures/sensor.geojson +0 -31
- package/test/fixtures/video-connection.geojson +0 -27
- package/test/fixtures/video.geojson +0 -24
- package/test/flow-tags.test.ts +0 -21
- package/test/force-delete.ts +0 -50
- package/test/from_geojson.test.ts +0 -323
- package/test/newlines.test.ts +0 -83
- package/test/packages/AttachmentInManifest.zip +0 -0
- package/test/packages/COMilePosts.zip +0 -0
- package/test/packages/CameraCOTs.zip +0 -0
- package/test/packages/QuickPic.zip +0 -0
- package/test/reversal-geojson.test.ts +0 -19
- package/test/reversal-proto.test.ts +0 -60
- package/test/stream.ts +0 -10
- package/test/taskings-mission.test.ts +0 -148
- package/test/util.test.ts +0 -34
- package/test/validation.test.ts +0 -13
|
Binary file
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Static } from '@sinclair/typebox';
|
|
2
|
-
import type { Feature } from '../lib/types/feature.js';
|
|
3
|
-
import fs from 'node:fs/promises';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import test from 'tape';
|
|
6
|
-
import CoT from '../index.js';
|
|
7
|
-
import { fileURLToPath } from 'node:url';
|
|
8
|
-
|
|
9
|
-
for (const fixturename of await fs.readdir(new URL('./fixtures/', import.meta.url))) {
|
|
10
|
-
test(`GeoJSON Reversal Tests: ${fixturename}`, async (t) => {
|
|
11
|
-
const fixture: Static<typeof Feature> = JSON.parse(String(await fs.readFile(path.join(path.parse(fileURLToPath(import.meta.url)).dir, 'fixtures/', fixturename))));
|
|
12
|
-
const geo = CoT.from_geojson(fixture)
|
|
13
|
-
const output = geo.to_geojson();
|
|
14
|
-
|
|
15
|
-
t.deepEquals(fixture, output, fixturename);
|
|
16
|
-
|
|
17
|
-
t.end();
|
|
18
|
-
});
|
|
19
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { Static } from '@sinclair/typebox';
|
|
2
|
-
import type { Feature } from '../lib/types/feature.js';
|
|
3
|
-
import fs from 'node:fs/promises';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import test from 'tape';
|
|
6
|
-
import CoT from '../index.js';
|
|
7
|
-
import { fileURLToPath } from 'node:url';
|
|
8
|
-
|
|
9
|
-
for (const fixturename of await fs.readdir(new URL('./fixtures/', import.meta.url))) {
|
|
10
|
-
test(`Protobuf Reversal Tests: ${fixturename}`, async (t) => {
|
|
11
|
-
const fixture: Static<typeof Feature> = JSON.parse(String(await fs.readFile(path.join(path.parse(fileURLToPath(import.meta.url)).dir, 'fixtures/', fixturename))));
|
|
12
|
-
const geo = CoT.from_geojson(fixture)
|
|
13
|
-
const intermediate = geo.to_proto();
|
|
14
|
-
const output = CoT.from_proto(intermediate);
|
|
15
|
-
t.deepEquals(fixture, output.to_geojson(), fixturename);
|
|
16
|
-
|
|
17
|
-
t.end();
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Ref: https://github.com/dfpc-coe/node-CoT/issues/55
|
|
22
|
-
test('Protobuf Multiple Calls', (t) => {
|
|
23
|
-
const cot = new CoT({
|
|
24
|
-
event: {
|
|
25
|
-
_attributes: {
|
|
26
|
-
version: '2.0',
|
|
27
|
-
uid: 'ebbf42a7-ea71-43a1-baf6-e259c3d115bf',
|
|
28
|
-
type: 'u-rb-a',
|
|
29
|
-
how: 'h-e',
|
|
30
|
-
time: '2024-08-30T22:28:02Z',
|
|
31
|
-
start: '2024-08-30T22:28:02Z',
|
|
32
|
-
stale: '2024-08-31T22:28:02Z',
|
|
33
|
-
access: 'Undefined',
|
|
34
|
-
},
|
|
35
|
-
point: {
|
|
36
|
-
_attributes: {
|
|
37
|
-
lat: '39.0981196',
|
|
38
|
-
lon: '-108.7395013',
|
|
39
|
-
hae: '0.0',
|
|
40
|
-
ce: '9999999.0',
|
|
41
|
-
le: '9999999.0',
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
detail: {
|
|
45
|
-
contact: {
|
|
46
|
-
_attributes: {
|
|
47
|
-
callsign: 'sign',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
const cot2 = CoT.from_proto(cot.to_proto())
|
|
55
|
-
t.deepEqual(cot2.raw.event.detail?.contact?._attributes.callsign, 'sign')
|
|
56
|
-
const cot3 = CoT.from_proto(cot.to_proto())
|
|
57
|
-
t.deepEqual(cot3.raw.event.detail?.contact?._attributes.callsign, 'sign')
|
|
58
|
-
|
|
59
|
-
t.end();
|
|
60
|
-
});
|
package/test/stream.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Stream } from 'node:stream';
|
|
2
|
-
|
|
3
|
-
export default async function stream2buffer(stream: Stream): Promise<Buffer> {
|
|
4
|
-
return new Promise<Buffer>((resolve, reject) => {
|
|
5
|
-
const _buf = Array<Buffer>();
|
|
6
|
-
stream.on("data", chunk => _buf.push(chunk));
|
|
7
|
-
stream.on("end", () => resolve(Buffer.concat(_buf)));
|
|
8
|
-
stream.on("error", (err: Error) => reject(`error converting stream - ${err}`));
|
|
9
|
-
});
|
|
10
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import test from 'tape';
|
|
2
|
-
import CoT from '../index.js';
|
|
3
|
-
|
|
4
|
-
test('Decode MissionChange CoTs', (t) => {
|
|
5
|
-
const cot = new CoT({"event":{"_attributes":{"how":"h-g-i-g-o","type":"t-x-m-c","version":"2.0","uid":"f205227b-2e23-40bf-8948-711566116365","start":"2024-07-17T18:49:03Z","time":"2024-07-17T18:49:03Z","stale":"2024-07-17T18:49:23Z"},"point":{"_attributes":{"ce":"9999999","le":"9999999","hae":"0","lat":"0","lon":"0"}},"detail":{"mission":{"_attributes":{"type":"CHANGE","tool":"public","name":"2024-07-17 - Lost Hiker","guid":"4ce8e41d-21e4-4471-a303-09d12bb93bcf","authorUid":"CN=mesasar-machine-user@ingalls.ca,OU=WILDFIRE,O=CO-TAK"},"MissionChanges": {"MissionChange":{"contentUid":{"_text":"layer-11-27529-1"},"creatorUid":{"_text":"CN=mma-etl-user@cotak.gov,OU=WILDFIRE,O=CO-TAK"},"isFederatedChange":{"_text":"false"},"missionName":{"_text":"Colorado NIFS Fire Perimeters"},"timestamp":{"_text":"2024-08-16T15:21:55.361Z"},"type":{"_text":"ADD_CONTENT"},"details":{"_attributes":{"type":"t-x-d-d"}}}}}}}});
|
|
6
|
-
|
|
7
|
-
if (!cot.raw.event.detail) {
|
|
8
|
-
t.fail('No Detail Section')
|
|
9
|
-
} else {
|
|
10
|
-
t.ok(cot.raw.event.detail['_flow-tags_']);
|
|
11
|
-
delete cot.raw.event.detail['_flow-tags_'];
|
|
12
|
-
|
|
13
|
-
t.deepEquals({
|
|
14
|
-
id: 'f205227b-2e23-40bf-8948-711566116365',
|
|
15
|
-
type: 'Feature',
|
|
16
|
-
path: '/',
|
|
17
|
-
properties: {
|
|
18
|
-
callsign: 'UNKNOWN',
|
|
19
|
-
center: [ 0, 0, 0 ],
|
|
20
|
-
type: 't-x-m-c',
|
|
21
|
-
how: 'h-g-i-g-o',
|
|
22
|
-
time: '2024-07-17T18:49:03Z',
|
|
23
|
-
start: '2024-07-17T18:49:03Z',
|
|
24
|
-
stale: '2024-07-17T18:49:23Z',
|
|
25
|
-
mission: {
|
|
26
|
-
type: 'CHANGE',
|
|
27
|
-
tool: 'public',
|
|
28
|
-
name: '2024-07-17 - Lost Hiker',
|
|
29
|
-
guid: '4ce8e41d-21e4-4471-a303-09d12bb93bcf',
|
|
30
|
-
authorUid: 'CN=mesasar-machine-user@ingalls.ca,OU=WILDFIRE,O=CO-TAK',
|
|
31
|
-
missionChanges: [{
|
|
32
|
-
contentUid: 'layer-11-27529-1',
|
|
33
|
-
creatorUid: 'CN=mma-etl-user@cotak.gov,OU=WILDFIRE,O=CO-TAK',
|
|
34
|
-
isFederatedChange: 'false',
|
|
35
|
-
missionName: 'Colorado NIFS Fire Perimeters',
|
|
36
|
-
timestamp: '2024-08-16T15:21:55.361Z',
|
|
37
|
-
type: 'ADD_CONTENT',
|
|
38
|
-
details: {
|
|
39
|
-
type: 't-x-d-d',
|
|
40
|
-
}
|
|
41
|
-
}]
|
|
42
|
-
},
|
|
43
|
-
metadata: {}
|
|
44
|
-
},
|
|
45
|
-
geometry: {
|
|
46
|
-
type: 'Point',
|
|
47
|
-
coordinates: [ 0, 0, 0 ]
|
|
48
|
-
}
|
|
49
|
-
}, cot.to_geojson());
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
t.end();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test('Decode MissionChange CoTs - #2', (t) => {
|
|
56
|
-
const cot = new CoT({"event":{"_attributes":{"how":"h-g-i-g-o","type":"t-x-m-c","version":"2.0","uid":"f205227b-2e23-40bf-8948-711566116365","start":"2024-07-17T18:49:03Z","time":"2024-07-17T18:49:03Z","stale":"2024-07-17T18:49:23Z"},"point":{"_attributes":{"ce":"9999999","le":"9999999","hae":"0","lat":"0","lon":"0"}},"detail":{"mission":{"_attributes":{"type":"CHANGE","tool":"public","name":"2024-07-17 - Lost Hiker","guid":"4ce8e41d-21e4-4471-a303-09d12bb93bcf","authorUid":"CN=mesasar-machine-user@ingalls.ca,OU=WILDFIRE,O=CO-TAK"},"MissionChanges":{"MissionChange":{"contentUid":{"_text":"8fb7b41f-77c5-4537-9a4c-5b7a76a71cb9"},"creatorUid":{"_text":"CN=mesasar-machine-user@ingalls.ca,OU=WILDFIRE,O=CO-TAK"},"isFederatedChange":{"_text":"false"},"missionName":{"_text":"2024-07-17 - Lost Hiker"},"timestamp":{"_text":"2024-07-17T18:49:03.606Z"},"type":{"_text":"ADD_CONTENT"},"details":{"_attributes":{"type":"u-d-p","callsign":"Third Test","color":"-65536"},"location":{"_attributes":{"lat":"39.118611111111115","lon":"-108.31361111111111"}}}}}}}}});
|
|
57
|
-
|
|
58
|
-
if (!cot.raw.event.detail) {
|
|
59
|
-
t.fail('No Detail Section')
|
|
60
|
-
} else {
|
|
61
|
-
t.ok(cot.raw.event.detail['_flow-tags_']);
|
|
62
|
-
delete cot.raw.event.detail['_flow-tags_'];
|
|
63
|
-
|
|
64
|
-
t.deepEquals({
|
|
65
|
-
id: 'f205227b-2e23-40bf-8948-711566116365',
|
|
66
|
-
type: 'Feature',
|
|
67
|
-
path: '/',
|
|
68
|
-
properties: {
|
|
69
|
-
callsign: 'UNKNOWN',
|
|
70
|
-
center: [ 0, 0, 0 ],
|
|
71
|
-
type: 't-x-m-c',
|
|
72
|
-
how: 'h-g-i-g-o',
|
|
73
|
-
time: '2024-07-17T18:49:03Z',
|
|
74
|
-
start: '2024-07-17T18:49:03Z',
|
|
75
|
-
stale: '2024-07-17T18:49:23Z',
|
|
76
|
-
mission: {
|
|
77
|
-
type: 'CHANGE',
|
|
78
|
-
tool: 'public',
|
|
79
|
-
name: '2024-07-17 - Lost Hiker',
|
|
80
|
-
guid: '4ce8e41d-21e4-4471-a303-09d12bb93bcf',
|
|
81
|
-
authorUid: 'CN=mesasar-machine-user@ingalls.ca,OU=WILDFIRE,O=CO-TAK',
|
|
82
|
-
missionChanges: [{
|
|
83
|
-
contentUid: '8fb7b41f-77c5-4537-9a4c-5b7a76a71cb9',
|
|
84
|
-
creatorUid: 'CN=mesasar-machine-user@ingalls.ca,OU=WILDFIRE,O=CO-TAK',
|
|
85
|
-
isFederatedChange: 'false',
|
|
86
|
-
missionName: '2024-07-17 - Lost Hiker',
|
|
87
|
-
timestamp: '2024-07-17T18:49:03.606Z',
|
|
88
|
-
type: 'ADD_CONTENT',
|
|
89
|
-
details: {
|
|
90
|
-
type: 'u-d-p',
|
|
91
|
-
callsign: 'Third Test',
|
|
92
|
-
color: '-65536',
|
|
93
|
-
lat: '39.118611111111115',
|
|
94
|
-
lon: '-108.31361111111111'
|
|
95
|
-
}
|
|
96
|
-
}]
|
|
97
|
-
},
|
|
98
|
-
metadata: {}
|
|
99
|
-
},
|
|
100
|
-
geometry: {
|
|
101
|
-
type: 'Point',
|
|
102
|
-
coordinates: [ 0, 0, 0 ]
|
|
103
|
-
}
|
|
104
|
-
}, cot.to_geojson());
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
t.end();
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
test('Decode MissionChange Logs', (t) => {
|
|
111
|
-
const cot = new CoT({"event":{"_attributes":{"how":"h-g-i-g-o","type":"t-x-m-c-l","version":"2.0","uid":"e77c55da-c5d2-4200-bbc9-9967b3f30b5b","start":"2024-10-14T15:33:04Z","time":"2024-10-14T15:33:04Z","stale":"2024-10-14T15:33:24Z"},"point":{"_attributes":{"ce":"9999999","le":"9999999","hae":"0","lat":"0","lon":"0"}},"detail":{"mission":{"_attributes":{"type":"CHANGE","tool":"public","name":"manual test","guid":"ae2e9ec4-2762-4664-8660-1ef824bde9bc","authorUid":"ANDROID-0ca41830e11d2ef3"}}}}});
|
|
112
|
-
|
|
113
|
-
if (!cot.raw.event.detail) {
|
|
114
|
-
t.fail('No Detail Section')
|
|
115
|
-
} else {
|
|
116
|
-
t.ok(cot.raw.event.detail['_flow-tags_']);
|
|
117
|
-
delete cot.raw.event.detail['_flow-tags_'];
|
|
118
|
-
|
|
119
|
-
t.deepEquals({
|
|
120
|
-
id: 'e77c55da-c5d2-4200-bbc9-9967b3f30b5b',
|
|
121
|
-
type: 'Feature',
|
|
122
|
-
path: '/',
|
|
123
|
-
properties: {
|
|
124
|
-
callsign: 'UNKNOWN',
|
|
125
|
-
center: [ 0, 0, 0 ],
|
|
126
|
-
type: 't-x-m-c-l',
|
|
127
|
-
how: 'h-g-i-g-o',
|
|
128
|
-
time: '2024-10-14T15:33:04Z',
|
|
129
|
-
start: '2024-10-14T15:33:04Z',
|
|
130
|
-
stale: '2024-10-14T15:33:24Z',
|
|
131
|
-
mission: {
|
|
132
|
-
type: 'CHANGE',
|
|
133
|
-
tool: 'public',
|
|
134
|
-
name: 'manual test',
|
|
135
|
-
guid: 'ae2e9ec4-2762-4664-8660-1ef824bde9bc',
|
|
136
|
-
authorUid: 'ANDROID-0ca41830e11d2ef3',
|
|
137
|
-
},
|
|
138
|
-
metadata: {}
|
|
139
|
-
},
|
|
140
|
-
geometry: {
|
|
141
|
-
type: 'Point',
|
|
142
|
-
coordinates: [ 0, 0, 0 ]
|
|
143
|
-
}
|
|
144
|
-
}, cot.to_geojson());
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
t.end();
|
|
148
|
-
});
|
package/test/util.test.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import test from 'tape';
|
|
2
|
-
import Util from '../lib/utils/util.js';
|
|
3
|
-
|
|
4
|
-
test('Util.cot_date - default', (t) => {
|
|
5
|
-
const res = Util.cot_date();
|
|
6
|
-
|
|
7
|
-
// Within 100ms of current time
|
|
8
|
-
t.ok(+new Date(res.time) > +new Date() - 100, 'res.time within 100ms of current time');
|
|
9
|
-
|
|
10
|
-
// res.start is the same as res.time
|
|
11
|
-
t.equals(+new Date(res.start), +new Date(res.time), 'by default res.start === res.time');
|
|
12
|
-
|
|
13
|
-
// Approx 20s ahead of start
|
|
14
|
-
t.ok(+new Date(res.stale) > +new Date(res.start) + 20 * 1000 - 100);
|
|
15
|
-
t.ok(+new Date(res.stale) < +new Date(res.start) + 20 * 1000 + 100);
|
|
16
|
-
|
|
17
|
-
t.end();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('Util.cot_date - stale', (t) => {
|
|
21
|
-
const res = Util.cot_date(null, null, 1000);
|
|
22
|
-
|
|
23
|
-
// Within 100ms of current time
|
|
24
|
-
t.ok(+new Date(res.time) > +new Date() - 100, 'res.time within 100ms of current time');
|
|
25
|
-
|
|
26
|
-
// res.start is the same as res.time
|
|
27
|
-
t.equals(+new Date(res.start), +new Date(res.time), 'by default res.start === res.time');
|
|
28
|
-
|
|
29
|
-
// Approx 1s ahead of start
|
|
30
|
-
t.ok(+new Date(res.stale) > +new Date(res.start) + 1 * 1000 - 100);
|
|
31
|
-
t.ok(+new Date(res.stale) < +new Date(res.start) + 1 * 1000 + 100);
|
|
32
|
-
|
|
33
|
-
t.end();
|
|
34
|
-
});
|
package/test/validation.test.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import test from 'tape';
|
|
2
|
-
import CoT from '../index.js';
|
|
3
|
-
|
|
4
|
-
test('CoT.from_geojson - Point', (t) => {
|
|
5
|
-
try {
|
|
6
|
-
new CoT({ event: { _attributes: {} } });
|
|
7
|
-
t.fail();
|
|
8
|
-
} catch (err) {
|
|
9
|
-
t.ok(String(err).includes('must have required property'));
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
t.end();
|
|
13
|
-
});
|