1
|
|
|
var assert = require('chai').assert, |
2
|
|
|
GedcomX = require('../../'); |
3
|
|
|
|
4
|
|
|
describe('TextValue', function(){ |
5
|
|
|
|
6
|
|
|
it('Create plain', function(){ |
7
|
|
|
var newValue = new GedcomX.TextValue(), |
8
|
|
|
value = GedcomX.TextValue(); |
9
|
|
|
assert.instanceOf(newValue, GedcomX.TextValue, 'An instance of TextValue is not returned when calling the constructor with new.'); |
10
|
|
|
assert.instanceOf(value, GedcomX.TextValue, 'An instance of TextValue is not returned when calling the constructor without new.'); |
11
|
|
|
}); |
12
|
|
|
|
13
|
|
|
it('Create with JSON', function(){ |
14
|
|
|
var value = GedcomX.TextValue({ |
15
|
|
|
lang: 'en', |
16
|
|
|
value: 'a full text value' |
17
|
|
|
}); |
18
|
|
|
assert.equal(value.getLang(), 'en'); |
19
|
|
|
assert.equal(value.getValue(), 'a full text value'); |
20
|
|
|
}); |
21
|
|
|
|
22
|
|
|
it('Build', function(){ |
23
|
|
|
var value = GedcomX.TextValue() |
24
|
|
|
.setLang('en') |
25
|
|
|
.setValue('a full text value'); |
26
|
|
|
assert.equal(value.getLang(), 'en'); |
27
|
|
|
assert.equal(value.getValue(), 'a full text value'); |
28
|
|
|
}); |
29
|
|
|
|
30
|
|
|
it('toJSON', function(){ |
31
|
|
|
var data = { |
32
|
|
|
lang: 'en', |
33
|
|
|
value: 'a full text value' |
34
|
|
|
}, value = GedcomX.TextValue(data); |
35
|
|
|
assert.deepEqual(value.toJSON(), data); |
36
|
|
|
}); |
37
|
|
|
|
38
|
|
|
it('constructor does not copy instances', function(){ |
39
|
|
|
var obj1 = GedcomX.TextValue(); |
40
|
|
|
var obj2 = GedcomX.TextValue(obj1); |
41
|
|
|
assert.strictEqual(obj1, obj2); |
42
|
|
|
}); |
43
|
|
|
|
44
|
|
|
}); |