@dhyasama/totem-models 1.0.0 → 1.6.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/index.js +18 -6
- package/lib/Account.js +13 -58
- package/lib/CapTable.js +397 -0
- package/lib/Fund.js +56 -12
- package/lib/Investment.js +143 -0
- package/lib/LimitedPartner.js +0 -50
- package/lib/List.js +1 -2
- package/lib/News.js +8 -61
- package/lib/Organization.js +520 -504
- package/lib/Person.js +49 -94
- package/lib/Round.js +805 -0
- package/package.json +4 -3
- package/test/CapTable.js +359 -0
- package/test/Investment.js +180 -0
- package/test/News.js +20 -46
- package/test/Organization.js +100 -30
- package/test/Person.js +0 -48
- package/test/Round.js +684 -0
package/test/Organization.js
CHANGED
|
@@ -28,6 +28,15 @@ describe('Organization', function() {
|
|
|
28
28
|
clearDB(done);
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
+
before(function (done) {
|
|
32
|
+
Organization.collection.dropIndexes(function (err, result) {
|
|
33
|
+
should.not.exist(err);
|
|
34
|
+
should.exist(result);
|
|
35
|
+
result.should.equal(true);
|
|
36
|
+
return done();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
31
40
|
before(function (done) {
|
|
32
41
|
|
|
33
42
|
org2 = new Organization();
|
|
@@ -36,7 +45,6 @@ describe('Organization', function() {
|
|
|
36
45
|
org2.website = 'nothanks2.org';
|
|
37
46
|
org2.websiteAliases = [ 'myolddomain.tld' ];
|
|
38
47
|
org2.related = [];
|
|
39
|
-
//org2.investedIn = ['123', '456'];
|
|
40
48
|
org2.aliases.push('NT2');
|
|
41
49
|
org2.crunchbase.uuid = 'abc';
|
|
42
50
|
org2.crunchbase.url = 'abc';
|
|
@@ -212,6 +220,47 @@ describe('Organization', function() {
|
|
|
212
220
|
|
|
213
221
|
});
|
|
214
222
|
|
|
223
|
+
before(function(done) {
|
|
224
|
+
|
|
225
|
+
org3.people.push({
|
|
226
|
+
person: person2.id,
|
|
227
|
+
current: true,
|
|
228
|
+
board: 'director'
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
org3.people.push({
|
|
232
|
+
person: person1.id,
|
|
233
|
+
current: true,
|
|
234
|
+
board: 'chairman'
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
Organization.upsert(org3, 'test-user', function(err, result) {
|
|
238
|
+
should.not.exist(err);
|
|
239
|
+
should.exist(result);
|
|
240
|
+
result.people.length.should.equal(2);
|
|
241
|
+
org3 = result;
|
|
242
|
+
done();
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
before(function(done) {
|
|
248
|
+
|
|
249
|
+
org2.chairs.push({
|
|
250
|
+
first: person2.id,
|
|
251
|
+
customer: org1
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
Organization.upsert(org2, 'test-user', function(err, result) {
|
|
255
|
+
should.not.exist(err);
|
|
256
|
+
should.exist(result);
|
|
257
|
+
result.chairs.length.should.equal(1);
|
|
258
|
+
org2 = result;
|
|
259
|
+
done();
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
});
|
|
263
|
+
|
|
215
264
|
it('it soft deletes an org', function(done) {
|
|
216
265
|
|
|
217
266
|
org4.deleteOrg();
|
|
@@ -262,32 +311,6 @@ describe('Organization', function() {
|
|
|
262
311
|
});
|
|
263
312
|
}); // end adds an org
|
|
264
313
|
|
|
265
|
-
it('adds a basic field to org', function(done) {
|
|
266
|
-
|
|
267
|
-
org1.newBasic('slug', 'org1-slug');
|
|
268
|
-
|
|
269
|
-
Organization.upsert(org1, 'test-user', function(err, org) {
|
|
270
|
-
should.not.exist(err);
|
|
271
|
-
should.exist(org);
|
|
272
|
-
org.slug.should.equal('org1-slug');
|
|
273
|
-
org1 = org;
|
|
274
|
-
done();
|
|
275
|
-
});
|
|
276
|
-
}); // end adds a basic field
|
|
277
|
-
|
|
278
|
-
it('updates a basic field on org', function(done) {
|
|
279
|
-
|
|
280
|
-
org1.updateBasic('website', 'updatedorg1.com');
|
|
281
|
-
|
|
282
|
-
Organization.upsert(org1, 'test-user', function(err, org) {
|
|
283
|
-
should.not.exist(err);
|
|
284
|
-
should.exist(org);
|
|
285
|
-
org.website.should.equal('updatedorg1.com');
|
|
286
|
-
org1 = org;
|
|
287
|
-
done();
|
|
288
|
-
});
|
|
289
|
-
}); // end update a basic field
|
|
290
|
-
|
|
291
314
|
it('finds a fuzzy match by name', function(done) {
|
|
292
315
|
|
|
293
316
|
Organization.search({
|
|
@@ -436,7 +459,6 @@ describe('Organization', function() {
|
|
|
436
459
|
Organization.findBySlug('org2-slug', function(err, org) {
|
|
437
460
|
should.not.exist(err);
|
|
438
461
|
should.exist(org);
|
|
439
|
-
org.length.should.equal(1);
|
|
440
462
|
done();
|
|
441
463
|
});
|
|
442
464
|
|
|
@@ -444,7 +466,7 @@ describe('Organization', function() {
|
|
|
444
466
|
|
|
445
467
|
it('finds org by slugs', function(done) {
|
|
446
468
|
|
|
447
|
-
Organization.findBySlugs(['
|
|
469
|
+
Organization.findBySlugs(['fudge-3', 'org2-slug'], function(err, orgs) {
|
|
448
470
|
should.not.exist(err);
|
|
449
471
|
should.exist(orgs);
|
|
450
472
|
orgs.length.should.equal(2);
|
|
@@ -472,7 +494,6 @@ describe('Organization', function() {
|
|
|
472
494
|
should.exist(org);
|
|
473
495
|
org1 = org;
|
|
474
496
|
org1.id.should.equal(org.id);
|
|
475
|
-
org1.sources.length.should.equal(1);
|
|
476
497
|
return done();
|
|
477
498
|
});
|
|
478
499
|
|
|
@@ -519,6 +540,40 @@ describe('Organization', function() {
|
|
|
519
540
|
|
|
520
541
|
});
|
|
521
542
|
|
|
543
|
+
it('finds boards of a person', function(done) {
|
|
544
|
+
|
|
545
|
+
Organization.getBoardsOfPerson(person2.id, function(err, result) {
|
|
546
|
+
should.not.exist(err);
|
|
547
|
+
should.exist(result);
|
|
548
|
+
result.length.should.equal(1);
|
|
549
|
+
done();
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
it('finds chairs of a person', function(done) {
|
|
555
|
+
|
|
556
|
+
Organization.getChairsOfPerson(person2.id, function(err, result) {
|
|
557
|
+
should.not.exist(err);
|
|
558
|
+
should.exist(result);
|
|
559
|
+
result.length.should.equal(1);
|
|
560
|
+
done();
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
it('gets the board of a company', function(done) {
|
|
566
|
+
|
|
567
|
+
Organization.getById(org3.id, function(err, result) {
|
|
568
|
+
should.not.exist(err);
|
|
569
|
+
should.exist(result);
|
|
570
|
+
var board = result.board;
|
|
571
|
+
board.all.length.should.equal(2);
|
|
572
|
+
done();
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
});
|
|
576
|
+
|
|
522
577
|
it('removes a person from people (unpopulated)', function(done) {
|
|
523
578
|
|
|
524
579
|
// remove person
|
|
@@ -617,6 +672,15 @@ describe('Organization', function() {
|
|
|
617
672
|
});
|
|
618
673
|
});
|
|
619
674
|
|
|
675
|
+
it('finds orgs by ids', function(done) {
|
|
676
|
+
Organization.findByIds([org4._id, org5._id], function(err, result) {
|
|
677
|
+
should.not.exist(err);
|
|
678
|
+
should.exist(result);
|
|
679
|
+
result.length.should.equal(2);
|
|
680
|
+
return done();
|
|
681
|
+
});
|
|
682
|
+
});
|
|
683
|
+
|
|
620
684
|
it('finds org by domain alias', function(done) {
|
|
621
685
|
Organization.findByDomains(['doesnotexist.io', 'myolddomain.tld'], function(err, result) {
|
|
622
686
|
should.not.exist(err);
|
|
@@ -716,6 +780,12 @@ describe('Organization', function() {
|
|
|
716
780
|
|
|
717
781
|
});
|
|
718
782
|
|
|
783
|
+
// not yet tested:
|
|
784
|
+
// listAllFlagged
|
|
785
|
+
// listPage
|
|
786
|
+
// removeById
|
|
787
|
+
// stats
|
|
788
|
+
|
|
719
789
|
// it('does not duplicate website domains with investors', function(done) {
|
|
720
790
|
//
|
|
721
791
|
// var investor = new Investor();
|
package/test/Person.js
CHANGED
|
@@ -699,33 +699,6 @@ describe('Person', function() {
|
|
|
699
699
|
|
|
700
700
|
});
|
|
701
701
|
|
|
702
|
-
it('finds a person by id and customer', function(done) {
|
|
703
|
-
|
|
704
|
-
Person.getByIdCustomer(person.id, config.CUSTOMER_ID, function(err, person) {
|
|
705
|
-
should.not.exist(err);
|
|
706
|
-
should.exist(person);
|
|
707
|
-
done();
|
|
708
|
-
});
|
|
709
|
-
|
|
710
|
-
});
|
|
711
|
-
|
|
712
|
-
it('finds a person by id and customer with a populated event note', function(done) {
|
|
713
|
-
|
|
714
|
-
Person.getByIdCustomer(person4.id, config.CUSTOMER_ID, function(err, person) {
|
|
715
|
-
should.not.exist(err);
|
|
716
|
-
should.exist(person);
|
|
717
|
-
should.exist(person.calendarEventSummaries);
|
|
718
|
-
person.calendarEventSummaries.length.should.equal(1);
|
|
719
|
-
should.exist(person.calendarEventSummaries[0].notes);
|
|
720
|
-
person.calendarEventSummaries[0].notes.length.should.equal(1);
|
|
721
|
-
should.exist(person.calendarEventSummaries[0].notes[0].createdBy);
|
|
722
|
-
|
|
723
|
-
return done();
|
|
724
|
-
|
|
725
|
-
});
|
|
726
|
-
|
|
727
|
-
});
|
|
728
|
-
|
|
729
702
|
it('finds a person by id and populates', function(done) {
|
|
730
703
|
|
|
731
704
|
Person.getById(person5.id, function(err, person) {
|
|
@@ -848,27 +821,6 @@ describe('Person', function() {
|
|
|
848
821
|
|
|
849
822
|
});
|
|
850
823
|
|
|
851
|
-
it('finds a person by id and customer with a populated note', function(done) {
|
|
852
|
-
|
|
853
|
-
Person.getByIdCustomer(person2.id, config.CUSTOMER_ID, function(err, person) {
|
|
854
|
-
|
|
855
|
-
should.not.exist(err);
|
|
856
|
-
should.exist(person);
|
|
857
|
-
should.exist(person.notes);
|
|
858
|
-
person.notes.length.should.equal(1);
|
|
859
|
-
should.exist(person.notes[0].createdBy);
|
|
860
|
-
should.exist(person.notes[0].createdBy.avatarUrl);
|
|
861
|
-
person.notes[0].createdBy.avatarUrl.length.should.be.above(0);
|
|
862
|
-
should.exist(person.notes[0].createdBy.name);
|
|
863
|
-
should.exist(person.notes[0].createdBy.name.first);
|
|
864
|
-
person.notes[0].createdBy.name.first.length.should.be.above(0);
|
|
865
|
-
|
|
866
|
-
return done();
|
|
867
|
-
|
|
868
|
-
});
|
|
869
|
-
|
|
870
|
-
});
|
|
871
|
-
|
|
872
824
|
it('deletes a simple note', function(done) {
|
|
873
825
|
|
|
874
826
|
Person.deleteNote(noteId, function(err, result) {
|