test/core/Root.js   A
last analyzed

Complexity

Total Complexity 10
Complexity/F 1

Size

Lines of Code 749
Function Count 10

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 749
rs 9.7391
wmc 10
mnd 0
bc 10
fnc 10
bpm 1
cpm 1
noi 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
B Root.js ➔ describe(ꞌRootꞌ) 0 627 1
B Root.js ➔ tests 0 113 1
1
var chai = require('chai');
2
chai.use(require('chai-json-schema'));
3
chai.tv4.banUnknown = true;
4
5
var assert = chai.assert,
6
    GedcomXSchema = require('gedcomx-json-schema'),
7
    GedcomX = require('../../');
8
9
describe('Root', function(){
10
  
11
  var fullJSON = {
12
    id: 'gedcomx',
13
    lang: 'en',
14
    description: '#sd1',
15
    attribution: { 
16
      changeMessage: 'It changed',
17
      contributor: { resource: 'https://myapp.com/contributor'},
18
      created: 1111338494969,
19
      creator: { resource: 'https://myapp.com/creator'},
20
      modified: 1111338494969
21
    },
22
    persons: [
23
      {
24
        private: false,
25
        gender: {
26
          type: 'http://gedcomx.org/Female'
27
        },
28
        names: [
29
          {
30
            type: 'http://gedcomx.org/BirthName',
31
            nameForms: [
32
              {
33
                fullText: 'Joanna Hopkins'
34
              }
35
            ]
36
          }  
37
        ],
38
        facts: [
39
          {
40
            type: 'http://gedcomx.org/Birth',
41
            date: {
42
              formal: '+2001-04-09'
43
            },
44
            place: {
45
              original: 'Farm house'
46
            }
47
          }  
48
        ]
49
      } 
50
    ],
51
    relationships: [
52
      {
53
        type: 'http://gedcomx.org/Couple',
54
        person1: {
55
          resource: 'http://identifier/for/person/1'
56
        },
57
        person2: {
58
          resource: 'http://identifier/for/person/2'
59
        },
60
        facts: [
61
          {
62
            type: 'http://gedcomx.org/Marriage'
63
          }
64
        ]
65
      }  
66
    ],
67
    sourceDescriptions: [
68
      {
69
        id: 'sd1',
70
        resourceType: 'http://some/type',
71
        citations: [
72
          {
73
            lang: 'en',
74
            value: 'Long source citation'
75
          }
76
        ],
77
        mediaType: 'book',
78
        about: 'http://a/resource',
79
        mediator: {
80
          resource: 'http://mediator'
81
        },
82
        sources: [
83
          {
84
            description: 'http://source/reference'
85
          }
86
        ],
87
        analysis: {
88
          resource: 'http://analysis'
89
        },
90
        componentOf: {
91
          description: 'http://container'
92
        },
93
        titles: [
94
          {
95
            lang: 'en',
96
            value: 'Title'
97
          },
98
          {
99
            lang: 'es',
100
            value: 'Titulo'
101
          }
102
        ],
103
        notes: [
104
          {
105
            subject: 'Note',
106
            text: 'Some note text'
107
          }
108
        ],
109
        attribution: {
110
          created: 1234578129
111
        },
112
        rights: [
113
          {
114
            resource: 'https://some/right'
115
          }
116
        ],
117
        coverage: [{
118
          temporal: {
119
            formal: '+2015'
120
          },
121
          spatial: {
122
            original: 'A place'
123
          }
124
        }],
125
        descriptions: [
126
          {
127
            value: 'A description'
128
          }
129
        ],
130
        identifiers: {
131
          $: 'identifier'
132
        },
133
        created: 1000000,
134
        modified: 11111111,
135
        repository: {
136
          resource: 'http://repository'
137
        }
138
      }
139
    ],
140
    agents: [
141
      {
142
        id: 'agent',
143
        identifiers: {
144
          $: 'ident'
145
        },
146
        names: [
147
          {
148
            lang: 'en',
149
            value: 'Name'
150
          }  
151
        ],
152
        homepage: {
153
          resource: 'http://homepage'
154
        },
155
        openid: {
156
          resource: 'http://openid'
157
        },
158
        accounts: [
159
          {
160
            accountName: 'jimbo'
161
          }  
162
        ],
163
        emails: [
164
          {
165
            resource: 'http://email'
166
          }  
167
        ],
168
        phones: [
169
          {
170
            resource: 'http://phone'
171
          }  
172
        ],
173
        addresses: [
174
          {
175
            value: 'big long address',
176
            postalCode: '123456'
177
          }  
178
        ],
179
        person: {
180
          resource: 'http://person'
181
        }
182
      }  
183
    ],
184
    events: [
185
      {
186
        type: 'http://gedcomx.org/Marriage',
187
        date: {
188
          formal: '+2002-06-06'
189
        },
190
        place: {
191
          original: 'Her town, MN'
192
        },
193
        roles: [
194
          {
195
            person: {
196
              resource: 'http://groom'
197
            },
198
            type: 'http://gedcomx.org/Participant'
199
          }
200
        ]
201
      }  
202
    ],
203
    documents: [
204
      {
205
        type: 'http://gedcomx.org/Abstract',
206
        extracted: false,
207
        textType: 'plain',
208
        text: 'Lots of text',
209
        attribution: {
210
          created: 123456789
211
        }
212
      }  
213
    ],
214
    places: [
215
      {
216
        names : [ 
217
          {
218
            lang : 'en',
219
            value : 'Pope\'s Creek, Westmoreland, Virginia, United States'
220
          }
221
        ],
222
        type : 'http://identifier/for/the/place/type',
223
        place : { resource : 'http://place' },
224
        jurisdiction : { resource : 'http://jurisdiction' },
225
        latitude : 27.9883575,
226
        longitude : 86.9252014,
227
        temporalDescription : { 
228
          formal: '+1899-01-04'
229
        },
230
        spatialDescription : {
231
          resource : 'http://uri/for/KML/document'
232
        }
233
      }
234
    ]
235
  };
236
  
237
  it('Create plain', function(){
238
    var newGedx = new GedcomX(),
239
        gedx = GedcomX();
240
    assert.instanceOf(newGedx, GedcomX.Root, 'An instance of GedcomX is not returned when calling the constructor with new.');
241
    assert.instanceOf(gedx, GedcomX.Root, 'An instance of GedcomX is not returned when calling the constructor without new.');
242
    assert.jsonSchema(newGedx.toJSON(), GedcomXSchema);
243
    assert.jsonSchema(gedx.toJSON(), GedcomXSchema);
244
  });
245
  
246
  it('Create with JSON', function(){
247
    var gedx = GedcomX(fullJSON);
248
    tests(gedx);
249
  });
250
  
251
  it('Create with mixed data', function(){
252
    var gedx = GedcomX({
253
      id: 'gedcomx',
254
      lang: 'en',
255
      description: '#sd1',
256
      attribution: GedcomX.Attribution({ 
257
        changeMessage: 'It changed',
258
        contributor: GedcomX.ResourceReference({ resource: 'https://myapp.com/contributor'}),
259
        created: new Date(1111338494969),
260
        creator: GedcomX.ResourceReference({ resource: 'https://myapp.com/creator'}),
261
        modified: new Date(1111338494969)
262
      }),
263
      persons: [
264
        GedcomX.Person({
265
          gender: {
266
            type: 'http://gedcomx.org/Female'
267
          },
268
          names: [
269
            {
270
              type: 'http://gedcomx.org/BirthName',
271
              nameForms: [
272
                {
273
                  fullText: 'Joanna Hopkins'
274
                }
275
              ]
276
            }  
277
          ],
278
          facts: [
279
            {
280
              type: 'http://gedcomx.org/Birth',
281
              date: {
282
                formal: '+2001-04-09'
283
              },
284
              place: {
285
                original: 'Farm house'
286
              }
287
            }  
288
          ]
289
        })
290
      ],
291
      relationships: [
292
        GedcomX.Relationship({
293
          type: 'http://gedcomx.org/Couple',
294
          person1: {
295
            resource: 'http://identifier/for/person/1'
296
          },
297
          person2: {
298
            resource: 'http://identifier/for/person/2'
299
          },
300
          facts: [
301
            GedcomX.Fact({
302
              type: 'http://gedcomx.org/Marriage'
303
            })
304
          ]
305
        })  
306
      ],
307
      sourceDescriptions: [
308
        GedcomX.SourceDescription({
309
          id: 'sd1',
310
          resourceType: 'http://some/type',
311
          citations: [
312
            GedcomX.SourceCitation({
313
              lang: 'en',
314
              value: 'Long source citation'
315
            })
316
          ],
317
          mediaType: 'book',
318
          about: 'http://a/resource',
319
          mediator: {
320
            resource: 'http://mediator'
321
          },
322
          sources: [
323
            GedcomX.SourceReference({
324
              description: 'http://source/reference'
325
            })
326
          ],
327
          analysis: {
328
            resource: 'http://analysis'
329
          },
330
          componentOf: {
331
            description: 'http://container'
332
          },
333
          titles: [
334
            GedcomX.TextValue({
335
              lang: 'en',
336
              value: 'Title'
337
            }),
338
            {
339
              lang: 'es',
340
              value: 'Titulo'
341
            }
342
          ],
343
          notes: [
344
            GedcomX.Note({
345
              subject: 'Note',
346
              text: 'Some note text'
347
            })
348
          ],
349
          attribution: {
350
            created: 1234578129
351
          },
352
          rights: [
353
            GedcomX.ResourceReference({
354
              resource: 'https://some/right'
355
            })
356
          ],
357
          coverage: [GedcomX.Coverage({
358
            temporal: {
359
              formal: '+2015'
360
            },
361
            spatial: {
362
              original: 'A place'
363
            }
364
          })],
365
          descriptions: [
366
            {
367
              value: 'A description'
368
            }
369
          ],
370
          identifiers: {
371
            $: 'identifier'
372
          },
373
          created: 1000000,
374
          modified: 11111111,
375
          repository: GedcomX.ResourceReference({
376
            resource: 'http://repository'
377
          })
378
        })  
379
      ],
380
      agents: [
381
        GedcomX.Agent({
382
          id: 'agent',
383
          identifiers: GedcomX.Identifiers({
384
            $: 'ident'
385
          }),
386
          names: [
387
            GedcomX.TextValue({
388
              lang: 'en',
389
              value: 'Name'
390
            })
391
          ],
392
          homepage: GedcomX.ResourceReference({
393
            resource: 'http://homepage'
394
          }),
395
          openid: GedcomX.ResourceReference({
396
            resource: 'http://openid'
397
          }),
398
          accounts: [
399
            GedcomX.OnlineAccount({
400
              accountName: 'jimbo'
401
            })
402
          ],
403
          emails: [
404
            GedcomX.ResourceReference({
405
              resource: 'http://email'
406
            })
407
          ],
408
          phones: [
409
            GedcomX.ResourceReference({
410
              resource: 'http://phone'
411
            })
412
          ],
413
          addresses: [
414
            GedcomX.Address({
415
              value: 'big long address',
416
              postalCode: '123456'
417
            })
418
          ],
419
          person: GedcomX.ResourceReference({
420
            resource: 'http://person'
421
          })
422
        })  
423
      ],
424
      events: [
425
        GedcomX.Event({
426
          type: 'http://gedcomx.org/Marriage',
427
          date: GedcomX.Date({
428
            formal: '+2002-06-06'
429
          }),
430
          place: GedcomX.PlaceReference({
431
            original: 'Her town, MN'
432
          }),
433
          roles: [
434
            GedcomX.EventRole({
435
              person: {
436
                resource: 'http://groom'
437
              },
438
              type: 'http://gedcomx.org/Participant'
439
            })
440
          ]
441
        })  
442
      ],
443
      documents: [
444
        GedcomX.Document({
445
          type: 'http://gedcomx.org/Abstract',
446
          extracted: false,
447
          textType: 'plain',
448
          text: 'Lots of text',
449
          attribution: GedcomX.Attribution({
450
            created: 123456789
451
          })
452
        })
453
      ],
454
      places: [
455
        GedcomX.PlaceDescription({
456
          names : [ 
457
            GedcomX.TextValue({
458
              lang : 'en',
459
              value : 'Pope\'s Creek, Westmoreland, Virginia, United States'
460
            })
461
          ],
462
          type : 'http://identifier/for/the/place/type',
463
          place : GedcomX.ResourceReference({ resource : 'http://place' }),
464
          jurisdiction : GedcomX.ResourceReference({ resource : 'http://jurisdiction' }),
465
          latitude : 27.9883575,
466
          longitude : 86.9252014,
467
          temporalDescription : GedcomX.Date({ 
468
            formal: '+1899-01-04'
469
          }),
470
          spatialDescription : GedcomX.ResourceReference({
471
            resource : 'http://uri/for/KML/document'
472
          })
473
        })  
474
      ]
475
    });
476
    
477
    tests(gedx);
478
  });
479
  
480
  it('Build', function(){
481
    var gedx = GedcomX()
482
      .setId('gedcomx')
483
      .setLang('en')
484
      .setDescription('#sd1')
485
      .setAttribution(GedcomX.Attribution()
486
        .setChangeMessage('It changed')
487
        .setContributor({ resource: 'https://myapp.com/contributor'})
488
        .setCreated(1111338494969)
489
        .setCreator({ resource: 'https://myapp.com/creator'})
490
        .setModified(1111338494969))
491
      .addPerson(
492
        GedcomX.Person()
493
          .setId('testPerson')
494
          .setPrivate(true)
495
          .setGender(GedcomX.Gender().setType('http://gedcomx.org/Female'))
496
          .addName(GedcomX.Name().addNameForm(GedcomX.NameForm().setFullText('Joanna Hopkins')))
497
          .addFact(GedcomX.Fact().setDate(GedcomX.Date().setFormal('+2001-04-09')).setPlace(GedcomX.PlaceReference().setOriginal('Farm house')))
498
      )
499
      .addRelationship(
500
        GedcomX.Relationship()
501
          .setType('http://gedcomx.org/Couple')
502
          .setPerson1(GedcomX.ResourceReference().setResource('http://identifier/for/person/1'))
503
          .setPerson2(GedcomX.ResourceReference().setResource('http://identifier/for/person/2'))
504
          .addFact(GedcomX.Fact().setType('http://gedcomx.org/Marriage'))  
505
      )
506
      .addSourceDescription(
507
        GedcomX.SourceDescription()
508
          .setId('sd1')
509
          .setResourceType('http://some/type')
510
          .addCitation(GedcomX.SourceCitation().setLang('en').setValue('Long source citation'))
511
          .setMediaType('book')
512
          .setAbout('http://a/resource')
513
          .setMediator(GedcomX.ResourceReference().setResource('http://mediator'))
514
          .addSource(GedcomX.SourceReference().setDescription('http://source/reference'))
515
          .setAnalysis(GedcomX.ResourceReference().setResource('http://analysis'))
516
          .setComponentOf(GedcomX.SourceReference().setDescription('http://container'))
517
          .addTitle(GedcomX.TextValue().setLang('en').setValue('Title'))
518
          .addTitle(GedcomX.TextValue().setLang('es').setValue('Titulo'))
519
          .addNote(GedcomX.Note().setSubject('Note').setText('Some note text'))
520
          .setAttribution(GedcomX.Attribution().setCreated(1234578129))
521
          .addRight(GedcomX.ResourceReference().setResource('https://some/right'))
522
          .addCoverage(
523
            GedcomX.Coverage()
524
              .setTemporal(GedcomX.Date().setFormal('+2015'))
525
              .setSpatial(GedcomX.PlaceReference().setOriginal('A place'))
526
          )
527
          .addDescription(GedcomX.TextValue().setValue('A description'))
528
          .setIdentifiers(GedcomX.Identifiers({
529
            $: 'identifier'
530
          }))
531
          .setCreated(1000000)
532
          .setModified(11111111)
533
          .setRepository(GedcomX.ResourceReference().setResource('http://repository'))  
534
      )
535
      .addAgent(
536
        GedcomX.Agent()
537
          .setId('agent')
538
          .setIdentifiers(GedcomX.Identifiers({$:'ident'}))
539
          .addName(GedcomX.TextValue().setLang('en').setValue('Name'))
540
          .setHomepage(GedcomX.ResourceReference().setResource('http://homepage'))
541
          .setOpenid(GedcomX.ResourceReference().setResource('http://openid'))
542
          .addAccount(GedcomX.OnlineAccount().setAccountName('jimbo'))
543
          .addEmail(GedcomX.ResourceReference().setResource('http://email'))
544
          .addPhone(GedcomX.ResourceReference().setResource('http://phone'))
545
          .addAddress(GedcomX.Address().setValue('big long address').setPostalCode('123456'))
546
          .setPerson(GedcomX.ResourceReference().setResource('http://person'))  
547
      )
548
      .addEvent(
549
        GedcomX.Event()
550
          .setType('http://gedcomx.org/Marriage')
551
          .setDate(GedcomX.Date().setFormal('+2002-06-06'))
552
          .setPlace(GedcomX.PlaceReference().setOriginal('Her town, MN'))
553
          .addRole(GedcomX.EventRole()
554
            .setType('http://gedcomx.org/Participant')
555
            .setPerson(GedcomX.ResourceReference().setResource('http://groom')))  
556
      )
557
      .addDocument(
558
        GedcomX.Document()
559
        .setType('http://gedcomx.org/Abstract')
560
        .setExtracted(false)
561
        .setTextType('plain')
562
        .setText('Lots of text')
563
        .setAttribution(GedcomX.Attribution().setCreated(123456789))          
564
      )
565
      .addPlace(
566
        GedcomX.PlaceDescription()
567
          .addName(GedcomX.TextValue().setLang('en').setValue('Pope\'s Creek, Westmoreland, Virginia, United States'))
568
          .setType('http://identifier/for/the/place/type')
569
          .setPlace(GedcomX.ResourceReference({ resource : 'http://place' }))
570
          .setJurisdiction(GedcomX.ResourceReference({ resource : 'http://jurisdiction' }))
571
          .setLatitude(27.9883575)
572
          .setLongitude(86.9252014)
573
          .setTemporalDescription(GedcomX.Date({ 
574
            formal: '+1899-01-04'
575
          }))
576
          .setSpatialDescription(GedcomX.ResourceReference({
577
            resource : 'http://uri/for/KML/document'
578
          }))
579
      );
580
    
581
    tests(gedx);
582
  });
583
  
584
  it('toJSON', function(){
585
    var gedx = GedcomX(fullJSON);
586
    assert.deepEqual(gedx.toJSON(), fullJSON);
587
    assert.jsonSchema(gedx.toJSON(), GedcomXSchema);
588
  });
589
  
590
  it('constructor does not copy instances', function(){
591
    var obj1 = GedcomX();
592
    var obj2 = GedcomX(obj1);
593
    assert.strictEqual(obj1, obj2);
594
  });
595
  
596
  it('getPersonById', function(){
597
    var gedx = GedcomX({
598
      persons: [{
599
        id: 'personId'
600
      }]
601
    });
602
    assert.equal(gedx.getPersonById('personId').getId(), 'personId');
603
    assert.isUndefined(gedx.getPersonById('missing'));
604
  });
605
  
606
  it('relationship getters', function(){
607
    var gedx = GedcomX({
608
      persons: [
609
        {id: 'person'},
610
        {id: 'spouse'},
611
        {id: 'parent'},
612
        {id: 'child'}
613
      ],
614
      relationships: [
615
        {type: 'http://gedcomx.org/Couple', person1: {resource: '#person'}, person2: {resource: '#spouse'}},
616
        {type: 'http://gedcomx.org/ParentChild', person1: {resource: '#person'}, person2: {resource: '#child'}},
617
        {type: 'http://gedcomx.org/ParentChild', person1: {resource: '#parent'}, person2: {resource: '#person'}}
618
      ]
619
    });
620
    assert.equal(gedx.getPersonsRelationships('person').length, 3);
621
    assert.equal(gedx.getPersonsRelationships('missing').length, 0);
622
    assert.equal(gedx.getPersonsParentRelationships('person').length, 1);
623
    assert.equal(gedx.getPersonsParentRelationships('spouse').length, 0);
624
    assert.equal(gedx.getPersonsParents('person')[0].getId(), 'parent');
625
    assert.equal(gedx.getPersonsCoupleRelationships('person').length, 1);
626
    assert.equal(gedx.getPersonsCoupleRelationships('child').length, 0);
627
    assert.equal(gedx.getPersonsSpouses('person')[0].getId(), 'spouse');
628
    assert.equal(gedx.getPersonsSpouses('child').length, 0);
629
    assert.equal(gedx.getPersonsChildRelationships('person').length, 1);
630
    assert.equal(gedx.getPersonsChildRelationships('child').length, 0);
631
    assert.equal(gedx.getPersonsChildren('person')[0].getId(), 'child');
632
    assert.equal(gedx.getPersonsChildren('child').length, 0);
633
  });
634
  
635
});
636
637
function tests(gedx){
638
  assert.equal(gedx.getId(), 'gedcomx');
639
  assert.equal(gedx.getLang(), 'en');
640
  assert.equal(gedx.getDescription(), '#sd1');
641
  
642
  var attribution = gedx.getAttribution();
643
  assert.equal(attribution.getChangeMessage(), 'It changed', 'Change message not saved properly when created with JSON');
644
  assert.equal(attribution.getContributor().getResource(), 'https://myapp.com/contributor', 'Contributor not saved when created with JSON');
645
  assert.equal(attribution.getCreated().getTime(), 1111338494969, 'Created date not saved when created with JSON');
646
  assert.equal(attribution.getCreator().getResource(), 'https://myapp.com/creator', 'Creator not saved when created with JSON');
647
  assert.equal(attribution.getModified().getTime(), 1111338494969, 'Modified date not saved when created with JSON');
648
  
649
  assert.equal(gedx.getPersons().length, 1);
650
  var person = gedx.getPersons()[0];
651
  assert.equal(person.getGender().getType(), 'http://gedcomx.org/Female');
652
  assert.equal(person.getNames().length, 1);
653
  assert.equal(person.getFacts().length, 1);
654
  
655
  assert.equal(gedx.getRelationships().length, 1);
656
  var relationship = gedx.getRelationships()[0];
657
  assert.equal(relationship.getType(), 'http://gedcomx.org/Couple');
658
  assert.equal(relationship.getPerson1().getResource(), 'http://identifier/for/person/1');
659
  assert.equal(relationship.getPerson2().getResource(), 'http://identifier/for/person/2');
660
  assert.equal(relationship.getFacts().length, 1);
661
  assert.equal(relationship.getFacts()[0].getType(), 'http://gedcomx.org/Marriage');
662
  
663
  assert.equal(gedx.getSourceDescriptions().length, 1);
664
  var description = gedx.getSourceDescriptions()[0];
665
  assert.equal(description.getId(), 'sd1');
666
  assert.equal(description.getResourceType(), 'http://some/type');
667
  assert.equal(description.getCitations().length, 1);
668
  assert.equal(description.getCitations()[0].getLang(), 'en');
669
  assert.equal(description.getCitations()[0].getValue(), 'Long source citation');
670
  assert.equal(description.getMediaType(), 'book');
671
  assert.equal(description.getAbout(), 'http://a/resource');
672
  assert.equal(description.getMediator().getResource(), 'http://mediator');
673
  assert.equal(description.getSources().length, 1);
674
  assert.equal(description.getSources()[0].getDescription(), 'http://source/reference');
675
  assert.equal(description.getAnalysis().getResource(), 'http://analysis');
676
  assert.equal(description.getComponentOf().getDescription(), 'http://container');
677
  assert.equal(description.getTitles().length, 2);
678
  assert.equal(description.getTitles()[0].getLang(), 'en');
679
  assert.equal(description.getTitles()[0].getValue(), 'Title');
680
  assert.equal(description.getTitles()[1].getLang(), 'es');
681
  assert.equal(description.getTitles()[1].getValue(), 'Titulo');
682
  assert.equal(description.getNotes().length, 1);
683
  assert.equal(description.getNotes()[0].getSubject(), 'Note');
684
  assert.equal(description.getNotes()[0].getText(), 'Some note text');
685
  assert.equal(description.getAttribution().getCreated().getTime(), 1234578129);
686
  assert.equal(description.getRights().length, 1);
687
  assert.equal(description.getRights()[0].getResource(), 'https://some/right');
688
  assert.equal(description.getCoverage().length, 1);
689
  assert.equal(description.getCoverage()[0].getTemporal().getFormal(), '+2015');
690
  assert.equal(description.getCoverage()[0].getSpatial().getOriginal(), 'A place');
691
  assert.equal(description.getDescriptions().length, 1);
692
  assert.equal(description.getDescriptions()[0].getValue(), 'A description');
693
  assert.equal(description.getIdentifiers().identifiers.$, 'identifier');
694
  assert.equal(description.getCreated(), 1000000);
695
  assert.equal(description.getModified(), 11111111);
696
  assert.equal(description.getRepository().getResource(), 'http://repository');
697
  
698
  assert.equal(gedx.getAgents().length, 1);
699
  var agent = gedx.getAgents()[0];
700
  assert.equal(agent.getId(), 'agent');
701
  assert.equal(agent.getIdentifiers().identifiers.$, 'ident');
702
  assert.equal(agent.getNames().length, 1);
703
  assert.equal(agent.getNames()[0].getLang(), 'en');
704
  assert.equal(agent.getNames()[0].getValue(), 'Name');
705
  assert.equal(agent.getHomepage().getResource(), 'http://homepage');
706
  assert.equal(agent.getOpenid().getResource(), 'http://openid');
707
  assert.equal(agent.getAccounts().length, 1);
708
  assert.equal(agent.getAccounts()[0].getAccountName(), 'jimbo');
709
  assert.equal(agent.getEmails().length, 1);
710
  assert.equal(agent.getEmails()[0].getResource(), 'http://email');
711
  assert.equal(agent.getPhones().length, 1);
712
  assert.equal(agent.getPhones()[0].getResource(), 'http://phone');
713
  assert.equal(agent.getAddresses().length, 1);
714
  assert.equal(agent.getAddresses()[0].getValue(), 'big long address');
715
  assert.equal(agent.getAddresses()[0].getPostalCode(), '123456');
716
  assert.equal(agent.getPerson().getResource(), 'http://person');
717
  
718
  assert.equal(gedx.getEvents().length, 1);
719
  var event = gedx.getEvents()[0];
720
  assert.equal(event.getType(), 'http://gedcomx.org/Marriage');
721
  assert.equal(event.getDate().getFormal(), '+2002-06-06');
722
  assert.equal(event.getPlace().getOriginal(), 'Her town, MN');
723
  assert.equal(event.getRoles().length, 1);
724
  assert.equal(event.getRoles()[0].getPerson().getResource(), 'http://groom');
725
  assert.equal(event.getRoles()[0].getType(), 'http://gedcomx.org/Participant');
726
  
727
  assert.equal(gedx.getDocuments().length, 1);
728
  var doc = gedx.getDocuments()[0];
729
  assert.equal(doc.getType(), 'http://gedcomx.org/Abstract');
730
  assert.equal(doc.getExtracted(), false);
731
  assert.equal(doc.getTextType(), 'plain');
732
  assert.equal(doc.getText(), 'Lots of text');
733
  assert.equal(doc.getAttribution().getCreated().getTime(), 123456789);
734
  
735
  assert.equal(gedx.getPlaces().length, 1);
736
  var place = gedx.getPlaces()[0];
737
  assert.equal(place.getNames().length, 1);
738
  assert.equal(place.getNames()[0].getLang(), 'en');
739
  assert.equal(place.getNames()[0].getValue(), 'Pope\'s Creek, Westmoreland, Virginia, United States');
740
  assert.equal(place.getType(), 'http://identifier/for/the/place/type');
741
  assert.equal(place.getPlace().getResource(), 'http://place');
742
  assert.equal(place.getJurisdiction().getResource(), 'http://jurisdiction');
743
  assert.equal(place.getLatitude(), 27.9883575);
744
  assert.equal(place.getLongitude(), 86.9252014);
745
  assert.equal(place.getTemporalDescription().getFormal(), '+1899-01-04');
746
  assert.equal(place.getSpatialDescription().getResource(), 'http://uri/for/KML/document');
747
  
748
  assert.jsonSchema(gedx.toJSON(), GedcomXSchema);
749
}