|
1
|
|
|
var assert = require('chai').assert, |
|
2
|
|
|
GedcomX = require('../'); |
|
3
|
|
|
|
|
4
|
|
|
describe('EvidenceReference', function(){ |
|
5
|
|
|
|
|
6
|
|
|
it('Create plain', function(){ |
|
7
|
|
|
var newER = new GedcomX.EvidenceReference(), |
|
8
|
|
|
er = GedcomX.EvidenceReference(); |
|
9
|
|
|
assert.instanceOf(newER, GedcomX.EvidenceReference, 'An instance of EvidenceReference is not returned when calling the constructor with new.'); |
|
10
|
|
|
assert.instanceOf(er, GedcomX.EvidenceReference, 'An instance of EvidenceReference is not returned when calling the constructor without new.'); |
|
11
|
|
|
}); |
|
12
|
|
|
|
|
13
|
|
|
it('Create with JSON', function(){ |
|
14
|
|
|
var er = GedcomX.EvidenceReference({ |
|
15
|
|
|
resource: 'http://example.com', |
|
16
|
|
|
attribution: { |
|
17
|
|
|
created: 1248942374 |
|
18
|
|
|
} |
|
19
|
|
|
}); |
|
20
|
|
|
assert.equal(er.getResource(), 'http://example.com', 'Resource not saved properly when created with JSON'); |
|
21
|
|
|
assert.equal(er.getAttribution().getCreated().getTime(), 1248942374); |
|
22
|
|
|
}); |
|
23
|
|
|
|
|
24
|
|
|
it('Build', function(){ |
|
25
|
|
|
var er = GedcomX.EvidenceReference() |
|
26
|
|
|
.setResource('http://newuri.com') |
|
27
|
|
|
.setAttribution({ |
|
28
|
|
|
created: new Date(1248942374) |
|
29
|
|
|
}); |
|
30
|
|
|
assert.equal(er.getResource(), 'http://newuri.com'); |
|
31
|
|
|
assert.equal(er.getAttribution().getCreated().getTime(), 1248942374); |
|
32
|
|
|
}); |
|
33
|
|
|
|
|
34
|
|
|
it('toJSON()', function(){ |
|
35
|
|
|
var erData = { |
|
36
|
|
|
resource: 'http://example.com', |
|
37
|
|
|
attribution: { |
|
38
|
|
|
created: 1248942374 |
|
39
|
|
|
} |
|
40
|
|
|
}, |
|
41
|
|
|
er = GedcomX.EvidenceReference(erData); |
|
42
|
|
|
assert.deepEqual(er.toJSON(), erData); |
|
43
|
|
|
}); |
|
44
|
|
|
|
|
45
|
|
|
it('constructor does not copy instances', function(){ |
|
46
|
|
|
var obj1 = GedcomX.EvidenceReference(); |
|
47
|
|
|
var obj2 = GedcomX.EvidenceReference(obj1); |
|
48
|
|
|
assert.strictEqual(obj1, obj2); |
|
49
|
|
|
}); |
|
50
|
|
|
|
|
51
|
|
|
}); |