tabletcommand-backend-models 5.17.27 → 5.17.30

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.
Files changed (39) hide show
  1. package/.eslintrc.js +1 -3
  2. package/build/models/arcgis-group.js +0 -5
  3. package/build/models/arcgis-group.js.map +1 -1
  4. package/build/models/department.js +4 -0
  5. package/build/models/department.js.map +1 -1
  6. package/build/models/esri.js +3 -3
  7. package/build/models/esri.js.map +1 -1
  8. package/build/models/location.js +6 -1
  9. package/build/models/location.js.map +1 -1
  10. package/build/test/arcgis-group.js +95 -0
  11. package/build/test/arcgis-group.js.map +1 -0
  12. package/build/test/config.js +12 -0
  13. package/build/test/config.js.map +1 -0
  14. package/build/test/mock.js +974 -0
  15. package/build/test/mock.js.map +1 -0
  16. package/build.sh +3 -0
  17. package/definitions/models/arcgis-group.d.ts +0 -46
  18. package/definitions/models/arcgis-group.d.ts.map +1 -1
  19. package/definitions/models/department.d.ts +1 -0
  20. package/definitions/models/department.d.ts.map +1 -1
  21. package/definitions/models/esri.d.ts +4 -4
  22. package/definitions/models/location.d.ts.map +1 -1
  23. package/definitions/test/arcgis-group.d.ts +2 -0
  24. package/definitions/test/arcgis-group.d.ts.map +1 -0
  25. package/definitions/test/config.d.ts +3 -0
  26. package/definitions/test/config.d.ts.map +1 -0
  27. package/definitions/test/mock.d.ts +39 -0
  28. package/definitions/test/mock.d.ts.map +1 -0
  29. package/package.json +17 -8
  30. package/src/models/arcgis-group.ts +0 -5
  31. package/src/models/department.ts +4 -0
  32. package/src/models/esri.ts +3 -3
  33. package/src/models/location.ts +10 -4
  34. package/src/test/arcgis-group.ts +107 -0
  35. package/src/test/config.ts +10 -0
  36. package/src/test/mock.ts +982 -0
  37. package/src/tsconfig.json +5 -0
  38. package/test/arcgis-group.js +2 -2
  39. package/test/mock.js +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock.js","sourceRoot":"","sources":["../../src/test/mock.ts"],"names":[],"mappings":";;AAIA,qCAA+C;AAC/C,IAAA,4BAAmB,GAAE,CAAC;AAEtB,SAAwB,UAAU,CAAC,WAElC;IAEC,KAAK,UAAU,OAAO;QACpB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,WAAW,GAAG;QAClB,MAAM,EAAE,SAAS;QACjB,iBAAiB,EAAE;YACjB;gBACE,UAAU,EAAE,0BAA0B;gBACtC,YAAY,EAAE,0BAA0B;gBACxC,YAAY,EAAE,WAAW;gBACzB,SAAS,EAAE,IAAI;gBACf,aAAa,EAAE,0BAA0B;gBACzC,UAAU,EAAE,IAAI;gBAChB,KAAK,EAAE;oBACL,EAAE;oBACF;wBACE,QAAQ,EAAE,YAAY;wBACtB,KAAK,EAAE,cAAc;wBACrB,MAAM,EAAE,0BAA0B;qBACnC;iBACF;aACF;SACF;QACD,cAAc,EAAE;YACd,iBAAiB;SAClB;QACD,OAAO,EAAE,kCAAkC;QAC3C,SAAS,EAAE;YACT;gBACE,QAAQ,EAAE,gBAAgB;gBAC1B,UAAU,EAAE,QAAQ;gBACpB,KAAK,EAAE,iBAAiB;gBACxB,QAAQ,EAAE,gBAAgB;aAC3B;SACF;QACD,KAAK,EAAE,oBAAoB;QAC3B,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,8BAA8B;QACrC,KAAK,EAAE;YACL;gBACE,QAAQ,EAAE,cAAc;gBACxB,UAAU,EAAE,OAAO;gBACnB,KAAK,EAAE,kBAAkB;gBACzB,QAAQ,EAAE,oBAAoB;aAC/B;SACF;KACF,CAAC;IAEF,OAAO;QACL,OAAO;QAEP,WAAW;KACZ,CAAC;AACJ,CAAC;AA1DD,6BA0DC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAk5BE"}
package/build.sh CHANGED
@@ -22,4 +22,7 @@ NODE_VERSION="v16.13.2"
22
22
  nvm use $NODE_VERSION || nvm install $NODE_VERSION
23
23
 
24
24
  npm install;
25
+ echo "--- test"
25
26
  npm test;
27
+ echo "--- type coverage"
28
+ npx type-coverage;
@@ -43,52 +43,6 @@ export declare function ArcGISGroupModule(mongoose: MongooseModule): Promise<imp
43
43
  };
44
44
  }>[];
45
45
  externalOrgIds: string[];
46
- resolvedDepartments: import("../helpers").MongooseInterface<{
47
- department: {
48
- type: StringConstructor;
49
- default: string;
50
- };
51
- departmentId: {
52
- type: StringConstructor;
53
- default: string;
54
- };
55
- authUsername: {
56
- type: StringConstructor;
57
- default: string;
58
- };
59
- authError: {
60
- type: StringConstructor;
61
- default: string;
62
- };
63
- tokenUsername: {
64
- type: StringConstructor;
65
- default: null;
66
- };
67
- tokenError: {
68
- type: StringConstructor;
69
- default: null;
70
- };
71
- users: {
72
- type: (import("mongoose").Schema<any> & {
73
- _interface: import("../helpers").MongooseInterface<{
74
- username: {
75
- type: StringConstructor;
76
- default: string;
77
- };
78
- email: {
79
- type: StringConstructor;
80
- default: string;
81
- };
82
- userId: {
83
- type: StringConstructor;
84
- default: string;
85
- };
86
- }>;
87
- _methods: unknown;
88
- })[];
89
- default: never[];
90
- };
91
- }>[];
92
46
  linkedDepartments: import("../helpers").MongooseInterface<{
93
47
  department: {
94
48
  type: StringConstructor;
@@ -1 +1 @@
1
- {"version":3,"file":"arcgis-group.d.ts","sourceRoot":"","sources":["../../src/models/arcgis-group.ts"],"names":[],"mappings":";AACA,OAAO,EAIL,8BAA8B,EAC9B,+BAA+B,EAC/B,cAAc,EACd,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAEpB,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwI/D;AAED,MAAM,WAAW,WAAY,SAAQ,8BAA8B,CAAC,OAAO,iBAAiB,CAAC;CAAI;AACjG,MAAM,WAAW,gBAAiB,SAAQ,+BAA+B,CAAC,WAAW,CAAC;CAAI;;AAC1F,wBAAuG"}
1
+ {"version":3,"file":"arcgis-group.d.ts","sourceRoot":"","sources":["../../src/models/arcgis-group.ts"],"names":[],"mappings":";AACA,OAAO,EAIL,8BAA8B,EAC9B,+BAA+B,EAC/B,cAAc,EACd,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAEpB,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmI/D;AAED,MAAM,WAAW,WAAY,SAAQ,8BAA8B,CAAC,OAAO,iBAAiB,CAAC;CAAI;AACjG,MAAM,WAAW,gBAAiB,SAAQ,+BAA+B,CAAC,WAAW,CAAC;CAAI;;AAC1F,wBAAuG"}
@@ -114,6 +114,7 @@ export declare function DepartmentModule(mongoose: MongooseModule): Promise<impo
114
114
  accountType: string;
115
115
  timeZone: string;
116
116
  remoteLoggingEnabled: boolean;
117
+ logOffEnabled: boolean;
117
118
  licensing: any;
118
119
  webDisclaimer: import("../helpers").MongooseInterface<{
119
120
  message: {
@@ -1 +1 @@
1
- {"version":3,"file":"department.d.ts","sourceRoot":"","sources":["../../src/models/department.ts"],"names":[],"mappings":";AAGA,OAAO,EAGL,WAAW,EAGX,cAAc,EAEd,8BAA8B,EAC9B,+BAA+B,EAC/B,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAGpB,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyZ9D;AAED,MAAM,WAAW,UAAW,SAAQ,8BAA8B,CAAC,OAAO,gBAAgB,CAAC;CAAI;AAC/F,MAAM,WAAW,eAAgB,SAAQ,+BAA+B,CAAC,UAAU,CAAC;CAAI;;AACxF,wBAAoG"}
1
+ {"version":3,"file":"department.d.ts","sourceRoot":"","sources":["../../src/models/department.ts"],"names":[],"mappings":";AAGA,OAAO,EAGL,WAAW,EAGX,cAAc,EAEd,8BAA8B,EAC9B,+BAA+B,EAC/B,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAGpB,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6Z9D;AAED,MAAM,WAAW,UAAW,SAAQ,8BAA8B,CAAC,OAAO,gBAAgB,CAAC;CAAI;AAC/F,MAAM,WAAW,eAAgB,SAAQ,+BAA+B,CAAC,UAAU,CAAC;CAAI;;AACxF,wBAAoG"}
@@ -171,9 +171,9 @@ export declare function EsriSchema(mongoose: MongooseModule): import("mongoose")
171
171
  };
172
172
  default: null;
173
173
  };
174
- arcGISGroupId: {
175
- type: StringConstructor;
176
- default: null;
174
+ arcGISGroupIds: {
175
+ type: StringConstructor[];
176
+ default: never[];
177
177
  };
178
178
  arcGISAuth: {
179
179
  type: import("mongoose").Schema<any> & {
@@ -543,7 +543,7 @@ export declare function EsriModule(mongoose: MongooseModule): Promise<import("mo
543
543
  default: null;
544
544
  };
545
545
  }>;
546
- arcGISGroupId: string;
546
+ arcGISGroupIds: string[];
547
547
  arcGISAuth: import("../helpers").MongooseInterface<{
548
548
  username: {
549
549
  type: StringConstructor;
@@ -1 +1 @@
1
- {"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../../src/models/location.ts"],"names":[],"mappings":";AACA,OAAO,EAKL,8BAA8B,EAC9B,+BAA+B,EAE/B,cAAc,EACd,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAKpB,wBAAsB,cAAc,CAAC,QAAQ,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6J5D;AAED,MAAM,WAAW,QAAS,SAAQ,8BAA8B,CAAC,OAAO,cAAc,CAAC;CAAI;AAC3F,MAAM,WAAW,aAAc,SAAQ,+BAA+B,CAAC,QAAQ,CAAC;CAAI;;AACpF,wBAA8F"}
1
+ {"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../../src/models/location.ts"],"names":[],"mappings":";AACA,OAAO,EAKL,8BAA8B,EAC9B,+BAA+B,EAE/B,cAAc,EACd,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAKpB,wBAAsB,cAAc,CAAC,QAAQ,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmK5D;AAED,MAAM,WAAW,QAAS,SAAQ,8BAA8B,CAAC,OAAO,cAAc,CAAC;CAAI;AAC3F,MAAM,WAAW,aAAc,SAAQ,+BAA+B,CAAC,QAAQ,CAAC;CAAI;;AACpF,wBAA8F"}
@@ -0,0 +1,2 @@
1
+ import "mocha";
2
+ //# sourceMappingURL=arcgis-group.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arcgis-group.d.ts","sourceRoot":"","sources":["../../src/test/arcgis-group.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const url: string;
2
+ export declare function checkIfTestDatabase(): void;
3
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/test/config.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG,QAAoE,CAAC;AAErF,wBAAgB,mBAAmB,SAKlC"}
@@ -0,0 +1,39 @@
1
+ export default function MockModule(dependecies: {
2
+ models: unknown;
3
+ }): {
4
+ cleanup: () => Promise<string>;
5
+ arcGISGroup: {
6
+ access: string;
7
+ linkedDepartments: {
8
+ department: string;
9
+ departmentId: string;
10
+ authUsername: string;
11
+ authError: null;
12
+ tokenUsername: string;
13
+ tokenError: null;
14
+ users: {
15
+ username: string;
16
+ email: string;
17
+ userId: string;
18
+ }[];
19
+ }[];
20
+ externalOrgIds: string[];
21
+ groupId: string;
22
+ outsiders: {
23
+ fullName: string;
24
+ memberType: string;
25
+ orgId: string;
26
+ username: string;
27
+ }[];
28
+ owner: string;
29
+ protected: boolean;
30
+ title: string;
31
+ users: {
32
+ fullName: string;
33
+ memberType: string;
34
+ orgId: string;
35
+ username: string;
36
+ }[];
37
+ };
38
+ };
39
+ //# sourceMappingURL=mock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/test/mock.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,WAAW,EAAE;IAC9C,MAAM,EAAE,OAAO,CAAC;CACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwDA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabletcommand-backend-models",
3
- "version": "5.17.27",
3
+ "version": "5.17.30",
4
4
  "description": "Tablet Command Backend Models",
5
5
  "scripts": {
6
6
  "test": "gulp",
@@ -27,21 +27,30 @@
27
27
  "devDependencies": {
28
28
  "@types/bluebird": "^3.5.36",
29
29
  "@types/chai": "^4.3.0",
30
- "@types/lodash": "^4.14.178",
30
+ "@types/lodash": "^4.14.179",
31
31
  "@types/mocha": "^9.1.0",
32
32
  "@types/mongodb": "^3.6.20",
33
33
  "@types/mongoose": "~5.10.5",
34
34
  "@types/uuid": "~8.3.4",
35
- "@typescript-eslint/eslint-plugin": "^5.12.1",
36
- "@typescript-eslint/parser": "^5.12.1",
35
+ "@typescript-eslint/eslint-plugin": "~5.14.0",
36
+ "@typescript-eslint/parser": "~5.14.0",
37
37
  "chai": "^4.3.6",
38
38
  "del": "^6.0.0",
39
- "eslint": "^8.9.0",
39
+ "eslint": "^8.10.0",
40
40
  "gulp": "^4.0.2",
41
41
  "gulp-mocha": "^8.0.0",
42
42
  "gulp-shell": "^0.8.0",
43
43
  "mocha": "^9.2.1",
44
- "typescript": "^4.5.5",
45
- "yargs-parser": ">=21.0.0"
44
+ "ts-node": "^10.7.0",
45
+ "type-coverage": "^2.21.0",
46
+ "typescript": "^4.6.2",
47
+ "yargs-parser": ">=21.0.1"
48
+ },
49
+ "typeCoverage": {
50
+ "atLeast": 99.80,
51
+ "ignoreFiles": [
52
+ "definitions/**/*.ts",
53
+ "src/test/**/*.ts"
54
+ ]
46
55
  }
47
- }
56
+ }
@@ -124,11 +124,6 @@ export async function ArcGISGroupModule(mongoose: MongooseModule) {
124
124
  default: [],
125
125
  },
126
126
 
127
- // departments that are linked to this group via group.user = dept.auth
128
- resolvedDepartments: {
129
- type: [ArcGISDepartment],
130
- default: [],
131
- },
132
127
  // departments that are linked via arcGISGroupId (linked by a super admin)
133
128
  linkedDepartments: {
134
129
  type: [ArcGISDepartment],
@@ -396,6 +396,10 @@ export async function DepartmentModule(mongoose: MongooseModule) {
396
396
  type: Boolean,
397
397
  default: false,
398
398
  },
399
+ logOffEnabled: {
400
+ type: Boolean,
401
+ default: false,
402
+ },
399
403
  licensing: {
400
404
  type: Object,
401
405
  default: LicensingDefault,
@@ -86,9 +86,9 @@ export function EsriSchema(mongoose: MongooseModule) {
86
86
  },
87
87
 
88
88
  // Link to ArcGISGroup
89
- arcGISGroupId: {
90
- type: String,
91
- default: null,
89
+ arcGISGroupIds: {
90
+ type: [String],
91
+ default: [],
92
92
  },
93
93
  // ArcGIS user used for fallback when a new user has no ArcGIS account yet
94
94
  arcGISAuth: {
@@ -144,23 +144,29 @@ export async function LocationModule(mongoose: MongooseModule) {
144
144
  versionKey: false,
145
145
  });
146
146
 
147
- modelSchema.virtual("id").get(function(this: MongooseDocument) {
147
+ modelSchema.virtual("id").get(function (this: MongooseDocument) {
148
148
  return this._id.toHexString();
149
149
  });
150
150
 
151
- modelSchema.virtual("location").get(function(this: { locationGeoJSON: { coordinates: number[] }} | null | undefined) {
151
+ modelSchema.virtual("location").get(function (this: { locationGeoJSON: { coordinates: number[] } } | null | undefined) {
152
152
  const location = {
153
153
  latitude: 0,
154
154
  longitude: 0
155
155
  };
156
- if (this && this.locationGeoJSON && this.locationGeoJSON.coordinates && this.locationGeoJSON.coordinates.length === 2) {
156
+ if (this && this.locationGeoJSON &&
157
+ this.locationGeoJSON.coordinates &&
158
+ this.locationGeoJSON.coordinates[0] &&
159
+ Number.isFinite(this.locationGeoJSON.coordinates[0]) &&
160
+ this.locationGeoJSON.coordinates[1] &&
161
+ Number.isFinite(this.locationGeoJSON.coordinates[1])
162
+ ) {
157
163
  location.longitude = this.locationGeoJSON.coordinates[0];
158
164
  location.latitude = this.locationGeoJSON.coordinates[1];
159
165
  }
160
166
  return location;
161
167
  });
162
168
 
163
- // Create GeoJSON index
169
+ // Create GeoJSON index
164
170
  modelSchema.index({
165
171
  locationGeoJSON: "2dsphere",
166
172
  shared: 1,
@@ -0,0 +1,107 @@
1
+
2
+ import { assert } from "chai";
3
+ import "mocha";
4
+ import * as _ from "lodash";
5
+
6
+ import { url as mongoURL } from "./config";
7
+
8
+ import { connect } from "..";
9
+ import MockModule from "./mock";
10
+
11
+ describe("ArcGISGroup", function () {
12
+ let models,
13
+ mongoose: typeof import("mongoose"),
14
+ mock;
15
+
16
+ beforeEach(async function () {
17
+ const result = await connect(mongoURL);
18
+ console.log(result);
19
+ // models = result.models;
20
+ // mongoose = result.mongoose;
21
+
22
+ // mock = MockModule({
23
+ // models,
24
+ // });
25
+ // await mock.cleanup();
26
+
27
+ // console.log("x", result);
28
+ console.log(mongoURL);
29
+ });
30
+
31
+ afterEach(async function() {
32
+ // await mongoose.disconnect();
33
+ });
34
+
35
+ it("is saved", async function () {
36
+ assert.isTrue(true);
37
+ });
38
+ });
39
+
40
+
41
+ /*
42
+
43
+ const m = require("..");
44
+
45
+ describe("ArcGISGroup", function() {
46
+ let models, mongoose, mock;
47
+
48
+ beforeEach(async function() {
49
+ const c = await m.connect(config.url);
50
+ models = c.models;
51
+ mongoose = c.mongoose;
52
+ mock = require("./mock")({
53
+ models,
54
+ mongoose,
55
+ });
56
+ await mock.cleanup();
57
+ });
58
+
59
+ afterEach(function() {
60
+ mongoose.disconnect();
61
+ });
62
+
63
+ it("is saved", async function() {
64
+ const testItem = mock.arcGISGroup;
65
+ assert.isObject(testItem);
66
+ const item = new models.ArcGISGroup(testItem);
67
+ const sut = await item.save();
68
+
69
+ assert.isNotNull(sut._id);
70
+ assert.isNotNull(sut.modified);
71
+
72
+ assert.equal(sut.groupId, testItem.groupId);
73
+ assert.equal(sut.title, testItem.title);
74
+ assert.deepEqual(sut.externalOrgIds, testItem.externalOrgIds);
75
+ assert.equal(sut.access, testItem.access);
76
+ assert.equal(sut.owner, testItem.owner);
77
+ assert.equal(sut.protected, testItem.protected);
78
+
79
+ assert.equal(sut.linkedDepartments.length, 1);
80
+ const dept = _.first(sut.linkedDepartments);
81
+ assert.equal(dept.department, "Demo RTS Fire Department");
82
+ assert.equal(dept.departmentId, "558365a198b2fa4278000053");
83
+ assert.equal(dept.authUsername, "tabletcmd");
84
+ assert.equal(dept.tokenUsername, "tc_ContraCostaCountyFire");
85
+
86
+ assert.equal(dept.users.length, 1);
87
+ const deptUser = _.first(dept.users);
88
+ assert.equal(deptUser.username, "tc_someone");
89
+ assert.equal(deptUser.email, "hello@tc.com");
90
+ assert.equal(deptUser.userId, "558365a198a2aa42780000aa");
91
+
92
+ assert.equal(sut.outsiders.length, 1);
93
+ const outsider = _.first(sut.outsiders);
94
+ assert.equal(outsider.username, "Michael_Kallum");
95
+ assert.equal(outsider.fullName, "Michael Kallum");
96
+ assert.equal(outsider.memberType, "member");
97
+ assert.equal(outsider.orgId, "MyTOuXKXZoizaaa");
98
+
99
+ assert.equal(sut.users.length, 1);
100
+ const user = _.first(sut.users);
101
+ assert.equal(user.username, "jane_tabletcommand");
102
+ assert.equal(user.fullName, "Jane Serrano");
103
+ assert.equal(user.memberType, "admin");
104
+ assert.equal(user.orgId, "zGXMcUaDlMGoAAAg");
105
+ });
106
+ });
107
+ */
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ export const url = process.env.NODE_MONGO_URL || "mongodb://127.0.0.1/incident-test";
4
+
5
+ export function checkIfTestDatabase() {
6
+ if (!/massive-test/i.exec(url)) {
7
+ console.log(`Not a test database: ${url}? Expecting database: massive-test.`);
8
+ process.exit(1);
9
+ }
10
+ }