@@ 1-130 (lines=130) @@ | ||
1 | var assert = require('chai').assert, |
|
2 | GedcomX = require('../../'); |
|
3 | ||
4 | describe('Conclusion', function(){ |
|
5 | ||
6 | it('Create plain', function(){ |
|
7 | var newConclusion = new GedcomX.Conclusion(), |
|
8 | conclusion = GedcomX.Conclusion(); |
|
9 | assert.instanceOf(newConclusion, GedcomX.Conclusion, 'An instance of Conclusion is not returned when calling the constructor with new.'); |
|
10 | assert.instanceOf(conclusion, GedcomX.Conclusion, 'An instance of Conclusion is not returned when calling the constructor without new.'); |
|
11 | }); |
|
12 | ||
13 | it('Create with JSON', function(){ |
|
14 | var conclusion = GedcomX.Conclusion({ |
|
15 | id: 'conclusion', |
|
16 | lang: 'en', |
|
17 | analysis: { |
|
18 | resource: 'http://analysis/uri' |
|
19 | }, |
|
20 | confidence: 'http://gedcomx.org/High', |
|
21 | attribution: { |
|
22 | created: 1145667891 |
|
23 | }, |
|
24 | sources: [ |
|
25 | { |
|
26 | description: 'http://description/uri' |
|
27 | } |
|
28 | ], |
|
29 | notes: [ |
|
30 | { |
|
31 | subject: 'Note title', |
|
32 | text: 'Note text' |
|
33 | } |
|
34 | ] |
|
35 | }); |
|
36 | assert.equal(conclusion.getId(), 'conclusion'); |
|
37 | assert.equal(conclusion.getLang(), 'en'); |
|
38 | assert.equal(conclusion.getAnalysis().getResource(), 'http://analysis/uri'); |
|
39 | assert.equal(conclusion.getConfidence(), 'http://gedcomx.org/High'); |
|
40 | assert.equal(conclusion.getAttribution().getCreated().getTime(), 1145667891); |
|
41 | assert.equal(conclusion.getSources().length, 1); |
|
42 | assert.equal(conclusion.getSources()[0].getDescription(), 'http://description/uri'); |
|
43 | assert.equal(conclusion.getNotes().length, 1); |
|
44 | assert.equal(conclusion.getNotes()[0].getSubject(), 'Note title'); |
|
45 | assert.equal(conclusion.getNotes()[0].getText(), 'Note text'); |
|
46 | }); |
|
47 | ||
48 | it('Create with mixed data', function(){ |
|
49 | var conclusion = GedcomX.Conclusion({ |
|
50 | id: 'conclusion', |
|
51 | lang: 'en', |
|
52 | confidence: 'http://gedcomx.org/High', |
|
53 | sources: [ |
|
54 | GedcomX.SourceReference({ description: 'http://description/uri' }) |
|
55 | ], |
|
56 | notes: [ |
|
57 | GedcomX.Note({ |
|
58 | subject: 'Note title', |
|
59 | text: 'Note text' |
|
60 | }) |
|
61 | ] |
|
62 | }); |
|
63 | assert.equal(conclusion.getId(), 'conclusion'); |
|
64 | assert.equal(conclusion.getLang(), 'en'); |
|
65 | assert.equal(conclusion.getConfidence(), 'http://gedcomx.org/High'); |
|
66 | assert.equal(conclusion.getSources().length, 1); |
|
67 | assert.equal(conclusion.getSources()[0].getDescription(), 'http://description/uri'); |
|
68 | assert.equal(conclusion.getNotes().length, 1); |
|
69 | assert.equal(conclusion.getNotes()[0].getSubject(), 'Note title'); |
|
70 | assert.equal(conclusion.getNotes()[0].getText(), 'Note text'); |
|
71 | }); |
|
72 | ||
73 | it('Build', function(){ |
|
74 | var conclusion = GedcomX.Conclusion() |
|
75 | .setId('conclusion') |
|
76 | .setLang('en') |
|
77 | .setConfidence('http://gedcomx.org/High') |
|
78 | .addSource( |
|
79 | GedcomX.SourceReference() |
|
80 | .setDescription('http://description/uri') |
|
81 | ) |
|
82 | .addNote( |
|
83 | GedcomX.Note() |
|
84 | .setSubject('Note title') |
|
85 | .setText('Note text') |
|
86 | ); |
|
87 | assert.equal(conclusion.getId(), 'conclusion'); |
|
88 | assert.equal(conclusion.getLang(), 'en'); |
|
89 | assert.equal(conclusion.getConfidence(), 'http://gedcomx.org/High'); |
|
90 | assert.equal(conclusion.getSources().length, 1); |
|
91 | assert.equal(conclusion.getSources()[0].getDescription(), 'http://description/uri'); |
|
92 | assert.equal(conclusion.getNotes().length, 1); |
|
93 | assert.equal(conclusion.getNotes()[0].getSubject(), 'Note title'); |
|
94 | assert.equal(conclusion.getNotes()[0].getText(), 'Note text'); |
|
95 | }); |
|
96 | ||
97 | it('toJSON', function(){ |
|
98 | var conclusionData = { |
|
99 | id: 'conclusion', |
|
100 | lang: 'en', |
|
101 | analysis: { |
|
102 | resource: 'http://analysis/uri' |
|
103 | }, |
|
104 | confidence: 'http://gedcomx.org/High', |
|
105 | attribution: { |
|
106 | created: 1145667891 |
|
107 | }, |
|
108 | sources: [ |
|
109 | { |
|
110 | description: 'http://description/uri' |
|
111 | } |
|
112 | ], |
|
113 | notes: [ |
|
114 | { |
|
115 | subject: 'Note title', |
|
116 | text: 'Note text' |
|
117 | } |
|
118 | ] |
|
119 | }, |
|
120 | conclusion = GedcomX.Conclusion(conclusionData); |
|
121 | assert.deepEqual(conclusion.toJSON(), conclusionData); |
|
122 | }); |
|
123 | ||
124 | it('constructor does not copy instances', function(){ |
|
125 | var obj1 = GedcomX.Conclusion(); |
|
126 | var obj2 = GedcomX.Conclusion(obj1); |
|
127 | assert.strictEqual(obj1, obj2); |
|
128 | }); |
|
129 | ||
130 | }); |
@@ 1-124 (lines=124) @@ | ||
1 | var assert = require('chai').assert, |
|
2 | GedcomX = require('../../'); |
|
3 | ||
4 | describe('Conclusion', function(){ |
|
5 | ||
6 | it('Create with JSON', function(){ |
|
7 | var conclusion = GedcomX.Conclusion({ |
|
8 | id: 'conclusion', |
|
9 | lang: 'en', |
|
10 | sortKey: '149das', |
|
11 | analysis: { |
|
12 | resource: 'http://analysis/uri' |
|
13 | }, |
|
14 | confidence: 'http://gedcomx.org/High', |
|
15 | attribution: { |
|
16 | created: 1145667891 |
|
17 | }, |
|
18 | sources: [ |
|
19 | { |
|
20 | description: 'http://description/uri' |
|
21 | } |
|
22 | ], |
|
23 | notes: [ |
|
24 | { |
|
25 | subject: 'Note title', |
|
26 | text: 'Note text' |
|
27 | } |
|
28 | ] |
|
29 | }); |
|
30 | assert.equal(conclusion.getId(), 'conclusion'); |
|
31 | assert.equal(conclusion.getLang(), 'en'); |
|
32 | assert.equal(conclusion.getSortKey(), '149das'); |
|
33 | assert.equal(conclusion.getAnalysis().getResource(), 'http://analysis/uri'); |
|
34 | assert.equal(conclusion.getConfidence(), 'http://gedcomx.org/High'); |
|
35 | assert.equal(conclusion.getAttribution().getCreated().getTime(), 1145667891); |
|
36 | assert.equal(conclusion.getSources().length, 1); |
|
37 | assert.equal(conclusion.getSources()[0].getDescription(), 'http://description/uri'); |
|
38 | assert.equal(conclusion.getNotes().length, 1); |
|
39 | assert.equal(conclusion.getNotes()[0].getSubject(), 'Note title'); |
|
40 | assert.equal(conclusion.getNotes()[0].getText(), 'Note text'); |
|
41 | }); |
|
42 | ||
43 | it('Create with mixed data', function(){ |
|
44 | var conclusion = GedcomX.Conclusion({ |
|
45 | id: 'conclusion', |
|
46 | lang: 'en', |
|
47 | sortKey: '149das', |
|
48 | confidence: 'http://gedcomx.org/High', |
|
49 | sources: [ |
|
50 | GedcomX.SourceReference({ description: 'http://description/uri' }) |
|
51 | ], |
|
52 | notes: [ |
|
53 | GedcomX.Note({ |
|
54 | subject: 'Note title', |
|
55 | text: 'Note text' |
|
56 | }) |
|
57 | ] |
|
58 | }); |
|
59 | assert.equal(conclusion.getId(), 'conclusion'); |
|
60 | assert.equal(conclusion.getLang(), 'en'); |
|
61 | assert.equal(conclusion.getSortKey(), '149das'); |
|
62 | assert.equal(conclusion.getConfidence(), 'http://gedcomx.org/High'); |
|
63 | assert.equal(conclusion.getSources().length, 1); |
|
64 | assert.equal(conclusion.getSources()[0].getDescription(), 'http://description/uri'); |
|
65 | assert.equal(conclusion.getNotes().length, 1); |
|
66 | assert.equal(conclusion.getNotes()[0].getSubject(), 'Note title'); |
|
67 | assert.equal(conclusion.getNotes()[0].getText(), 'Note text'); |
|
68 | }); |
|
69 | ||
70 | it('Build', function(){ |
|
71 | var conclusion = GedcomX.Conclusion() |
|
72 | .setId('conclusion') |
|
73 | .setLang('en') |
|
74 | .setSortKey('149das') |
|
75 | .setConfidence('http://gedcomx.org/High') |
|
76 | .addSource( |
|
77 | GedcomX.SourceReference() |
|
78 | .setDescription('http://description/uri') |
|
79 | ) |
|
80 | .addNote( |
|
81 | GedcomX.Note() |
|
82 | .setSubject('Note title') |
|
83 | .setText('Note text') |
|
84 | ); |
|
85 | assert.equal(conclusion.getId(), 'conclusion'); |
|
86 | assert.equal(conclusion.getLang(), 'en'); |
|
87 | assert.equal(conclusion.getSortKey(), '149das'); |
|
88 | assert.equal(conclusion.getConfidence(), 'http://gedcomx.org/High'); |
|
89 | assert.equal(conclusion.getSources().length, 1); |
|
90 | assert.equal(conclusion.getSources()[0].getDescription(), 'http://description/uri'); |
|
91 | assert.equal(conclusion.getNotes().length, 1); |
|
92 | assert.equal(conclusion.getNotes()[0].getSubject(), 'Note title'); |
|
93 | assert.equal(conclusion.getNotes()[0].getText(), 'Note text'); |
|
94 | }); |
|
95 | ||
96 | it('toJSON', function(){ |
|
97 | var data = { |
|
98 | id: 'conclusion', |
|
99 | lang: 'en', |
|
100 | sortKey: '149das', |
|
101 | analysis: { |
|
102 | resource: 'http://analysis/uri' |
|
103 | }, |
|
104 | confidence: 'http://gedcomx.org/High', |
|
105 | attribution: { |
|
106 | created: 1145667891 |
|
107 | }, |
|
108 | sources: [ |
|
109 | { |
|
110 | description: 'http://description/uri' |
|
111 | } |
|
112 | ], |
|
113 | notes: [ |
|
114 | { |
|
115 | subject: 'Note title', |
|
116 | text: 'Note text' |
|
117 | } |
|
118 | ] |
|
119 | }, |
|
120 | conclusion = GedcomX.Conclusion(data); |
|
121 | assert.deepEqual(conclusion.toJSON(), data); |
|
122 | }); |
|
123 | ||
124 | }); |