1
|
|
|
var assert = require('chai').assert, |
2
|
|
|
GedcomX = require('../../'); |
3
|
|
|
|
4
|
|
|
describe('PlaceReference', function(){ |
5
|
|
|
|
6
|
|
|
it('Create with JSON', function(){ |
7
|
|
|
var place = GedcomX.PlaceReference({ |
8
|
|
|
"original": "Mitchel Field, Hempstead, New York, United States", |
9
|
|
|
"normalized":[ |
10
|
|
|
{"lang": "en-US", "value": "Hempstead, Nassau, New York, United States"} |
11
|
|
|
] |
12
|
|
|
}); |
13
|
|
|
assert.equal(place.getOriginal(), 'Mitchel Field, Hempstead, New York, United States'); |
14
|
|
|
assert.equal(place.getNormalized().length, 1); |
15
|
|
|
assert.equal(place.getNormalized()[0].getLang(), 'en-US'); |
16
|
|
|
assert.equal(place.getNormalized()[0].getValue(), 'Hempstead, Nassau, New York, United States'); |
17
|
|
|
}); |
18
|
|
|
|
19
|
|
|
it('Build', function(){ |
20
|
|
|
var place = GedcomX.PlaceReference() |
21
|
|
|
.setOriginal('Mitchel Field, Hempstead, New York, United States') |
22
|
|
|
.addNormalized({"lang": "en-US", "value": "Hempstead, Nassau, New York, United States"}); |
23
|
|
|
assert.equal(place.getOriginal(), 'Mitchel Field, Hempstead, New York, United States'); |
24
|
|
|
assert.equal(place.getNormalized().length, 1); |
25
|
|
|
assert.equal(place.getNormalized()[0].getLang(), 'en-US'); |
26
|
|
|
assert.equal(place.getNormalized()[0].getValue(), 'Hempstead, Nassau, New York, United States'); |
27
|
|
|
}); |
28
|
|
|
|
29
|
|
|
it('toJSON', function(){ |
30
|
|
|
var data = { |
31
|
|
|
"original": "Mitchel Field, Hempstead, New York, United States", |
32
|
|
|
"normalized":[ |
33
|
|
|
{"lang": "en-US", "value": "Hempstead, Nassau, New York, United States"} |
34
|
|
|
] |
35
|
|
|
}, place = GedcomX.PlaceReference(data); |
36
|
|
|
assert.deepEqual(place.toJSON(), data); |
37
|
|
|
}); |
38
|
|
|
|
39
|
|
|
}); |