test/rs/Link.js   A
last analyzed

Complexity

Total Complexity 6
Complexity/F 1

Size

Lines of Code 72
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 72
rs 10
wmc 6
mnd 0
bc 6
fnc 6
bpm 1
cpm 1
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A Link.js ➔ describe(ꞌLinkꞌ) 0 69 1
1
var assert = require('chai').assert,
2
    GedcomX = require('../../');
3
4
describe('Link', function(){
5
  
6
  it('Create plain', function(){
7
    assert.instanceOf(new GedcomX.Link(), GedcomX.Link, 'An instance of Link is not returned when calling the constructor with new.');
8
    assert.instanceOf(GedcomX.Link(), GedcomX.Link, 'An instance of Link is not returned when calling the constructor without new.');
9
  });
10
  
11
  it('Create with JSON', function(){
12
    var link = GedcomX.Link({
13
      rel: 'relationship',
14
      href: '/relationship',
15
      template: '/relationship/{}',
16
      type: 'application/x-gedcomx-v1+json',
17
      accept: 'application/x-gedcomx-v1+json',
18
      allow: 'GET',
19
      hreflang: 'en',
20
      title: 'Relationship'
21
    });
22
    assert.equal(link.getRel(), 'relationship');
23
    assert.equal(link.getHref(), '/relationship');
24
    assert.equal(link.getTemplate(), '/relationship/{}');
25
    assert.equal(link.getType(), 'application/x-gedcomx-v1+json');
26
    assert.equal(link.getAccept(), 'application/x-gedcomx-v1+json');
27
    assert.equal(link.getAllow(), 'GET');
28
    assert.equal(link.getHrefLang(), 'en');
29
    assert.equal(link.getTitle(), 'Relationship');
30
  });
31
  
32
  it('Build', function(){
33
    var link = GedcomX.Link()
34
      .setRel('relationship')
35
      .setHref('/relationship')
36
      .setTemplate('/relationship/{}')
37
      .setType('application/x-gedcomx-v1+json')
38
      .setAccept('application/x-gedcomx-v1+json')
39
      .setAllow('GET')
40
      .setHrefLang('en')
41
      .setTitle('Relationship');
42
    assert.equal(link.getRel(), 'relationship');
43
    assert.equal(link.getHref(), '/relationship');
44
    assert.equal(link.getTemplate(), '/relationship/{}');
45
    assert.equal(link.getType(), 'application/x-gedcomx-v1+json');
46
    assert.equal(link.getAccept(), 'application/x-gedcomx-v1+json');
47
    assert.equal(link.getAllow(), 'GET');
48
    assert.equal(link.getHrefLang(), 'en');
49
    assert.equal(link.getTitle(), 'Relationship');
50
  });
51
  
52
  it('toJSON', function(){
53
    var data = {
54
      rel: 'relationship',
55
      href: '/relationship',
56
      template: '/relationship/{}',
57
      type: 'application/x-gedcomx-v1+json',
58
      accept: 'application/x-gedcomx-v1+json',
59
      allow: 'GET',
60
      hreflang: 'en',
61
      title: 'Relationship'
62
    }, link = GedcomX.Link(data);
63
    assert.deepEqual(link.toJSON(), data);
64
  });
65
  
66
  it('constructor does not copy instances', function(){
67
    var obj1 = GedcomX.Link();
68
    var obj2 = GedcomX.Link(obj1);
69
    assert.strictEqual(obj1, obj2);
70
  });
71
  
72
});