Skip to content

Commit 2d4d965

Browse files
committed
Add additional tests
1 parent f1967b1 commit 2d4d965

5 files changed

Lines changed: 83 additions & 30 deletions

File tree

lib/parser/to_geojson.ts

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {
44
Feature,
55
Polygon,
66
FeaturePropertyMission,
7+
FeaturePropertyMissionChange,
78
FeaturePropertyMissionLayer,
89
} from '../types/feature.js';
910
import type {
@@ -219,31 +220,40 @@ export async function to_geojson(cot: CoT): Promise<Static<typeof Feature>> {
219220

220221
mission.missionChanges = []
221222
for (const change of changes) {
222-
mission.missionChanges.push({
223-
contentUid: change.MissionChange.contentUid?._text,
224-
creatorUid: change.MissionChange.creatorUid?._text,
223+
const mc: Static<typeof FeaturePropertyMissionChange> = {
224+
contentUid: change.MissionChange.contentUid ? change.MissionChange.contentUid._text : undefined,
225+
creatorUid: change.MissionChange.creatorUid._text,
225226
isFederatedChange: change.MissionChange.isFederatedChange._text,
226227
missionName: change.MissionChange.missionName._text,
227228
timestamp: change.MissionChange.timestamp._text,
228229
type: change.MissionChange.type._text,
229-
contentResource: change.MissionChange.contentResource ? {
230-
expiration: change.MissionChange.contentResource.expiration._text,
231-
filename: change.MissionChange.contentResource.filename._text,
232-
hash: change.MissionChange.contentResource.hash._text,
233-
name: change.MissionChange.contentResource.name._text,
234-
size: change.MissionChange.contentResource.size._text,
235-
submissionTime: change.MissionChange.contentResource.submissionTime._text,
236-
submitter: change.MissionChange.contentResource.submitter._text,
237-
tool: change.MissionChange.contentResource.tool._text,
238-
uid: change.MissionChange.contentResource.uid._text,
239-
} : undefined,
240-
details: change.MissionChange.details ? {
230+
};
231+
232+
if (change.MissionChange.contentResource) {
233+
const cr = change.MissionChange.contentResource;
234+
mc.contentResource = {
235+
expiration: cr.expiration._text,
236+
filename: cr.filename._text,
237+
hash: cr.hash._text,
238+
name: cr.name._text,
239+
size: parseInt(cr.size._text),
240+
submissionTime: cr.submissionTime._text,
241+
submitter: cr.submitter._text,
242+
tool: cr.tool._text,
243+
uid: cr.uid._text,
244+
};
245+
}
246+
247+
if (change.MissionChange.details) {
248+
mc.details = {
241249
...change.MissionChange.details._attributes,
242250
...change.MissionChange.details.location
243251
? change.MissionChange.details.location._attributes
244252
: {}
245-
} : undefined
246-
})
253+
};
254+
}
255+
256+
mission.missionChanges.push(mc)
247257
}
248258
}
249259

lib/types/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ export const MissionChange = Type.Object({
344344
creatorUid: GenericOptionalText,
345345
isFederatedChange: GenericTextBoolean,
346346
missionName: GenericText,
347+
missionGuid: Type.Optional(GenericText),
347348
timestamp: GenericText,
348349
type: GenericText,
349350
contentResource: Type.Optional(MissionChangeContentResource),

package-lock.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"xml-js": "^1.6.11"
5454
},
5555
"devDependencies": {
56+
"@eslint/js": "^10.0.1",
5657
"@types/node": "^25.0.0",
5758
"@types/tape": "^5.6.0",
5859
"c8": "^10.1.3",

test/taskings-mission.test.ts

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ test('Decode MissionChange ContentResource', async (t) => {
154154
"_attributes": {
155155
"ce": "9999999",
156156
"le": "9999999",
157-
"hae": "0",
158-
"lat": "0",
159-
"lon": "0"
157+
"hae": 0,
158+
"lat": 0,
159+
"lon": 0
160160
}
161161
},
162162
"detail": {
@@ -184,7 +184,7 @@ test('Decode MissionChange ContentResource', async (t) => {
184184
"_text": "images.jpeg"
185185
},
186186
"size": {
187-
"_text": "9420"
187+
"_text": 9420
188188
},
189189
"submissionTime": {
190190
"_text": "2026-02-19T20:48:29.725Z"
@@ -203,7 +203,7 @@ test('Decode MissionChange ContentResource', async (t) => {
203203
"_text": "nicholas.ingalls@state.co.us"
204204
},
205205
"isFederatedChange": {
206-
"_text": "false"
206+
"_text": false
207207
},
208208
"missionGuid": {
209209
"_text": "cd4cfc53-621a-4dd9-81f8-8f87a3867bf2"
@@ -228,23 +228,42 @@ test('Decode MissionChange ContentResource', async (t) => {
228228
t.fail('No Detail Section')
229229
} else {
230230
t.deepEquals({
231-
id: 'e77c55da-c5d2-4200-bbc9-9967b3f30b5b',
231+
id: '6e244207-3f63-43a5-8da4-0ff470b23859',
232232
type: 'Feature',
233233
path: '/',
234234
properties: {
235235
callsign: 'UNKNOWN',
236236
center: [ 0, 0, 0 ],
237-
type: 't-x-m-c-l',
237+
type: 't-x-m-c',
238238
how: 'h-g-i-g-o',
239-
time: '2024-10-14T15:33:04Z',
240-
start: '2024-10-14T15:33:04Z',
241-
stale: '2024-10-14T15:33:24Z',
239+
time: '2026-02-19T22:39:15Z',
240+
start: '2026-02-19T22:39:15Z',
241+
stale: '2026-02-19T22:39:35Z',
242242
mission: {
243243
type: 'CHANGE',
244244
tool: 'public',
245-
name: 'manual test',
246-
guid: 'ae2e9ec4-2762-4664-8660-1ef824bde9bc',
247-
authorUid: 'ANDROID-0ca41830e11d2ef3',
245+
name: 'Test Attachments',
246+
guid: 'cd4cfc53-621a-4dd9-81f8-8f87a3867bf2',
247+
authorUid: 'nicholas.ingalls@state.co.us',
248+
missionChanges: [{
249+
contentUid: undefined,
250+
creatorUid: 'nicholas.ingalls@state.co.us',
251+
isFederatedChange: false,
252+
missionName: 'Test Attachments',
253+
timestamp: '2026-02-19T22:39:15.446Z',
254+
type: 'ADD_CONTENT',
255+
contentResource: {
256+
expiration: '-1',
257+
filename: 'images.jpeg',
258+
hash: 'ce8a1eedf818cb3be12646177779820ed1d71c95ac558a70fde07b483979512a',
259+
name: 'images.jpeg',
260+
size: 9420,
261+
submissionTime: '2026-02-19T20:48:29.725Z',
262+
submitter: 'nicholas.ingalls@state.co.us',
263+
tool: 'public',
264+
uid: 'add1e84f-6025-4cf5-a7c3-b9087309216c',
265+
},
266+
}]
248267
},
249268
metadata: {}
250269
},

0 commit comments

Comments
 (0)