@dhyasama/totem-models 7.58.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +14 -0
- package/helpers.js +89 -0
- package/index.js +0 -1
- package/lib/Account.js +125 -79
- package/lib/Activity.js +0 -2
- package/lib/CalendarEvent.js +1 -7
- package/lib/CapTable.js +0 -1
- package/lib/Deal.js +215 -151
- package/lib/Document.js +57 -56
- package/lib/Financials.js +115 -176
- package/lib/Flag.js +37 -14
- package/lib/Fund.js +6 -33
- package/lib/Interaction.js +79 -32
- package/lib/Investment.js +4 -10
- package/lib/LimitedPartner.js +303 -634
- package/lib/List.js +105 -147
- package/lib/Message.js +100 -51
- package/lib/News.js +1 -53
- package/lib/Note.js +60 -66
- package/lib/Organization.js +470 -645
- package/lib/Person.js +342 -650
- package/lib/Round.js +191 -134
- package/lib/Snapshot.js +3 -5
- package/lib/Webhook.js +1 -4
- package/package-lock.json +1927 -0
- package/package.json +2 -3
- package/test/Account.js +53 -38
- package/test/Deal.js +14 -30
- package/test/Document.js +51 -50
- package/test/Financials.js +5 -3
- package/test/Flag.js +18 -14
- package/test/Interaction.js +1 -31
- package/test/Investment.js +2 -3
- package/test/LimitedPartner.js +399 -554
- package/test/List.js +24 -29
- package/test/Message.js +7 -46
- package/test/News.js +12 -29
- package/test/Note.js +23 -22
- package/test/Organization.js +33 -307
- package/test/Person.js +6 -253
- package/test/Round.js +11 -11
- package/lib/Sync.js +0 -48
package/test/LimitedPartner.js
CHANGED
|
@@ -1,554 +1,399 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
//
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
// done();
|
|
401
|
-
//
|
|
402
|
-
// });
|
|
403
|
-
//
|
|
404
|
-
// });
|
|
405
|
-
//
|
|
406
|
-
// it('does not find k1 for an lp if not allowed', function(done) {
|
|
407
|
-
//
|
|
408
|
-
// LimitedPartner.getById(lp.id, 'lp-names', function(err, result) {
|
|
409
|
-
//
|
|
410
|
-
// should.not.exist(err);
|
|
411
|
-
// should.exist(result);
|
|
412
|
-
// should.not.exist(result.k1.nameOfInvestor);
|
|
413
|
-
//
|
|
414
|
-
// done();
|
|
415
|
-
//
|
|
416
|
-
// });
|
|
417
|
-
//
|
|
418
|
-
// });
|
|
419
|
-
//
|
|
420
|
-
// it('finds k1 for an lp if allowed', function(done) {
|
|
421
|
-
//
|
|
422
|
-
// LimitedPartner.getById(lp.id, 'lp-full', function(err, lp) {
|
|
423
|
-
//
|
|
424
|
-
// should.not.exist(err);
|
|
425
|
-
// should.exist(lp);
|
|
426
|
-
// lp.k1.nameOfInvestor.should.equal('United T');
|
|
427
|
-
//
|
|
428
|
-
// done();
|
|
429
|
-
//
|
|
430
|
-
// });
|
|
431
|
-
//
|
|
432
|
-
// });
|
|
433
|
-
//
|
|
434
|
-
// it('finds name for an lp if allowed', function(done) {
|
|
435
|
-
//
|
|
436
|
-
// LimitedPartner.getById(lp.id, 'lp-names', function(err, lp) {
|
|
437
|
-
//
|
|
438
|
-
// should.not.exist(err);
|
|
439
|
-
// should.exist(lp);
|
|
440
|
-
// should.exist(lp.name);
|
|
441
|
-
//
|
|
442
|
-
// done();
|
|
443
|
-
//
|
|
444
|
-
// });
|
|
445
|
-
//
|
|
446
|
-
// });
|
|
447
|
-
//
|
|
448
|
-
// it('flags an lp as an admin', function(done) {
|
|
449
|
-
//
|
|
450
|
-
// LimitedPartner.flag(lp.id, false, 'incorrect phone', 'testy', 'admin', function(err, lp) {
|
|
451
|
-
//
|
|
452
|
-
// should.not.exist(err);
|
|
453
|
-
// should.exist(lp);
|
|
454
|
-
// should.exist(lp.name);
|
|
455
|
-
// lp.flagged.resolved.should.equal(false);
|
|
456
|
-
//
|
|
457
|
-
// done();
|
|
458
|
-
//
|
|
459
|
-
// });
|
|
460
|
-
//
|
|
461
|
-
// });
|
|
462
|
-
//
|
|
463
|
-
// it('flags an lp as a limited user', function(done) {
|
|
464
|
-
//
|
|
465
|
-
// LimitedPartner.flag(lp.id, false, 'incorrect phone', 'testy', 'lp-names', function(err, lp) {
|
|
466
|
-
//
|
|
467
|
-
// should.not.exist(err);
|
|
468
|
-
// should.exist(lp);
|
|
469
|
-
// should.exist(lp.name);
|
|
470
|
-
// lp.flagged.resolved.should.equal(false);
|
|
471
|
-
//
|
|
472
|
-
// done();
|
|
473
|
-
//
|
|
474
|
-
// });
|
|
475
|
-
//
|
|
476
|
-
// it('does not flag an lp as a nobody', function(done) {
|
|
477
|
-
//
|
|
478
|
-
// LimitedPartner.flag(lp.id, false, 'incorrect phone', 'testy', 'none', function (err, lp) {
|
|
479
|
-
//
|
|
480
|
-
// should.not.exist(err);
|
|
481
|
-
// should.exist(lp);
|
|
482
|
-
// should.not.exist(lp.flagged);
|
|
483
|
-
//
|
|
484
|
-
// done();
|
|
485
|
-
//
|
|
486
|
-
// });
|
|
487
|
-
//
|
|
488
|
-
// });
|
|
489
|
-
//
|
|
490
|
-
// });
|
|
491
|
-
//
|
|
492
|
-
// it('adds a note', function(done) {
|
|
493
|
-
//
|
|
494
|
-
// LimitedPartner.addNote(lp.id, person._id, 'Sweet note bro!', function(err, result) {
|
|
495
|
-
//
|
|
496
|
-
// should.not.exist(err);
|
|
497
|
-
// should.exist(result);
|
|
498
|
-
// should.exist(result.note);
|
|
499
|
-
// should.exist(result.addedTo);
|
|
500
|
-
// result.addedTo.notes.length.should.equal(1);
|
|
501
|
-
//
|
|
502
|
-
// noteId = result.addedTo.notes[0];
|
|
503
|
-
//
|
|
504
|
-
// return done();
|
|
505
|
-
//
|
|
506
|
-
// });
|
|
507
|
-
//
|
|
508
|
-
// });
|
|
509
|
-
//
|
|
510
|
-
// it('gets an lp by id with a populated note', function(done) {
|
|
511
|
-
// LimitedPartner.getById(lp.id, 'admin', function(err, result) {
|
|
512
|
-
// should.not.exist(err);
|
|
513
|
-
// should.exist(result);
|
|
514
|
-
// result.id.should.equal(lp.id);
|
|
515
|
-
// should.exist(result.notes);
|
|
516
|
-
// result.notes.length.should.equal(1);
|
|
517
|
-
// should.exist(result.notes[0].createdBy);
|
|
518
|
-
// should.exist(result.notes[0].createdBy.avatarUrl);
|
|
519
|
-
// result.notes[0].createdBy.avatarUrl.length.should.be.above(0);
|
|
520
|
-
// should.exist(result.notes[0].createdBy.name);
|
|
521
|
-
// should.exist(result.notes[0].createdBy.name.first);
|
|
522
|
-
// result.notes[0].createdBy.name.first.length.should.be.above(0);
|
|
523
|
-
// done();
|
|
524
|
-
// });
|
|
525
|
-
// });
|
|
526
|
-
//
|
|
527
|
-
// it('deletes a note', function(done) {
|
|
528
|
-
//
|
|
529
|
-
// LimitedPartner.deleteNote(noteId, function(err, result) {
|
|
530
|
-
//
|
|
531
|
-
// should.not.exist(err);
|
|
532
|
-
//
|
|
533
|
-
// return done();
|
|
534
|
-
//
|
|
535
|
-
// });
|
|
536
|
-
//
|
|
537
|
-
// });
|
|
538
|
-
//
|
|
539
|
-
// it('deletes an event note', function(done) {
|
|
540
|
-
//
|
|
541
|
-
// LimitedPartner.deleteNote(eventNote.id, function(err, result) {
|
|
542
|
-
//
|
|
543
|
-
// should.not.exist(err);
|
|
544
|
-
//
|
|
545
|
-
// return done();
|
|
546
|
-
//
|
|
547
|
-
// });
|
|
548
|
-
//
|
|
549
|
-
// });
|
|
550
|
-
//
|
|
551
|
-
// // todo - findbytransaction
|
|
552
|
-
// // todo - distributions
|
|
553
|
-
//
|
|
554
|
-
// });
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var
|
|
4
|
+
|
|
5
|
+
should = require("should"),
|
|
6
|
+
config = require('./config')['test'],
|
|
7
|
+
mongoose = require('mongoose'),
|
|
8
|
+
clearDB = require('mocha-mongoose')(config.db.uri, {noClear: true}),
|
|
9
|
+
LimitedPartner = mongoose.model('LimitedPartner'),
|
|
10
|
+
lp = new LimitedPartner(),
|
|
11
|
+
Person = mongoose.model('Person'),
|
|
12
|
+
person = new Person(),
|
|
13
|
+
person1, person2,
|
|
14
|
+
Fund = mongoose.model('Fund'),
|
|
15
|
+
fund = new Fund(),
|
|
16
|
+
noteId,
|
|
17
|
+
Organization = mongoose.model('Organization'),
|
|
18
|
+
organization = new Organization();
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
describe('Limited Partner', function() {
|
|
22
|
+
|
|
23
|
+
before(function(done) {
|
|
24
|
+
if (mongoose.connection.db) return done();
|
|
25
|
+
mongoose.connect(config.db.uri, done);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
before(function(done) {
|
|
29
|
+
clearDB(done);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
before(function(done) {
|
|
33
|
+
organization.name = 'My Org';
|
|
34
|
+
organization.slug = 'my-org';
|
|
35
|
+
Organization.upsert(organization, 'test', function(err, result) {
|
|
36
|
+
should.not.exist(err);
|
|
37
|
+
should.exist(result);
|
|
38
|
+
organization = result;
|
|
39
|
+
done();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
before(function(done) {
|
|
44
|
+
fund.name = 'My Huge Fund';
|
|
45
|
+
fund.slug = 'my-huge-fund';
|
|
46
|
+
fund.shortName = 'mhf';
|
|
47
|
+
fund.abbreviation = 'mhf';
|
|
48
|
+
Fund.upsert(fund, 'test', function(err, result) {
|
|
49
|
+
should.not.exist(err);
|
|
50
|
+
should.exist(result);
|
|
51
|
+
fund = result;
|
|
52
|
+
done();
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
before(function(done) {
|
|
57
|
+
|
|
58
|
+
person1 = new Person();
|
|
59
|
+
person1.name.first = 'Mischa';
|
|
60
|
+
person1.name.last = 'Barton';
|
|
61
|
+
person1.slug = 'mischa-barton';
|
|
62
|
+
|
|
63
|
+
Person.upsert(person1, 'test', function (err, newPerson) {
|
|
64
|
+
|
|
65
|
+
should.not.exist(err);
|
|
66
|
+
should.exist(newPerson);
|
|
67
|
+
|
|
68
|
+
person1 = newPerson;
|
|
69
|
+
|
|
70
|
+
return done();
|
|
71
|
+
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
before(function(done) {
|
|
77
|
+
|
|
78
|
+
person2 = new Person();
|
|
79
|
+
person2.name.first = 'Carrie';
|
|
80
|
+
person2.name.last = 'Coon';
|
|
81
|
+
person2.slug = 'carrie-coon';
|
|
82
|
+
|
|
83
|
+
Person.upsert(person2, 'test', function (err, newPerson) {
|
|
84
|
+
|
|
85
|
+
should.not.exist(err);
|
|
86
|
+
should.exist(newPerson);
|
|
87
|
+
|
|
88
|
+
person2 = newPerson;
|
|
89
|
+
|
|
90
|
+
return done();
|
|
91
|
+
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
before(function(done) {
|
|
97
|
+
|
|
98
|
+
person = new Person();
|
|
99
|
+
person.name.first = 'George';
|
|
100
|
+
person.name.last = 'Costanza';
|
|
101
|
+
person.slug = 'george';
|
|
102
|
+
person.avatarUrl = 'tiger.jpg';
|
|
103
|
+
|
|
104
|
+
Person.upsert(person, 'test', function (err, newPerson) {
|
|
105
|
+
|
|
106
|
+
person = newPerson;
|
|
107
|
+
|
|
108
|
+
return done();
|
|
109
|
+
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('adds a limited partner', function(done) {
|
|
115
|
+
|
|
116
|
+
lp.name = 'United Testers';
|
|
117
|
+
lp.customer = organization;
|
|
118
|
+
|
|
119
|
+
lp.fundsInvested.push({
|
|
120
|
+
fund: fund,
|
|
121
|
+
committed: 1000000,
|
|
122
|
+
called: 400000
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
lp.contact.phone.push({
|
|
126
|
+
type: 'other',
|
|
127
|
+
number: '12079396565',
|
|
128
|
+
primary: true
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
lp.contact.email.push({
|
|
132
|
+
type: 'other',
|
|
133
|
+
email: 'dhyasama+test@gmail.com',
|
|
134
|
+
primary: true
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
lp.contact.address.push({
|
|
138
|
+
street: '121 Union St',
|
|
139
|
+
city: 'Brewer',
|
|
140
|
+
state: 'ME',
|
|
141
|
+
country: 'USA',
|
|
142
|
+
postalCode: '04412',
|
|
143
|
+
primary: true
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
LimitedPartner.upsert(lp, 'test', { CUSTOMER_ID: organization._id, role: 'admin' }, function(err, updatedLp) {
|
|
147
|
+
should.not.exist(err);
|
|
148
|
+
should.exist(updatedLp);
|
|
149
|
+
lp = updatedLp;
|
|
150
|
+
done();
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('searches for an lp', function(done) {
|
|
156
|
+
|
|
157
|
+
LimitedPartner.search('United', { CUSTOMER_ID: organization._id, role: 'admin' }, function(err, result) {
|
|
158
|
+
|
|
159
|
+
should.not.exist(err);
|
|
160
|
+
should.exist(result);
|
|
161
|
+
|
|
162
|
+
result.length.should.equal(1);
|
|
163
|
+
done();
|
|
164
|
+
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('searches for an lp without the rights', function(done) {
|
|
170
|
+
|
|
171
|
+
LimitedPartner.search('United', { CUSTOMER_ID: organization._id, role: 'none' }, function(err, result) {
|
|
172
|
+
|
|
173
|
+
should.not.exist(err);
|
|
174
|
+
should.exist(result);
|
|
175
|
+
|
|
176
|
+
result.length.should.equal(0);
|
|
177
|
+
done();
|
|
178
|
+
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('searches for an lp of different customer', function(done) {
|
|
184
|
+
|
|
185
|
+
LimitedPartner.search('United', { CUSTOMER_ID: new mongoose.Types.ObjectId(), role: 'admin' }, function(err, result) {
|
|
186
|
+
|
|
187
|
+
should.not.exist(err);
|
|
188
|
+
should.exist(result);
|
|
189
|
+
|
|
190
|
+
result.length.should.equal(0);
|
|
191
|
+
done();
|
|
192
|
+
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('updates a limited partner', function(done) {
|
|
198
|
+
|
|
199
|
+
LimitedPartner.getById(lp._id, { CUSTOMER_ID: organization._id, role: 'admin' }, function(err, result) {
|
|
200
|
+
|
|
201
|
+
should.not.exist(err);
|
|
202
|
+
should.exist(result);
|
|
203
|
+
lp.name = 'Changed Name';
|
|
204
|
+
|
|
205
|
+
LimitedPartner.upsert(result, 'test', { CUSTOMER_ID: organization._id, role: 'admin' }, function(err, updatedLp) {
|
|
206
|
+
should.not.exist(err);
|
|
207
|
+
should.exist(updatedLp);
|
|
208
|
+
lp.name.should.equal('Changed Name');
|
|
209
|
+
lp = updatedLp;
|
|
210
|
+
done();
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('adds a person to an lp', function(done) {
|
|
218
|
+
|
|
219
|
+
LimitedPartner.getById(lp.id, { CUSTOMER_ID: organization._id, role: 'admin' }, function(err, result) {
|
|
220
|
+
|
|
221
|
+
result.addPerson(person.id);
|
|
222
|
+
|
|
223
|
+
LimitedPartner.upsert(result, 'test', { CUSTOMER_ID: organization._id, role: 'admin' }, function(err, updatedLp) {
|
|
224
|
+
should.not.exist(err);
|
|
225
|
+
should.exist(updatedLp);
|
|
226
|
+
updatedLp.people.length.should.equal(1);
|
|
227
|
+
done();
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it('tries to add a person to an lp again', function(done) {
|
|
235
|
+
|
|
236
|
+
// must be a better way to do this
|
|
237
|
+
// successful test means addPerson throws an error
|
|
238
|
+
// if the should in the try is hit then the test fails
|
|
239
|
+
|
|
240
|
+
try {
|
|
241
|
+
lp.addPerson(person.id);
|
|
242
|
+
should.exist(e);
|
|
243
|
+
}
|
|
244
|
+
catch(e) {
|
|
245
|
+
should.exist(e);
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
done();
|
|
249
|
+
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it('finds limited partners by person id', function(done) {
|
|
253
|
+
LimitedPartner.getByPersonId(person._id, { CUSTOMER_ID: organization._id, role: 'lp-full' }, function(err, result) {
|
|
254
|
+
should.not.exist(err);
|
|
255
|
+
should.exist(result);
|
|
256
|
+
result.length.should.equal(1);
|
|
257
|
+
done();
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it('finds a limited partner by id', function(done) {
|
|
262
|
+
LimitedPartner.getById(lp.id, { CUSTOMER_ID: organization._id, role: 'admin' }, function(err, result) {
|
|
263
|
+
should.not.exist(err);
|
|
264
|
+
should.exist(result);
|
|
265
|
+
result.id.should.equal(lp.id);
|
|
266
|
+
done();
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it('adds a note', function(done) {
|
|
271
|
+
|
|
272
|
+
LimitedPartner.addNote(lp.id, person._id, 'Sweet note bro!', false, organization._id, function(err, result) {
|
|
273
|
+
|
|
274
|
+
should.not.exist(err);
|
|
275
|
+
should.exist(result);
|
|
276
|
+
should.exist(result.note);
|
|
277
|
+
should.exist(result.addedTo);
|
|
278
|
+
result.addedTo.notes.length.should.equal(1);
|
|
279
|
+
|
|
280
|
+
noteId = result.addedTo.notes[0];
|
|
281
|
+
|
|
282
|
+
return done();
|
|
283
|
+
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it('gets an lp by id with a populated note', function(done) {
|
|
289
|
+
|
|
290
|
+
LimitedPartner.getById(lp.id, { CUSTOMER_ID: organization._id, role: 'admin' }, function(err, result) {
|
|
291
|
+
|
|
292
|
+
should.not.exist(err);
|
|
293
|
+
should.exist(result);
|
|
294
|
+
|
|
295
|
+
result.id.should.equal(lp.id);
|
|
296
|
+
|
|
297
|
+
should.exist(result.notes);
|
|
298
|
+
result.notes.length.should.equal(1);
|
|
299
|
+
should.exist(result.notes[0].createdBy);
|
|
300
|
+
should.exist(result.notes[0].createdBy.avatarUrl);
|
|
301
|
+
result.notes[0].createdBy.avatarUrl.length.should.be.above(0);
|
|
302
|
+
should.exist(result.notes[0].createdBy.name);
|
|
303
|
+
should.exist(result.notes[0].createdBy.name.first);
|
|
304
|
+
result.notes[0].createdBy.name.first.length.should.be.above(0);
|
|
305
|
+
|
|
306
|
+
done();
|
|
307
|
+
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('deletes a note', function(done) {
|
|
313
|
+
|
|
314
|
+
LimitedPartner.deleteNote(noteId, organization._id, function(err, result) {
|
|
315
|
+
|
|
316
|
+
should.not.exist(err);
|
|
317
|
+
|
|
318
|
+
return done();
|
|
319
|
+
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it('finds the primary email for an lp', function(done) {
|
|
325
|
+
|
|
326
|
+
LimitedPartner.getById(lp.id, { CUSTOMER_ID: organization._id, role: 'admin' }, function(err, partner) {
|
|
327
|
+
|
|
328
|
+
should.not.exist(err);
|
|
329
|
+
should.exist(partner);
|
|
330
|
+
|
|
331
|
+
partner.email.primary.should.equal('dhyasama+test@gmail.com');
|
|
332
|
+
|
|
333
|
+
done();
|
|
334
|
+
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it('finds the primary phone for an lp', function(done) {
|
|
340
|
+
|
|
341
|
+
LimitedPartner.getById(lp.id, { CUSTOMER_ID: organization._id, role: 'admin' }, function(err, lp) {
|
|
342
|
+
|
|
343
|
+
should.not.exist(err);
|
|
344
|
+
should.exist(lp);
|
|
345
|
+
|
|
346
|
+
lp.phone.primary.should.equal('12079396565');
|
|
347
|
+
|
|
348
|
+
done();
|
|
349
|
+
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
it('finds the primary address for an lp', function(done) {
|
|
355
|
+
|
|
356
|
+
LimitedPartner.getById(lp.id, { CUSTOMER_ID: organization._id, role: 'admin' }, function(err, lp) {
|
|
357
|
+
|
|
358
|
+
should.not.exist(err);
|
|
359
|
+
should.exist(lp);
|
|
360
|
+
|
|
361
|
+
lp.address.primary.postalCode.should.equal('04412');
|
|
362
|
+
|
|
363
|
+
done();
|
|
364
|
+
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it('finds name for an lp if allowed', function(done) {
|
|
370
|
+
|
|
371
|
+
LimitedPartner.getById(lp.id, { CUSTOMER_ID: organization._id, role: 'lp-names' }, function(err, lp) {
|
|
372
|
+
|
|
373
|
+
should.not.exist(err);
|
|
374
|
+
should.exist(lp);
|
|
375
|
+
should.exist(lp.name);
|
|
376
|
+
|
|
377
|
+
done();
|
|
378
|
+
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
it('adds a flag', function(done) {
|
|
384
|
+
|
|
385
|
+
LimitedPartner.addFlag(lp.id, person._id, 'incorrect phone', organization._id, function(err, result) {
|
|
386
|
+
|
|
387
|
+
should.not.exist(err);
|
|
388
|
+
should.exist(result);
|
|
389
|
+
should.exist(result.flag);
|
|
390
|
+
should.exist(result.addedTo);
|
|
391
|
+
result.addedTo.flags.length.should.equal(1);
|
|
392
|
+
|
|
393
|
+
done();
|
|
394
|
+
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
});
|