1
|
|
|
var assert = require('chai').assert, |
2
|
|
|
GedcomX = require('../../'); |
3
|
|
|
|
4
|
|
|
describe('AtomCategory', function(){ |
5
|
|
|
|
6
|
|
|
it('Create plain', function(){ |
7
|
|
|
assert.instanceOf(new GedcomX.AtomCategory(), GedcomX.AtomCategory, 'An instance of AtomCategory is not returned when calling the constructor with new.'); |
8
|
|
|
assert.instanceOf(GedcomX.AtomCategory(), GedcomX.AtomCategory, 'An instance of AtomCategory is not returned when calling the constructor without new.'); |
9
|
|
|
}); |
10
|
|
|
|
11
|
|
|
it('Create with JSON', function(){ |
12
|
|
|
var category = GedcomX.AtomCategory({ |
13
|
|
|
scheme: 'scheme', |
14
|
|
|
term: 'term', |
15
|
|
|
label: 'label' |
16
|
|
|
}); |
17
|
|
|
assert.equal(category.getScheme(), 'scheme'); |
18
|
|
|
assert.equal(category.getTerm(), 'term'); |
19
|
|
|
assert.equal(category.getLabel(), 'label'); |
20
|
|
|
}); |
21
|
|
|
|
22
|
|
|
it('Build', function(){ |
23
|
|
|
var category = GedcomX.AtomCategory() |
24
|
|
|
.setScheme('scheme') |
25
|
|
|
.setTerm('term') |
26
|
|
|
.setLabel('label'); |
27
|
|
|
assert.equal(category.getScheme(), 'scheme'); |
28
|
|
|
assert.equal(category.getTerm(), 'term'); |
29
|
|
|
assert.equal(category.getLabel(), 'label'); |
30
|
|
|
}); |
31
|
|
|
|
32
|
|
|
it('toJSON', function(){ |
33
|
|
|
var data = { |
34
|
|
|
scheme: 'scheme', |
35
|
|
|
term: 'term', |
36
|
|
|
label: 'label' |
37
|
|
|
}, category = GedcomX.AtomCategory(data); |
38
|
|
|
assert.deepEqual(category.toJSON(), data); |
39
|
|
|
}); |
40
|
|
|
|
41
|
|
|
it('constructor does not copy instances', function(){ |
42
|
|
|
var obj1 = GedcomX.AtomCategory(); |
43
|
|
|
var obj2 = GedcomX.AtomCategory(obj1); |
44
|
|
|
assert.strictEqual(obj1, obj2); |
45
|
|
|
}); |
46
|
|
|
|
47
|
|
|
}); |