tabletcommand-backend-models 7.0.13 → 7.0.15
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 +43 -1
- package/build/constants.js.map +1 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/models/cad-incident-stream.js +2 -2
- package/build/models/cad-incident-stream.js.map +1 -1
- package/build/models/chart-device-stats.js +2 -2
- package/build/models/chart-device-stats.js.map +1 -1
- package/build/models/chart-incident.js +2 -2
- package/build/models/chart-incident.js.map +1 -1
- package/build/models/chart-managed-incident.js +2 -2
- package/build/models/chart-managed-incident.js.map +1 -1
- package/build/models/chart-user.js +2 -2
- package/build/models/chart-user.js.map +1 -1
- package/build/models/department.js +7 -2
- 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/incident-event.js +2 -2
- package/build/models/incident-event.js.map +1 -1
- package/build/models/job-log.js +2 -2
- package/build/models/job-log.js.map +1 -1
- package/build/models/location.js +37 -2
- package/build/models/location.js.map +1 -1
- package/build/models/managed-incident.js +2 -2
- package/build/models/managed-incident.js.map +1 -1
- package/build/models/monitor.js +2 -2
- package/build/models/monitor.js.map +1 -1
- package/build/models/schema/cad-incident.js +2 -3
- package/build/models/schema/cad-incident.js.map +1 -1
- package/build/models/smtp-unhandled.js +2 -2
- package/build/models/smtp-unhandled.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 +87 -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 +1289 -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 +12 -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/models/location.d.ts +2 -0
- package/definitions/models/location.d.ts.map +1 -1
- package/definitions/models/schema/cad-incident.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 +1057 -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/definitions/types/location.d.ts +24 -23
- package/definitions/types/location.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/constants.ts +43 -0
- package/src/index.ts +2 -0
- package/src/models/cad-incident-stream.ts +1 -1
- package/src/models/chart-device-stats.ts +1 -1
- package/src/models/chart-incident.ts +1 -1
- package/src/models/chart-managed-incident.ts +1 -1
- package/src/models/chart-user.ts +1 -1
- package/src/models/department.ts +7 -1
- package/src/models/device-mapping.ts +4 -0
- package/src/models/incident-event.ts +1 -1
- package/src/models/job-log.ts +1 -1
- package/src/models/location.ts +41 -2
- package/src/models/managed-incident.ts +1 -1
- package/src/models/monitor.ts +1 -1
- package/src/models/schema/cad-incident.ts +1 -3
- package/src/models/smtp-unhandled.ts +1 -1
- package/src/mongoose-lean-virtuals.d.ts +4 -2
- 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 +93 -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 +599 -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 +6 -3
- package/src/types/cad.ts +2 -2
- package/src/types/department.ts +1 -0
- package/src/types/location.ts +22 -24
- 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,57 @@
|
|
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("CADStatus", function() {
|
8
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
9
|
+
let testItem: Partial<m.CADStatus>;
|
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.cadStatus;
|
19
|
+
});
|
20
|
+
afterEach(async function() {
|
21
|
+
await mongoose.disconnect();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("is saved", async function() {
|
25
|
+
const item = new models.CADStatus(testItem);
|
26
|
+
const sut = await item.save();
|
27
|
+
|
28
|
+
assert.equal(testItem.uuid, sut.uuid);
|
29
|
+
assert.equal(testItem.departmentId, sut.departmentId);
|
30
|
+
assert.equal(testItem.modifiedDate, sut.modifiedDate);
|
31
|
+
assert.equal(testItem.code, sut.code);
|
32
|
+
assert.equal(testItem.codeDisplay, sut.codeDisplay);
|
33
|
+
assert.equal(testItem.color?.background, sut.color.background);
|
34
|
+
assert.equal(testItem.color?.text, sut.color.text);
|
35
|
+
assert.equal(testItem.name, sut.name);
|
36
|
+
assert.equal(testItem.normalized, sut.normalized);
|
37
|
+
assert.isFalse(sut.roaming);
|
38
|
+
assert.isTrue(sut.selfAssignable);
|
39
|
+
assert.equal(testItem.status, sut.status);
|
40
|
+
assert.equal(testItem.statusId, sut.statusId);
|
41
|
+
if (testItem.options?.length && sut.options.length) {
|
42
|
+
assert.equal(testItem.options[0]?.cadKey, sut.options[0]?.cadKey);
|
43
|
+
assert.equal(testItem.options[0]?.name, sut.options[0]?.name);
|
44
|
+
assert.equal(testItem.options[0]?.position, sut.options[0]?.position);
|
45
|
+
assert.isTrue(sut.options[0]?.visible);
|
46
|
+
assert.equal(testItem.options[0]?.cadValues[0]?.name, sut.options[0]?.cadValues[0]?.name);
|
47
|
+
assert.equal(testItem.options[0]?.cadValues[0]?.type, sut.options[0]?.cadValues[0]?.type);
|
48
|
+
assert.equal(testItem.options[0]?.cadValues[0]?.value, sut.options[0]?.cadValues[0]?.value);
|
49
|
+
assert.isTrue(sut.options[0]?.cadValues[0]?.visible);
|
50
|
+
assert.isFalse(sut.options[0]?.cadValues[0]?.favorite);
|
51
|
+
} else {
|
52
|
+
assert.equal(testItem.options?.length, 1);
|
53
|
+
assert.equal(sut.options?.length, 1);
|
54
|
+
|
55
|
+
}
|
56
|
+
});
|
57
|
+
});
|
@@ -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("CADVehicleStatusHistory", function() {
|
8
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
9
|
+
let testItem: Partial<m.CADVehicleStatusHistory>;
|
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.cadVehicleStatusHistory;
|
19
|
+
});
|
20
|
+
afterEach(async function() {
|
21
|
+
await mongoose.disconnect();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("is saved", async function() {
|
25
|
+
const item = new models.CADVehicleStatusHistory(testItem);
|
26
|
+
const sut = await item.save();
|
27
|
+
|
28
|
+
assert.equal(testItem.departmentId, sut.departmentId);
|
29
|
+
assert.equal(testItem.vehicleId, sut.vehicleId);
|
30
|
+
assert.equal(testItem.radioName, sut.radioName);
|
31
|
+
assert.equal(testItem.status, sut.status);
|
32
|
+
assert.equal(testItem.statusCode, sut.statusCode);
|
33
|
+
assert.equal(testItem.requestedAt, sut.requestedAt);
|
34
|
+
assert.equal(testItem.requestedBy, sut.requestedBy);
|
35
|
+
assert.equal(testItem.incidentNumber, sut.incidentNumber);
|
36
|
+
});
|
37
|
+
});
|
@@ -0,0 +1,43 @@
|
|
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("CADVehicleStatus", function() {
|
8
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
9
|
+
let testItem: Partial<m.CADVehicleStatus>;
|
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.cadVehicleStatus;
|
19
|
+
});
|
20
|
+
afterEach(async function() {
|
21
|
+
await mongoose.disconnect();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("is saved", async function() {
|
25
|
+
const item = new models.CADVehicleStatus(testItem);
|
26
|
+
const sut = await item.save();
|
27
|
+
|
28
|
+
assert.equal(testItem.uuid, sut.uuid);
|
29
|
+
assert.equal(testItem.departmentId, sut.departmentId);
|
30
|
+
assert.equal(testItem.vehicleId, sut.vehicleId);
|
31
|
+
assert.equal(testItem.radioName, sut.radioName);
|
32
|
+
assert.equal(testItem.requestTime, sut.requestTime);
|
33
|
+
assert.equal(testItem.responseTime, sut.responseTime);
|
34
|
+
assert.equal(testItem.status, sut.status);
|
35
|
+
assert.equal(testItem.statusCode, sut.statusCode);
|
36
|
+
assert.equal(testItem.modifiedDate, sut.modifiedDate);
|
37
|
+
assert.equal(testItem.requestStatus, sut.requestStatus);
|
38
|
+
assert.equal(testItem.incidentNumber, sut.incidentNumber);
|
39
|
+
assert.equal(testItem.capability, sut.capability);
|
40
|
+
assert.equal(testItem.owner, sut.owner);
|
41
|
+
assert.equal(testItem.ownerId, sut.ownerId);
|
42
|
+
});
|
43
|
+
});
|
@@ -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("CADVehicle", function() {
|
8
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
9
|
+
let testItem: Partial<m.CADVehicle>;
|
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.cadVehicle;
|
19
|
+
});
|
20
|
+
afterEach(async function() {
|
21
|
+
await mongoose.disconnect();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("is saved", async function() {
|
25
|
+
const item = new models.CADVehicle(testItem);
|
26
|
+
const sut = await item.save();
|
27
|
+
|
28
|
+
assert.equal(testItem.uuid, sut.uuid);
|
29
|
+
assert.equal(testItem.departmentId, sut.departmentId);
|
30
|
+
assert.equal(testItem.modifiedDate, sut.modifiedDate);
|
31
|
+
assert.equal(testItem.vehicleId, sut.vehicleId);
|
32
|
+
assert.equal(testItem.radioName, sut.radioName);
|
33
|
+
assert.equal(testItem.station?.code, sut.station.code);
|
34
|
+
assert.equal(testItem.station?.name, sut.station.name);
|
35
|
+
assert.equal(testItem.capability, sut.capability);
|
36
|
+
assert.isFalse(sut.locationToCAD);
|
37
|
+
});
|
38
|
+
});
|
@@ -0,0 +1,43 @@
|
|
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("ChecklistItem", function() {
|
8
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
9
|
+
let testItem: Partial<m.ChecklistItem>;
|
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.checklistItem;
|
19
|
+
});
|
20
|
+
afterEach(async function() {
|
21
|
+
await mongoose.disconnect();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("is saved", async function() {
|
25
|
+
const item = new models.ChecklistItem(testItem);
|
26
|
+
const sut = await item.save();
|
27
|
+
|
28
|
+
assert.isNotNull(item._id);
|
29
|
+
assert.equal(item._id, sut.id);
|
30
|
+
assert.equal(testItem.position, sut.position);
|
31
|
+
assert.equal(testItem.active, sut.active);
|
32
|
+
assert.equal(testItem.name, sut.name);
|
33
|
+
assert.equal(testItem.userId, sut.userId);
|
34
|
+
assert.equal(testItem.departmentId, sut.departmentId);
|
35
|
+
assert.equal(testItem.isMandatory, sut.isMandatory);
|
36
|
+
assert.equal(testItem.api_checklist_id, sut.api_checklist_id);
|
37
|
+
assert.equal(testItem.checklist_uuid, sut.checklist_uuid);
|
38
|
+
assert.equal(testItem.description, sut.description);
|
39
|
+
const expectedDate = new Date().valueOf() / 1000.0;
|
40
|
+
const timeDelta = expectedDate - sut.modified_unix_date;
|
41
|
+
assert.isTrue(timeDelta < 1);
|
42
|
+
});
|
43
|
+
});
|
@@ -0,0 +1,44 @@
|
|
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("Checklist", function() {
|
8
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
9
|
+
let testItem: Partial<m.Checklist>;
|
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.checklist;
|
19
|
+
});
|
20
|
+
afterEach(async function() {
|
21
|
+
await mongoose.disconnect();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("is saved", async function() {
|
25
|
+
const item = new models.Checklist(testItem);
|
26
|
+
const sut = await item.save();
|
27
|
+
assert.isNotNull(item._id);
|
28
|
+
assert.equal(item._id, sut.id);
|
29
|
+
assert.equal(testItem.position, sut.position);
|
30
|
+
assert.equal(testItem.active, sut.active);
|
31
|
+
assert.equal(testItem.name, sut.name);
|
32
|
+
assert.equal(testItem.userId, sut.userId);
|
33
|
+
assert.equal(testItem.departmentId, sut.departmentId);
|
34
|
+
assert.equal(testItem.isMandatory, sut.isMandatory);
|
35
|
+
assert.equal(testItem.agencyId, sut.agencyId);
|
36
|
+
const expectedDate = new Date().valueOf() / 1000.0;
|
37
|
+
const timeDelta = expectedDate - sut.modified_unix_date;
|
38
|
+
assert.isTrue(timeDelta < 1);
|
39
|
+
|
40
|
+
const items = sut.items;
|
41
|
+
assert.isArray(items);
|
42
|
+
assert.equal(items.length, 1);
|
43
|
+
});
|
44
|
+
});
|
package/src/test/config.ts
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
export const url = process.env.NODE_MONGO_URL || "mongodb://127.0.0.1/incident-test";
|
1
|
+
export const url = process.env.NODE_MONGO_URL || "";
|
4
2
|
|
5
3
|
export function checkIfTestDatabase() {
|
6
4
|
if (!/massive-test/i.exec(url)) {
|
@@ -8,3 +6,5 @@ export function checkIfTestDatabase() {
|
|
8
6
|
process.exit(1);
|
9
7
|
}
|
10
8
|
}
|
9
|
+
|
10
|
+
checkIfTestDatabase();
|
@@ -0,0 +1,44 @@
|
|
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("CSVImport", function() {
|
8
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
9
|
+
let testItem: Partial<m.CSVImport>;
|
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.csvImport;
|
19
|
+
});
|
20
|
+
afterEach(async function() {
|
21
|
+
await mongoose.disconnect();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("is saved", async function() {
|
25
|
+
const item = new models.CSVImport(testItem);
|
26
|
+
const sut = await item.save();
|
27
|
+
assert.equal(testItem._id, sut._id);
|
28
|
+
assert.equal(testItem.batchId, sut.batchId);
|
29
|
+
// assert.equal(testItem.importCreated, sut.importCreated);
|
30
|
+
assert.equal(testItem.departmentId, sut.departmentId);
|
31
|
+
assert.equal(testItem.agencyId, sut.agencyId);
|
32
|
+
assert.equal(testItem.importType, sut.importType);
|
33
|
+
assert.equal(testItem.fileType, sut.fileType);
|
34
|
+
assert.equal(testItem.fileName, sut.fileName);
|
35
|
+
assert.equal(testItem.fileSize, sut.fileSize);
|
36
|
+
assert.equal(testItem.status, sut.status);
|
37
|
+
// assert.equal(testItem.modifiedDate, sut.modifiedDate);
|
38
|
+
// assert.equal(testItem.fileLastModified, sut.fileLastModified);
|
39
|
+
assert.equal(testItem.records?.length, 0);
|
40
|
+
assert.equal(testItem.userId, sut.userId);
|
41
|
+
assert.equal(testItem.sendNotification, sut.sendNotification);
|
42
|
+
});
|
43
|
+
});
|
44
|
+
|
@@ -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
|
+
});
|