tabletcommand-backend-models 7.0.13 → 7.0.14
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/build/constants.js +8 -1
- package/build/constants.js.map +1 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/models/department.js +5 -0
- package/build/models/department.js.map +1 -1
- package/build/models/device-mapping.js +4 -0
- package/build/models/device-mapping.js.map +1 -1
- package/build/models/schema/cad-incident.js +1 -1
- package/build/models/schema/cad-incident.js.map +1 -1
- package/build/test/0index.js +72 -0
- package/build/test/0index.js.map +1 -0
- package/build/test/action-log.js +40 -0
- package/build/test/action-log.js.map +1 -0
- package/build/test/agency.js +41 -0
- package/build/test/agency.js.map +1 -0
- package/build/test/arcgis-group.js +48 -85
- package/build/test/arcgis-group.js.map +1 -1
- package/build/test/assignment.js +39 -0
- package/build/test/assignment.js.map +1 -0
- package/build/test/battalion.js +45 -0
- package/build/test/battalion.js.map +1 -0
- package/build/test/cad-incident-block.js +43 -0
- package/build/test/cad-incident-block.js.map +1 -0
- package/build/test/cad-incident.js +159 -0
- package/build/test/cad-incident.js.map +1 -0
- package/build/test/cad-simulation.js +32 -0
- package/build/test/cad-simulation.js.map +1 -0
- package/build/test/cad-status-map.js +41 -0
- package/build/test/cad-status-map.js.map +1 -0
- package/build/test/cad-status.js +57 -0
- package/build/test/cad-status.js.map +1 -0
- package/build/test/cad-vehicle-status-history.js +36 -0
- package/build/test/cad-vehicle-status-history.js.map +1 -0
- package/build/test/cad-vehicle-status.js +42 -0
- package/build/test/cad-vehicle-status.js.map +1 -0
- package/build/test/cad-vehicle.js +38 -0
- package/build/test/cad-vehicle.js.map +1 -0
- package/build/test/checklist-item.js +42 -0
- package/build/test/checklist-item.js.map +1 -0
- package/build/test/checklist.js +43 -0
- package/build/test/checklist.js.map +1 -0
- package/build/test/config.js +2 -1
- package/build/test/config.js.map +1 -1
- package/build/test/csv-import.js +44 -0
- package/build/test/csv-import.js.map +1 -0
- package/build/test/department.js +99 -0
- package/build/test/department.js.map +1 -0
- package/build/test/device-mapping.js +51 -0
- package/build/test/device-mapping.js.map +1 -0
- package/build/test/esri.js +67 -0
- package/build/test/esri.js.map +1 -0
- package/build/test/gst-mapping.js +37 -0
- package/build/test/gst-mapping.js.map +1 -0
- package/build/test/helpers.js +14 -0
- package/build/test/helpers.js.map +1 -0
- package/build/test/incident-event.js +52 -0
- package/build/test/incident-event.js.map +1 -0
- package/build/test/incident-notified.js +42 -0
- package/build/test/incident-notified.js.map +1 -0
- package/build/test/incident-takeover.js +38 -0
- package/build/test/incident-takeover.js.map +1 -0
- package/build/test/job-log.js +36 -0
- package/build/test/job-log.js.map +1 -0
- package/build/test/location.js +76 -0
- package/build/test/location.js.map +1 -0
- package/build/test/mail-log.js +52 -0
- package/build/test/mail-log.js.map +1 -0
- package/build/test/managed-incident.js +107 -0
- package/build/test/managed-incident.js.map +1 -0
- package/build/test/mark43-incident-retry.js +33 -0
- package/build/test/mark43-incident-retry.js.map +1 -0
- package/build/test/message.js +38 -0
- package/build/test/message.js.map +1 -0
- package/build/test/mock.js +1280 -910
- package/build/test/mock.js.map +1 -1
- package/build/test/monitor.js +34 -0
- package/build/test/monitor.js.map +1 -0
- package/build/test/personnel-import.js +55 -0
- package/build/test/personnel-import.js.map +1 -0
- package/build/test/rate-limit.js +32 -0
- package/build/test/rate-limit.js.map +1 -0
- package/build/test/release-note.js +34 -0
- package/build/test/release-note.js.map +1 -0
- package/build/test/session.js +42 -0
- package/build/test/session.js.map +1 -0
- package/build/test/template.js +43 -0
- package/build/test/template.js.map +1 -0
- package/build/test/user-device.js +69 -0
- package/build/test/user-device.js.map +1 -0
- package/build/test/user-registration.js +44 -0
- package/build/test/user-registration.js.map +1 -0
- package/build/test/user.js +51 -0
- package/build/test/user.js.map +1 -0
- package/build/test/validation-report.js +33 -0
- package/build/test/validation-report.js.map +1 -0
- package/cspell.json +11 -8
- package/definitions/constants.d.ts +6 -0
- package/definitions/constants.d.ts.map +1 -1
- package/definitions/index.d.ts +2 -2
- package/definitions/index.d.ts.map +1 -1
- package/definitions/models/department.d.ts.map +1 -1
- package/definitions/models/device-mapping.d.ts.map +1 -1
- package/definitions/test/0index.d.ts +2 -0
- package/definitions/test/0index.d.ts.map +1 -0
- package/definitions/test/action-log.d.ts +2 -0
- package/definitions/test/action-log.d.ts.map +1 -0
- package/definitions/test/agency.d.ts +2 -0
- package/definitions/test/agency.d.ts.map +1 -0
- package/definitions/test/arcgis-group.d.ts.map +1 -1
- package/definitions/test/assignment.d.ts +2 -0
- package/definitions/test/assignment.d.ts.map +1 -0
- package/definitions/test/battalion.d.ts +2 -0
- package/definitions/test/battalion.d.ts.map +1 -0
- package/definitions/test/cad-incident-block.d.ts +2 -0
- package/definitions/test/cad-incident-block.d.ts.map +1 -0
- package/definitions/test/cad-incident.d.ts +2 -0
- package/definitions/test/cad-incident.d.ts.map +1 -0
- package/definitions/test/cad-simulation.d.ts +2 -0
- package/definitions/test/cad-simulation.d.ts.map +1 -0
- package/definitions/test/cad-status-map.d.ts +2 -0
- package/definitions/test/cad-status-map.d.ts.map +1 -0
- package/definitions/test/cad-status.d.ts +2 -0
- package/definitions/test/cad-status.d.ts.map +1 -0
- package/definitions/test/cad-vehicle-status-history.d.ts +2 -0
- package/definitions/test/cad-vehicle-status-history.d.ts.map +1 -0
- package/definitions/test/cad-vehicle-status.d.ts +2 -0
- package/definitions/test/cad-vehicle-status.d.ts.map +1 -0
- package/definitions/test/cad-vehicle.d.ts +2 -0
- package/definitions/test/cad-vehicle.d.ts.map +1 -0
- package/definitions/test/checklist-item.d.ts +2 -0
- package/definitions/test/checklist-item.d.ts.map +1 -0
- package/definitions/test/checklist.d.ts +2 -0
- package/definitions/test/checklist.d.ts.map +1 -0
- package/definitions/test/config.d.ts.map +1 -1
- package/definitions/test/csv-import.d.ts +2 -0
- package/definitions/test/csv-import.d.ts.map +1 -0
- package/definitions/test/department.d.ts +2 -0
- package/definitions/test/department.d.ts.map +1 -0
- package/definitions/test/device-mapping.d.ts +2 -0
- package/definitions/test/device-mapping.d.ts.map +1 -0
- package/definitions/test/esri.d.ts +2 -0
- package/definitions/test/esri.d.ts.map +1 -0
- package/definitions/test/gst-mapping.d.ts +2 -0
- package/definitions/test/gst-mapping.d.ts.map +1 -0
- package/definitions/test/helpers.d.ts +2 -0
- package/definitions/test/helpers.d.ts.map +1 -0
- package/definitions/test/incident-event.d.ts +2 -0
- package/definitions/test/incident-event.d.ts.map +1 -0
- package/definitions/test/incident-notified.d.ts +2 -0
- package/definitions/test/incident-notified.d.ts.map +1 -0
- package/definitions/test/incident-takeover.d.ts +2 -0
- package/definitions/test/incident-takeover.d.ts.map +1 -0
- package/definitions/test/job-log.d.ts +2 -0
- package/definitions/test/job-log.d.ts.map +1 -0
- package/definitions/test/location.d.ts +2 -0
- package/definitions/test/location.d.ts.map +1 -0
- package/definitions/test/mail-log.d.ts +2 -0
- package/definitions/test/mail-log.d.ts.map +1 -0
- package/definitions/test/managed-incident.d.ts +2 -0
- package/definitions/test/managed-incident.d.ts.map +1 -0
- package/definitions/test/mark43-incident-retry.d.ts +2 -0
- package/definitions/test/mark43-incident-retry.d.ts.map +1 -0
- package/definitions/test/message.d.ts +2 -0
- package/definitions/test/message.d.ts.map +1 -0
- package/definitions/test/mock.d.ts +1056 -3
- package/definitions/test/mock.d.ts.map +1 -1
- package/definitions/test/monitor.d.ts +2 -0
- package/definitions/test/monitor.d.ts.map +1 -0
- package/definitions/test/personnel-import.d.ts +2 -0
- package/definitions/test/personnel-import.d.ts.map +1 -0
- package/definitions/test/rate-limit.d.ts +2 -0
- package/definitions/test/rate-limit.d.ts.map +1 -0
- package/definitions/test/release-note.d.ts +2 -0
- package/definitions/test/release-note.d.ts.map +1 -0
- package/definitions/test/session.d.ts +2 -0
- package/definitions/test/session.d.ts.map +1 -0
- package/definitions/test/template.d.ts +2 -0
- package/definitions/test/template.d.ts.map +1 -0
- package/definitions/test/user-device.d.ts +2 -0
- package/definitions/test/user-device.d.ts.map +1 -0
- package/definitions/test/user-registration.d.ts +2 -0
- package/definitions/test/user-registration.d.ts.map +1 -0
- package/definitions/test/user.d.ts +2 -0
- package/definitions/test/user.d.ts.map +1 -0
- package/definitions/test/validation-report.d.ts +2 -0
- package/definitions/test/validation-report.d.ts.map +1 -0
- package/definitions/types/cad.d.ts +2 -2
- package/definitions/types/cad.d.ts.map +1 -1
- package/definitions/types/department.d.ts +1 -0
- package/definitions/types/department.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/constants.ts +7 -0
- package/src/index.ts +2 -0
- package/src/models/department.ts +6 -0
- package/src/models/device-mapping.ts +4 -0
- package/src/test/0index.ts +71 -0
- package/src/test/action-log.ts +41 -0
- package/src/test/agency.ts +41 -0
- package/src/test/arcgis-group.ts +25 -63
- package/src/test/assignment.ts +41 -0
- package/src/test/battalion.ts +45 -0
- package/src/test/cad-incident-block.ts +44 -0
- package/src/test/cad-incident.ts +168 -0
- package/src/test/cad-simulation.ts +33 -0
- package/src/test/cad-status-map.ts +41 -0
- package/src/test/cad-status.ts +57 -0
- package/src/test/cad-vehicle-status-history.ts +37 -0
- package/src/test/cad-vehicle-status.ts +43 -0
- package/src/test/cad-vehicle.ts +38 -0
- package/src/test/checklist-item.ts +43 -0
- package/src/test/checklist.ts +44 -0
- package/src/test/config.ts +3 -3
- package/src/test/csv-import.ts +44 -0
- package/src/test/department.ts +95 -0
- package/src/test/device-mapping.ts +53 -0
- package/src/test/esri.ts +69 -0
- package/src/test/gst-mapping.ts +38 -0
- package/src/test/helpers.ts +15 -0
- package/src/test/incident-event.ts +53 -0
- package/src/test/incident-notified.ts +41 -0
- package/src/test/incident-takeover.ts +39 -0
- package/src/test/job-log.ts +37 -0
- package/src/test/location.ts +79 -0
- package/src/test/mail-log.ts +51 -0
- package/src/test/managed-incident.ts +116 -0
- package/src/test/mark43-incident-retry.ts +34 -0
- package/src/test/message.ts +39 -0
- package/src/test/mock.ts +590 -163
- package/src/test/monitor.ts +35 -0
- package/src/test/personnel-import.ts +55 -0
- package/src/test/rate-limit.ts +33 -0
- package/src/test/release-note.ts +36 -0
- package/src/test/session.ts +43 -0
- package/src/test/template.ts +44 -0
- package/src/test/user-device.ts +66 -0
- package/src/test/user-registration.ts +45 -0
- package/src/test/user.ts +51 -0
- package/src/test/validation-report.ts +33 -0
- package/src/tsconfig.json +13 -3
- package/src/types/cad.ts +2 -2
- package/src/types/department.ts +1 -0
- package/tslint.json +0 -28
- /package/{test → test-legacy}/0index.js +0 -0
- /package/{test → test-legacy}/action-log.js +0 -0
- /package/{test → test-legacy}/agency.js +0 -0
- /package/{test → test-legacy}/arcgis-group.js +0 -0
- /package/{test → test-legacy}/assignment.js +0 -0
- /package/{test → test-legacy}/battalion.js +0 -0
- /package/{test → test-legacy}/cad-incident-block.js +0 -0
- /package/{test → test-legacy}/cad-incident.js +0 -0
- /package/{test → test-legacy}/cad-simulation.js +0 -0
- /package/{test → test-legacy}/cad-status-map.js +0 -0
- /package/{test → test-legacy}/cad-status.js +0 -0
- /package/{test → test-legacy}/cad-vehicle-status-history.js +0 -0
- /package/{test → test-legacy}/cad-vehicle-status.js +0 -0
- /package/{test → test-legacy}/cad-vehicle.js +0 -0
- /package/{test → test-legacy}/checklist-item.js +0 -0
- /package/{test → test-legacy}/checklist.js +0 -0
- /package/{test → test-legacy}/config.js +0 -0
- /package/{test → test-legacy}/csv-import.js +0 -0
- /package/{test → test-legacy}/department.js +0 -0
- /package/{test → test-legacy}/device-mapping.js +0 -0
- /package/{test → test-legacy}/esri.js +0 -0
- /package/{test → test-legacy}/gst-mapping.js +0 -0
- /package/{test → test-legacy}/helpers.js +0 -0
- /package/{test → test-legacy}/incident-event.js +0 -0
- /package/{test → test-legacy}/incident-notified.js +0 -0
- /package/{test → test-legacy}/incident-takeover.js +0 -0
- /package/{test → test-legacy}/job-log.js +0 -0
- /package/{test → test-legacy}/location.js +0 -0
- /package/{test → test-legacy}/mail-log.js +0 -0
- /package/{test → test-legacy}/managed-incident.js +0 -0
- /package/{test → test-legacy}/mark43-incident-retry.js +0 -0
- /package/{test → test-legacy}/message.js +0 -0
- /package/{test → test-legacy}/mock.js +0 -0
- /package/{test → test-legacy}/monitor.js +0 -0
- /package/{test → test-legacy}/personnel-import.js +0 -0
- /package/{test → test-legacy}/rate-limit.js +0 -0
- /package/{test → test-legacy}/release-note.js +0 -0
- /package/{test → test-legacy}/session.js +0 -0
- /package/{test → test-legacy}/template.js +0 -0
- /package/{test → test-legacy}/user-device.js +0 -0
- /package/{test → test-legacy}/user-registration.js +0 -0
- /package/{test → test-legacy}/user.js +0 -0
- /package/{test → test-legacy}/validation-report.js +0 -0
@@ -0,0 +1,95 @@
|
|
1
|
+
import { assert } from "chai";
|
2
|
+
import "mocha";
|
3
|
+
import * as m from "../index";
|
4
|
+
import * as config from "./config";
|
5
|
+
import mockModule from "./mock";
|
6
|
+
|
7
|
+
describe("Department", function() {
|
8
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
9
|
+
let testItem: Partial<m.Department>;
|
10
|
+
beforeEach(async function() {
|
11
|
+
const c = await m.connect(config.url);
|
12
|
+
models = c.models;
|
13
|
+
mongoose = c.mongoose;
|
14
|
+
const mock = mockModule({
|
15
|
+
mongoose
|
16
|
+
});
|
17
|
+
testItem = mock.department;
|
18
|
+
});
|
19
|
+
|
20
|
+
afterEach(async function() {
|
21
|
+
await mongoose.disconnect();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("is saved", async function() {
|
25
|
+
assert.isObject(testItem);
|
26
|
+
const item = new models.Department(testItem);
|
27
|
+
const sut = await item.save();
|
28
|
+
await models.Department.findOne({ _id: testItem._id }).lean();
|
29
|
+
assert.isNotNull(sut._id);
|
30
|
+
assert.isNotNull(sut.id);
|
31
|
+
assert.equal(sut.department, testItem.department);
|
32
|
+
assert.equal(sut.addressDetails.city, testItem.addressDetails?.city);
|
33
|
+
assert.isTrue(sut.active);
|
34
|
+
assert.equal(sut.apikey, testItem.apikey);
|
35
|
+
assert.equal(sut.partialApiKey, testItem.partialApiKey);
|
36
|
+
assert.isTrue(sut.personnelStaffingEnabled);
|
37
|
+
assert.isTrue(sut.rtsEnabled);
|
38
|
+
assert.equal(sut.rtsChannelPrefix, testItem.rtsChannelPrefix);
|
39
|
+
assert.equal(sut.pubNubV3.token, testItem.pubNubV3?.token);
|
40
|
+
assert.equal(sut.pubNubV3.expireAt.toISOString(), testItem.pubNubV3?.expireAt.toISOString());
|
41
|
+
assert.equal(sut.pubNubV3.runAt.toISOString(), testItem.pubNubV3?.runAt.toISOString());
|
42
|
+
assert.equal(sut.signupKey, testItem.signupKey);
|
43
|
+
assert.equal(sut.incidentTypes.length, 1);
|
44
|
+
assert.equal(sut.agencyIds.length, 1);
|
45
|
+
if (testItem.agencyIds?.length) {
|
46
|
+
assert.equal(sut.agencyIds[0], testItem.agencyIds[0]);
|
47
|
+
} else {
|
48
|
+
assert.equal(testItem.agencyIds?.length, 1);
|
49
|
+
}
|
50
|
+
assert.equal(sut.safetyPriorityKeywords.length, 3);
|
51
|
+
if (testItem.incidentTypes?.length) {
|
52
|
+
assert.equal(sut.incidentTypes[0]?.name, testItem.incidentTypes[0]?.name);
|
53
|
+
} else {
|
54
|
+
assert.equal(testItem.incidentTypes?.length, 1);
|
55
|
+
}
|
56
|
+
assert.isFalse(sut.shareLocationPhones);
|
57
|
+
assert.isTrue(sut.shareLocationTablets);
|
58
|
+
assert.isFalse(sut.cadOneWayVehiclesEnabled);
|
59
|
+
assert.isFalse(sut.cadGetLocationEnabled);
|
60
|
+
assert.isTrue(sut.mowsEnabled);
|
61
|
+
assert.isTrue(sut.shareAVL.enabled);
|
62
|
+
assert.equal(sut.shareAVL.opAreaCode, testItem.shareAVL?.opAreaCode);
|
63
|
+
assert.equal(sut.shareAVL.opAreaName, testItem.shareAVL?.opAreaName);
|
64
|
+
assert.equal(sut.accountType, testItem.accountType);
|
65
|
+
assert.equal(sut.timeZone, testItem.timeZone);
|
66
|
+
assert.equal(sut.firstArrivingEnabled, testItem.firstArrivingEnabled);
|
67
|
+
assert.equal(sut.simpleSense.token, testItem.simpleSense?.token);
|
68
|
+
assert.equal(sut.firstArriving.token, testItem.firstArriving?.token);
|
69
|
+
assert.equal(sut.simpleSenseEnabled, testItem.simpleSenseEnabled);
|
70
|
+
assert.equal(sut.webDisclaimer.message, testItem.webDisclaimer?.message);
|
71
|
+
assert.equal(sut.webDisclaimer.enabled, testItem.webDisclaimer?.enabled);
|
72
|
+
assert.equal(JSON.stringify(sut.licensing), JSON.stringify(testItem.licensing));
|
73
|
+
assert.equal(sut.externalNotificationsEnabled, testItem.externalNotificationsEnabled);
|
74
|
+
assert.equal(sut.notificationEmails.length, testItem.notificationEmails?.length);
|
75
|
+
assert.equal(sut.restrictedComments.callTypesAllowed.length, testItem.restrictedComments?.callTypesAllowed.length);
|
76
|
+
assert.equal(sut.restrictedComments.statusesAllowed.length, testItem.restrictedComments?.statusesAllowed.length);
|
77
|
+
assert.equal(sut.restrictedComments.restrictedFields.length, testItem.restrictedComments?.restrictedFields.length);
|
78
|
+
assert.equal(sut.restrictedComments.restrictedMessage, testItem.restrictedComments?.restrictedMessage);
|
79
|
+
assert.equal(sut.restrictedComments.enabled, testItem.restrictedComments?.enabled);
|
80
|
+
if (testItem.customButtons?.length) {
|
81
|
+
assert.equal(sut.customButtons[0]?.name, testItem.customButtons[0]?.name);
|
82
|
+
assert.equal(sut.customButtons[0]?.url, testItem.customButtons[0]?.url);
|
83
|
+
assert.equal(sut.customButtons[0]?.order, testItem.customButtons[0]?.order);
|
84
|
+
assert.equal(sut.customButtons[0]?.allowExternal, testItem.customButtons[0]?.allowExternal);
|
85
|
+
assert.equal(sut.customButtons[0]?.defaultExternal, testItem.customButtons[0]?.defaultExternal);
|
86
|
+
assert.equal(sut.customButtons[0]?.allowFloating, testItem.customButtons[0]?.allowFloating);
|
87
|
+
assert.equal(JSON.stringify(sut.customButtons[0]?.color), JSON.stringify(testItem.customButtons[0]?.color));
|
88
|
+
} else {
|
89
|
+
assert.equal(testItem.customButtons?.length, 1);
|
90
|
+
}
|
91
|
+
assert.equal(sut.reportNumberEnabled, testItem.reportNumberEnabled);
|
92
|
+
assert.equal(JSON.stringify(sut.samsara), JSON.stringify(testItem.samsara));
|
93
|
+
assert.equal(sut.reportOdometer, "status");
|
94
|
+
});
|
95
|
+
});
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { assert } from "chai";
|
2
|
+
import "mocha";
|
3
|
+
import * as m from "../index";
|
4
|
+
import * as config from "./config";
|
5
|
+
import mockModule from "./mock";
|
6
|
+
|
7
|
+
describe("DeviceMapping", function() {
|
8
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
9
|
+
let testItem: Partial<m.DeviceMapping>, testItemForTrim: Partial<m.DeviceMapping>;
|
10
|
+
beforeEach(async function() {
|
11
|
+
const c = await m.connect(config.url);
|
12
|
+
models = c.models;
|
13
|
+
mongoose = c.mongoose;
|
14
|
+
|
15
|
+
const mock = mockModule({
|
16
|
+
mongoose
|
17
|
+
});
|
18
|
+
testItem = mock.deviceMapping;
|
19
|
+
testItemForTrim = mock.deviceMappingWithWhiteSpaces;
|
20
|
+
});
|
21
|
+
afterEach(async function() {
|
22
|
+
await mongoose.disconnect();
|
23
|
+
});
|
24
|
+
|
25
|
+
it("is saved", async function() {
|
26
|
+
const item = new models.DeviceMapping(testItem);
|
27
|
+
const sut = await item.save();
|
28
|
+
|
29
|
+
assert.isNotNull(testItem._id);
|
30
|
+
assert.equal(testItem.departmentId, sut.departmentId);
|
31
|
+
assert.equal(testItem.deviceType, sut.deviceType);
|
32
|
+
assert.equal(testItem.mapId, sut.mapId);
|
33
|
+
assert.equal(testItem.deviceId, sut.deviceId);
|
34
|
+
assert.equal(testItem.modified_unix_date, sut.modified_unix_date);
|
35
|
+
assert.equal(testItem.remoteAddress, sut.remoteAddress);
|
36
|
+
assert.equal(testItem.note, sut.note);
|
37
|
+
assert.isFalse(sut.active);
|
38
|
+
assert.isFalse(sut.mapHidden);
|
39
|
+
});
|
40
|
+
|
41
|
+
|
42
|
+
it("is saved with trim", async function() {
|
43
|
+
const item = new models.DeviceMapping(testItemForTrim);
|
44
|
+
const sut = await item.save();
|
45
|
+
assert.isNotNull(testItemForTrim._id);
|
46
|
+
assert.equal(testItemForTrim.departmentId, sut.departmentId);
|
47
|
+
assert.equal(testItemForTrim.modified_unix_date, sut.modified_unix_date);
|
48
|
+
assert.equal(testItemForTrim.mapId?.trim(), sut.mapId); // Should be trimmed by Schema
|
49
|
+
assert.equal(testItemForTrim.deviceId?.trim(), sut.deviceId); // Should be trimmed by Schema
|
50
|
+
assert.equal(testItemForTrim.remoteAddress?.trim(), sut.remoteAddress); // Should be trimmed by Schema
|
51
|
+
assert.equal(testItemForTrim.note?.trim(), sut.note); // Should be trimmed by Schema
|
52
|
+
});
|
53
|
+
});
|
package/src/test/esri.ts
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
import { assert } from "chai";
|
2
|
+
import "mocha";
|
3
|
+
import * as m from "../index";
|
4
|
+
import * as config from "./config";
|
5
|
+
import mockModule from "./mock";
|
6
|
+
describe("Esri", function() {
|
7
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
8
|
+
let testItem: Partial<m.Esri>;
|
9
|
+
beforeEach(async function() {
|
10
|
+
const c = await m.connect(config.url);
|
11
|
+
models = c.models;
|
12
|
+
mongoose = c.mongoose;
|
13
|
+
const mock = mockModule({
|
14
|
+
mongoose
|
15
|
+
});
|
16
|
+
testItem = mock.esri;
|
17
|
+
await mock.cleanup();
|
18
|
+
});
|
19
|
+
|
20
|
+
afterEach(async function() {
|
21
|
+
await mongoose.disconnect();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("is saved", async function() {
|
25
|
+
assert.isObject(testItem);
|
26
|
+
const item = new models.Esri(testItem);
|
27
|
+
const sut = await item.save();
|
28
|
+
assert.isNotNull(sut._id);
|
29
|
+
assert.isNotNull(sut.id);
|
30
|
+
assert.equal(sut._id.toString(), testItem._id?.toString());
|
31
|
+
assert.equal(sut.toJSON().id, testItem._id?.toString());
|
32
|
+
assert.equal(sut.departmentId, testItem.departmentId);
|
33
|
+
|
34
|
+
assert.equal(sut.auth.username, testItem.auth?.username);
|
35
|
+
assert.equal(sut.auth.encrypted.iv, testItem.auth?.encrypted.iv);
|
36
|
+
assert.equal(sut.auth.encrypted.encryptedData, testItem.auth?.encrypted.encryptedData);
|
37
|
+
|
38
|
+
assert.equal(sut.fireMapperAuth.username, testItem.fireMapperAuth?.username);
|
39
|
+
assert.equal(sut.fireMapperAuth.encrypted.iv, testItem.fireMapperAuth?.encrypted.iv);
|
40
|
+
assert.equal(sut.fireMapperAuth.encrypted.encryptedData, testItem.fireMapperAuth?.encrypted.encryptedData);
|
41
|
+
assert.equal(sut.fireMapperAuth.encryptedAccessCode.iv, testItem.fireMapperAuth?.encryptedAccessCode.iv);
|
42
|
+
assert.equal(sut.fireMapperAuth.encryptedAccessCode.encryptedData, testItem.fireMapperAuth?.encryptedAccessCode.encryptedData);
|
43
|
+
|
44
|
+
assert.equal(sut.maps.length, 1);
|
45
|
+
const sutm = sut.maps[0];
|
46
|
+
let testItemM;
|
47
|
+
if (testItem.maps?.length) {
|
48
|
+
testItemM = testItem.maps[0];
|
49
|
+
}
|
50
|
+
assert.equal(sutm?.itemId, testItemM?.itemId);
|
51
|
+
assert.equal(sutm?.title, testItemM?.title);
|
52
|
+
assert.equal(sutm?.url, testItemM?.url);
|
53
|
+
assert.equal(sutm?.access, testItemM?.access);
|
54
|
+
assert.equal(sutm?.owner, testItemM?.owner);
|
55
|
+
assert.equal(sutm?.type, testItemM?.type);
|
56
|
+
assert.equal(sutm?.mapLayers.length, 3);
|
57
|
+
assert.equal(sutm?.mapLayers.length, 3);
|
58
|
+
assert.equal(sutm?.baseMap.baseMapLayers.length, 1);
|
59
|
+
assert.equal(sutm?.baseMap.title, testItemM?.baseMap.title);
|
60
|
+
|
61
|
+
const itemId = "01cebf7aede94ed3a9f4c260e18a7d7e";
|
62
|
+
// compare saved items
|
63
|
+
assert.equal(sut.mapsProperties.length, 1, "all items");
|
64
|
+
const mapPropsFound = sut.mapsProperties.filter(p => { return p.itemId === itemId; });
|
65
|
+
assert.equal(mapPropsFound.length, 1, "found items");
|
66
|
+
const props = mapPropsFound[0];
|
67
|
+
assert.equal(props?.download, true);
|
68
|
+
});
|
69
|
+
});
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { assert } from "chai";
|
2
|
+
import "mocha";
|
3
|
+
import * as m from "../index";
|
4
|
+
import * as config from "./config";
|
5
|
+
import mockModule from "./mock";
|
6
|
+
|
7
|
+
describe("GSTMapping", function() {
|
8
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
9
|
+
let testItem: Partial<m.GSTMapping>;
|
10
|
+
beforeEach(async function() {
|
11
|
+
const c = await m.connect(config.url);
|
12
|
+
models = c.models;
|
13
|
+
mongoose = c.mongoose;
|
14
|
+
|
15
|
+
const mock = mockModule({
|
16
|
+
mongoose
|
17
|
+
});
|
18
|
+
testItem = mock.gstMapping;
|
19
|
+
});
|
20
|
+
afterEach(async function() {
|
21
|
+
await mongoose.disconnect();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("is saved", async function() {
|
25
|
+
const item = new models.GSTMapping(testItem);
|
26
|
+
const sut = await item.save();
|
27
|
+
|
28
|
+
assert.isNotNull(testItem._id);
|
29
|
+
assert.equal(testItem.departmentId, sut.departmentId);
|
30
|
+
assert.equal(testItem.deviceType, sut.deviceType);
|
31
|
+
assert.equal(testItem.unitId, sut.unitId);
|
32
|
+
assert.equal(testItem.modified_unix_date, sut.modified_unix_date);
|
33
|
+
assert.equal(testItem.remoteAddress, sut.remoteAddress);
|
34
|
+
assert.equal(testItem.note, sut.note);
|
35
|
+
assert.isFalse(sut.active);
|
36
|
+
assert.isFalse(sut.mapHidden);
|
37
|
+
});
|
38
|
+
});
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { assert } from "chai";
|
4
|
+
import "mocha";
|
5
|
+
import * as m from "../helpers";
|
6
|
+
|
7
|
+
describe("helpers", function() {
|
8
|
+
it("retrieveCurrentUnixTime", function() {
|
9
|
+
const item = m.retrieveCurrentUnixTime();
|
10
|
+
const expected = new Date().valueOf() / 1000.0;
|
11
|
+
|
12
|
+
const delta = Math.abs(expected - item);
|
13
|
+
assert.isTrue(delta < 1);
|
14
|
+
});
|
15
|
+
});
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { assert } from "chai";
|
2
|
+
import "mocha";
|
3
|
+
import * as m from "../index";
|
4
|
+
import * as config from "./config";
|
5
|
+
import mockModule from "./mock";
|
6
|
+
|
7
|
+
describe("IncidentEvent", function() {
|
8
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
9
|
+
let testItem: Partial<m.IncidentEvent>;
|
10
|
+
beforeEach(async function() {
|
11
|
+
const c = await m.connect(config.url);
|
12
|
+
models = c.models;
|
13
|
+
mongoose = c.mongoose;
|
14
|
+
|
15
|
+
const mock = mockModule({
|
16
|
+
mongoose
|
17
|
+
});
|
18
|
+
testItem = mock.incidentEvent;
|
19
|
+
await models.IncidentEvent.deleteMany({
|
20
|
+
departmentId: testItem.departmentId
|
21
|
+
});
|
22
|
+
});
|
23
|
+
afterEach(async function() {
|
24
|
+
await mongoose.disconnect();
|
25
|
+
});
|
26
|
+
|
27
|
+
it("is saved", async function() {
|
28
|
+
const item = new models.IncidentEvent(testItem);
|
29
|
+
const sut = await item.save();
|
30
|
+
|
31
|
+
assert.isNotNull(testItem._id);
|
32
|
+
assert.equal(testItem.departmentId, sut.departmentId);
|
33
|
+
assert.equal(testItem.IncidentNumber, sut.IncidentNumber);
|
34
|
+
assert.equal(testItem.modified_unix_date, sut.modified_unix_date);
|
35
|
+
assert.equal(testItem.message, sut.message);
|
36
|
+
assert.equal(testItem.userTime, sut.userTime);
|
37
|
+
assert.equal(testItem.type, sut.type);
|
38
|
+
assert.equal(testItem.uuid, sut.uuid);
|
39
|
+
assert.equal(testItem.location?.latitude, sut.location.latitude);
|
40
|
+
assert.equal(testItem.location?.longitude, sut.location.longitude);
|
41
|
+
assert.equal(testItem.user?.email, sut.user.email);
|
42
|
+
assert.equal(testItem.user?.username, sut.user.username);
|
43
|
+
assert.equal(testItem.user?.radioName, sut.user.radioName);
|
44
|
+
assert.equal(testItem.user?.userId, sut.user.userId);
|
45
|
+
|
46
|
+
const items = await models.IncidentEvent.find({
|
47
|
+
departmentId: item.departmentId
|
48
|
+
}).lean({
|
49
|
+
virtuals: true
|
50
|
+
});
|
51
|
+
assert.equal(items.length, 1);
|
52
|
+
});
|
53
|
+
});
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { assert } from "chai";
|
2
|
+
import "mocha";
|
3
|
+
import * as m from "../index";
|
4
|
+
import * as config from "./config";
|
5
|
+
import mockModule from "./mock";
|
6
|
+
|
7
|
+
describe("IncidentNotified", function() {
|
8
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
9
|
+
let testItem: Partial<m.IncidentNotified>;
|
10
|
+
beforeEach(async function() {
|
11
|
+
const c = await m.connect(config.url);
|
12
|
+
models = c.models;
|
13
|
+
mongoose = c.mongoose;
|
14
|
+
|
15
|
+
const mock = mockModule({
|
16
|
+
mongoose
|
17
|
+
});
|
18
|
+
testItem = mock.incidentNotified;
|
19
|
+
});
|
20
|
+
afterEach(async function() {
|
21
|
+
await mongoose.disconnect();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("is saved", async function() {
|
25
|
+
const item = new models.IncidentNotified(testItem);
|
26
|
+
const sut = await item.save();
|
27
|
+
|
28
|
+
assert.isNotNull(testItem._id);
|
29
|
+
assert.equal(testItem.departmentId, sut.departmentId);
|
30
|
+
assert.equal(testItem.IncidentNumber, sut.IncidentNumber);
|
31
|
+
assert.deepEqual(testItem.incidentTypes, sut.incidentTypes);
|
32
|
+
assert.deepEqual(testItem.units, sut.units);
|
33
|
+
if (testItem.unitsByDispatch?.length) {
|
34
|
+
assert.equal(testItem.unitsByDispatch[0]?.UnitID, sut.unitsByDispatch[0]?.UnitID);
|
35
|
+
assert.equal(testItem.unitsByDispatch[0]?.UnitDispatchNumber, sut.unitsByDispatch[0]?.UnitDispatchNumber);
|
36
|
+
} else {
|
37
|
+
assert.equal(testItem?.unitsByDispatch?.length, 1);
|
38
|
+
}
|
39
|
+
assert.equal(testItem.updated?.toISOString(), sut.updated.toISOString());
|
40
|
+
});
|
41
|
+
});
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { assert } from "chai";
|
2
|
+
import "mocha";
|
3
|
+
import * as m from "../index";
|
4
|
+
import * as config from "./config";
|
5
|
+
import mockModule from "./mock";
|
6
|
+
|
7
|
+
describe("IncidentTakeover", function() {
|
8
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
9
|
+
let testItem: Partial<m.IncidentTakeover>;
|
10
|
+
beforeEach(async function() {
|
11
|
+
const c = await m.connect(config.url);
|
12
|
+
models = c.models;
|
13
|
+
mongoose = c.mongoose;
|
14
|
+
|
15
|
+
const mock = mockModule({
|
16
|
+
mongoose
|
17
|
+
});
|
18
|
+
testItem = mock.incidentTakeover;
|
19
|
+
});
|
20
|
+
afterEach(async function() {
|
21
|
+
await mongoose.disconnect();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("is saved", async function() {
|
25
|
+
const item = new models.IncidentTakeover(testItem);
|
26
|
+
const sut = await item.save();
|
27
|
+
|
28
|
+
assert.isNotNull(testItem._id);
|
29
|
+
assert.equal(testItem.departmentId, sut.departmentId);
|
30
|
+
assert.equal(testItem.incident_id, sut.incident_id);
|
31
|
+
assert.equal(testItem.incident_name, sut.incident_name);
|
32
|
+
assert.equal(testItem.incident_number, sut.incident_number);
|
33
|
+
assert.equal(testItem.old_owner, sut.old_owner);
|
34
|
+
assert.equal(testItem.new_owner, sut.new_owner);
|
35
|
+
assert.equal(testItem.status, sut.status);
|
36
|
+
assert.equal(testItem.request_time, sut.request_time);
|
37
|
+
assert.isTrue(sut.uuid !== "");
|
38
|
+
});
|
39
|
+
});
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { assert } from "chai";
|
2
|
+
import "mocha";
|
3
|
+
import * as m from "../index";
|
4
|
+
import * as config from "./config";
|
5
|
+
import mockModule from "./mock";
|
6
|
+
|
7
|
+
describe("JobLog", function() {
|
8
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
9
|
+
let testItem: Partial<m.JobLog>;
|
10
|
+
beforeEach(async function() {
|
11
|
+
const c = await m.connect(config.url);
|
12
|
+
models = c.models;
|
13
|
+
mongoose = c.mongoose;
|
14
|
+
|
15
|
+
const mock = mockModule({
|
16
|
+
mongoose
|
17
|
+
});
|
18
|
+
testItem = mock.jobLog;
|
19
|
+
});
|
20
|
+
afterEach(async function() {
|
21
|
+
await mongoose.disconnect();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("is saved", async function() {
|
25
|
+
const item = new models.JobLog(testItem);
|
26
|
+
const sut = await item.save();
|
27
|
+
|
28
|
+
assert.isNotNull(testItem._id);
|
29
|
+
assert.equal(testItem.host, sut.host);
|
30
|
+
assert.equal(testItem.jobName, sut.jobName);
|
31
|
+
assert.equal(testItem.state, sut.state);
|
32
|
+
assert.equal(testItem.bidDate, sut.bidDate);
|
33
|
+
assert.equal(testItem.startDate, sut.startDate);
|
34
|
+
assert.equal(testItem.completedDate, sut.completedDate);
|
35
|
+
assert.equal(testItem.forceClosed, sut.forceClosed);
|
36
|
+
});
|
37
|
+
});
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import { assert } from "chai";
|
2
|
+
import "mocha";
|
3
|
+
import * as m from "../index";
|
4
|
+
import * as config from "./config";
|
5
|
+
import mockModule from "./mock";
|
6
|
+
|
7
|
+
describe("Location", function() {
|
8
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
9
|
+
let testItem: Partial<m.Location>;
|
10
|
+
beforeEach(async function() {
|
11
|
+
const c = await m.connect(config.url);
|
12
|
+
models = c.models;
|
13
|
+
mongoose = c.mongoose;
|
14
|
+
|
15
|
+
const mock = mockModule({
|
16
|
+
mongoose
|
17
|
+
});
|
18
|
+
testItem = mock.location;
|
19
|
+
});
|
20
|
+
afterEach(async function() {
|
21
|
+
await mongoose.disconnect();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("is saved", async function() {
|
25
|
+
const item = new models.Location(testItem);
|
26
|
+
const sut = await item.save();
|
27
|
+
await models.Location.findOne({ _id: testItem._id });
|
28
|
+
assert.isNotNull(testItem._id);
|
29
|
+
assert.equal(testItem.departmentId, sut.departmentId);
|
30
|
+
assert.equal(testItem.userId, sut.userId);
|
31
|
+
assert.equal(testItem.uuid, sut.uuid);
|
32
|
+
assert.equal(testItem.username, sut.username);
|
33
|
+
assert.equal(testItem.device_type, sut.device_type);
|
34
|
+
assert.equal(testItem.session, sut.session);
|
35
|
+
assert.equal(testItem.active, sut.active);
|
36
|
+
assert.equal(testItem.heading, sut.heading);
|
37
|
+
assert.equal(testItem.locationGeoJSON?.coordinates[0], sut.location?.longitude);
|
38
|
+
assert.equal(testItem.locationGeoJSON?.coordinates[1], sut.location?.latitude);
|
39
|
+
assert.equal(testItem.locationGeoJSON?.type, "Point");
|
40
|
+
assert.equal(testItem.locationGeoJSON?.coordinates[0], sut.locationGeoJSON.coordinates[0]);
|
41
|
+
assert.equal(testItem.locationGeoJSON?.coordinates[1], sut.locationGeoJSON.coordinates[1]);
|
42
|
+
assert.equal(testItem.opAreaCode, sut.opAreaCode);
|
43
|
+
assert.equal(testItem.opAreaName, sut.opAreaName);
|
44
|
+
assert.equal(testItem.shared, sut.shared);
|
45
|
+
assert.equal(testItem.state, sut.state);
|
46
|
+
assert.equal(testItem.sendToCAD, sut.sendToCAD);
|
47
|
+
assert.equal(testItem.color?.text, sut.color.text);
|
48
|
+
assert.equal(testItem.color?.background, sut.color.background);
|
49
|
+
assert.isTrue(sut.uuid !== "");
|
50
|
+
|
51
|
+
const { longitude, latitude } = sut.location ?? { latitude: 0, longitude: 0 };
|
52
|
+
const maxDistance = 10000;
|
53
|
+
const geoQuery = {
|
54
|
+
locationGeoJSON: {
|
55
|
+
$nearSphere: {
|
56
|
+
$geometry: {
|
57
|
+
type: "Point",
|
58
|
+
coordinates: [longitude, latitude],
|
59
|
+
},
|
60
|
+
$maxDistance: maxDistance
|
61
|
+
}
|
62
|
+
}
|
63
|
+
};
|
64
|
+
|
65
|
+
try {
|
66
|
+
await models.Location.findOne(geoQuery);
|
67
|
+
assert.isFalse(true, "Expecting above to fail.");
|
68
|
+
} catch (error) {
|
69
|
+
assert.isNotNull(error, "Expecting above to fail");
|
70
|
+
}
|
71
|
+
|
72
|
+
await models.Location.createIndexes();
|
73
|
+
|
74
|
+
const found = await models.Location.findOne(geoQuery);
|
75
|
+
assert.isObject(found);
|
76
|
+
|
77
|
+
await models.Location.collection.dropIndexes();
|
78
|
+
});
|
79
|
+
});
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { assert } from "chai";
|
2
|
+
import "mocha";
|
3
|
+
import * as m from "../index";
|
4
|
+
import * as config from "./config";
|
5
|
+
import mockModule from "./mock";
|
6
|
+
|
7
|
+
describe("MailLog", function() {
|
8
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
9
|
+
let testItem: Partial<m.MailLog>;
|
10
|
+
beforeEach(async function() {
|
11
|
+
const c = await m.connect(config.url);
|
12
|
+
models = c.models;
|
13
|
+
mongoose = c.mongoose;
|
14
|
+
|
15
|
+
const mock = mockModule({
|
16
|
+
mongoose
|
17
|
+
});
|
18
|
+
testItem = mock.mailLog;
|
19
|
+
});
|
20
|
+
afterEach(async function() {
|
21
|
+
await mongoose.disconnect();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("is saved", async function() {
|
25
|
+
const item = new models.MailLog(testItem);
|
26
|
+
const sut = await item.save();
|
27
|
+
|
28
|
+
assert.isNotNull(testItem._id);
|
29
|
+
assert.equal(testItem.mailId, sut.mailId);
|
30
|
+
assert.equal(testItem.event, sut.event);
|
31
|
+
assert.equal(testItem.timestamp, sut.timestamp);
|
32
|
+
assert.equal(testItem.recipient, sut.recipient);
|
33
|
+
assert.equal(testItem.recipientDomain, sut.recipientDomain);
|
34
|
+
if (testItem.tags?.length) {
|
35
|
+
assert.equal(testItem.tags[0], sut.tags[0]);
|
36
|
+
} else {
|
37
|
+
assert.equal(testItem.tags?.length, 1);
|
38
|
+
}
|
39
|
+
assert.equal(testItem.deliveryStatus, sut.deliveryStatus);
|
40
|
+
assert.equal(testItem.message, sut.message);
|
41
|
+
assert.equal(testItem.deliveryStatus, sut.deliveryStatus);
|
42
|
+
assert.equal(testItem.flags, sut.flags);
|
43
|
+
assert.equal(testItem.envelope, sut.envelope);
|
44
|
+
assert.equal(testItem.logLevel, sut.logLevel);
|
45
|
+
assert.equal(testItem.reason, sut.reason);
|
46
|
+
assert.equal(testItem.severity, sut.severity);
|
47
|
+
const expectedDate = new Date().valueOf() / 1000.0;
|
48
|
+
const timeDelta = expectedDate - sut.modified_unix_date;
|
49
|
+
assert.isTrue(timeDelta < 1);
|
50
|
+
});
|
51
|
+
});
|