1
|
|
|
var assert = require('chai').assert, |
2
|
|
|
GedcomX = require('../'); |
3
|
|
|
|
4
|
|
|
describe('EventRole', function(){ |
5
|
|
|
|
6
|
|
|
it('Create plain', function(){ |
7
|
|
|
assert.instanceOf(GedcomX.EventRole(), GedcomX.EventRole, 'An instance of EventRole is not returned when calling the constructor with new.'); |
8
|
|
|
assert.instanceOf(GedcomX.EventRole(), GedcomX.EventRole, 'An instance of EventRole is not returned when calling the constructor without new.'); |
9
|
|
|
}); |
10
|
|
|
|
11
|
|
|
it('Create with JSON', function(){ |
12
|
|
|
var role = GedcomX.EventRole({ |
13
|
|
|
person: { |
14
|
|
|
resource: 'http://person' |
15
|
|
|
}, |
16
|
|
|
type: 'http://gedcomx.org/Witness', |
17
|
|
|
details: 'One of two witnesses' |
18
|
|
|
}); |
19
|
|
|
assert.equal(role.getPerson().getResource(), 'http://person'); |
20
|
|
|
assert.equal(role.getType(), 'http://gedcomx.org/Witness'); |
21
|
|
|
assert.equal(role.getDetails(), 'One of two witnesses'); |
22
|
|
|
}); |
23
|
|
|
|
24
|
|
|
it('Create with mixed data', function(){ |
25
|
|
|
var role = GedcomX.EventRole({ |
26
|
|
|
person: GedcomX.ResourceReference({ |
27
|
|
|
resource: 'http://person' |
28
|
|
|
}), |
29
|
|
|
type: 'http://gedcomx.org/Witness', |
30
|
|
|
details: 'One of two witnesses' |
31
|
|
|
}); |
32
|
|
|
assert.equal(role.getPerson().getResource(), 'http://person'); |
33
|
|
|
assert.equal(role.getType(), 'http://gedcomx.org/Witness'); |
34
|
|
|
assert.equal(role.getDetails(), 'One of two witnesses'); |
35
|
|
|
}); |
36
|
|
|
|
37
|
|
|
it('Build', function(){ |
38
|
|
|
var role = GedcomX.EventRole() |
39
|
|
|
.setPerson(GedcomX.ResourceReference().setResource('http://person')) |
40
|
|
|
.setType('http://gedcomx.org/Witness') |
41
|
|
|
.setDetails('One of two witnesses'); |
42
|
|
|
assert.equal(role.getPerson().getResource(), 'http://person'); |
43
|
|
|
assert.equal(role.getType(), 'http://gedcomx.org/Witness'); |
44
|
|
|
assert.equal(role.getDetails(), 'One of two witnesses'); |
45
|
|
|
}); |
46
|
|
|
|
47
|
|
|
it('toJSON', function(){ |
48
|
|
|
var data = { |
49
|
|
|
person: { |
50
|
|
|
resource: 'http://person' |
51
|
|
|
}, |
52
|
|
|
type: 'http://gedcomx.org/Witness', |
53
|
|
|
details: 'One of two witnesses' |
54
|
|
|
}, role = GedcomX.EventRole(data); |
55
|
|
|
assert.deepEqual(role.toJSON(), data); |
56
|
|
|
}); |
57
|
|
|
|
58
|
|
|
it('constructor does not copy instances', function(){ |
59
|
|
|
var obj1 = GedcomX.EventRole(); |
60
|
|
|
var obj2 = GedcomX.EventRole(obj1); |
61
|
|
|
assert.strictEqual(obj1, obj2); |
62
|
|
|
}); |
63
|
|
|
|
64
|
|
|
}); |