test/rs/Links.js   A
last analyzed

Complexity

Total Complexity 6
Complexity/F 1

Size

Lines of Code 49
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

1 Function

Rating   Name   Duplication   Size   Complexity  
B Links.js ➔ describe(ꞌLinkssꞌ) 0 46 1
1
var assert = require('chai').assert,
2
    GedcomX = require('../../');
3
4
describe('Linkss', function(){
5
  
6
  it('Create plain', function(){
7
    assert.instanceOf(new GedcomX.Links(), GedcomX.Links, 'An instance of Links is not returned when calling the constructor with new.');
8
    assert.instanceOf(GedcomX.Links(), GedcomX.Links, 'An instance of Links is not returned when calling the constructor without new.');
9
  });
10
  
11
  it('Create with JSON', function(){
12
    var links = GedcomX.Links({
13
      person: {
14
        href: '/person'
15
      }
16
    });
17
    assert.equal(links.getLinks().length, 1);
18
    assert.instanceOf(links.getLink('person'), GedcomX.Link);
19
    assert.equal(links.getLink('person').getHref(), '/person');
20
  });
21
  
22
  it('Build', function(){
23
    var links = GedcomX.Links()
24
      .setLinks([
25
        new GedcomX.Link()
26
          .setRel('person')
27
          .setHref('/person')
28
      ]);
29
    assert.equal(links.getLinks().length, 1);
30
    assert.instanceOf(links.getLink('person'), GedcomX.Link);
31
    assert.equal(links.getLink('person').getHref(), '/person');
32
  });
33
  
34
  it('toJSON', function(){
35
    var data = {
36
      person: {
37
        href: '/person'
38
      }
39
    }, links = GedcomX.Links(data);
40
    assert.deepEqual(links.toJSON(), data);
41
  });
42
  
43
  it('constructor does not copy instances', function(){
44
    var obj1 = GedcomX.Links();
45
    var obj2 = GedcomX.Links(obj1);
46
    assert.strictEqual(obj1, obj2);
47
  });
48
  
49
});