Completed
Pull Request — master (#13)
by Justin
07:02
created

test/ExtensibleData.js   A

Complexity

Total Complexity 6
Complexity/F 1

Size

Lines of Code 36
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 0
c 2
b 0
f 0
nc 1
dl 0
loc 36
rs 10
wmc 6
mnd 0
bc 6
fnc 6
bpm 1
cpm 1
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B ExtensibleData.js ➔ describe(ꞌExtensibleDataꞌ) 0 33 1
1
var assert = require('chai').assert,
2
    GedcomX = require('../');
3
4
describe('ExtensibleData', function(){
5
  
6
  it('Create plain', function(){
7
    var newEd = new GedcomX.ExtensibleData(),
8
        ed = GedcomX.ExtensibleData();
9
    assert.instanceOf(newEd, GedcomX.ExtensibleData, 'An instance of ExtensibleData is not returned when calling the constructor with new.');
10
    assert.instanceOf(ed, GedcomX.ExtensibleData, 'An instance of ExtensibleData is not returned when calling the constructor without new.');
11
  });
12
  
13
  it('Create with JSON', function(){
14
    var ed = GedcomX.ExtensibleData({ id: 'edid' });
15
    assert.equal(ed.getId(), 'edid', 'ID not saved properly when created with JSON');
16
  });
17
  
18
  it('Change ID', function(){
19
    var ed = GedcomX.ExtensibleData({ id: 'edid' });
20
    ed.setId('newId');
21
    assert.equal(ed.getId(), 'newId', 'ID not saved properly when changed with setId()');
22
  });
23
  
24
  it('toJSON()', function(){
25
    var ed = GedcomX.ExtensibleData({ id: 'firstId' });
26
    ed.setId('newId');
27
    assert.deepEqual(ed.toJSON(), {id:'newId'}, 'JSON export is incorrect');
28
  });
29
  
30
  it('constructor does not copy instances', function(){
31
    var obj1 = GedcomX.ExtensibleData();
32
    var obj2 = GedcomX.ExtensibleData(obj1);
33
    assert.strictEqual(obj1, obj2);
34
  });
35
  
36
});