Completed
Push — master ( e3ee1d...5cbb1b )
by Justin
01:36
created

test/records/FieldValueDescriptor.js   A

Complexity

Total Complexity 6
Complexity/F 1

Size

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

1 Function

Rating   Name   Duplication   Size   Complexity  
A FieldValueDescriptor.js ➔ describe(ꞌFieldValueDescriptorꞌ) 0 62 1
1
var assert = require('chai').assert,
2
    GedcomX = require('../../');
3
4
describe('FieldValueDescriptor', function(){
5
  
6
  it('Create plain', function(){
7
    assert.instanceOf(new GedcomX.FieldValueDescriptor(), GedcomX.FieldValueDescriptor, 'An instance of FieldValueDescriptor is not returned when calling the constructor with new.');
8
    assert.instanceOf(GedcomX.FieldValueDescriptor(), GedcomX.FieldValueDescriptor, 'An instance of FieldValueDescriptor is not returned when calling the constructor without new.');
9
  });
10
  
11
  it('Create with JSON', function(){
12
    var fvd = GedcomX.FieldValueDescriptor({
13
      id: 'fvd',
14
      optional: true,
15
      type: 'http://gedcomx.org/Original',
16
      labelId: 'name',
17
      displayLabels: [
18
        { lang: 'en-US', value: 'Name' }
19
      ]
20
    });
21
    assert.equal(fvd.getId(), 'fvd');
22
    assert(fvd.getOptional());
23
    assert.equal(fvd.getType(), 'http://gedcomx.org/Original');
24
    assert.equal(fvd.getLabelId(), 'name');
25
    assert.equal(fvd.getDisplayLabels().length, 1);
26
    assert.equal(fvd.getDisplayLabels()[0].getLang(), 'en-US');
27
    assert.equal(fvd.getDisplayLabels()[0].getValue(), 'Name');
28
  });
29
  
30
  it('Build', function(){
31
    var fvd = GedcomX.FieldValueDescriptor()
32
      .setId('fvd')
33
      .setOptional(true)
34
      .setType('http://gedcomx.org/Original')
35
      .setLabelId('name')
36
      .addDisplayLabel({ lang: 'en-US', value: 'Name' });
37
    assert.equal(fvd.getId(), 'fvd');
38
    assert(fvd.getOptional());
39
    assert.equal(fvd.getType(), 'http://gedcomx.org/Original');
40
    assert.equal(fvd.getLabelId(), 'name');
41
    assert.equal(fvd.getDisplayLabels().length, 1);
42
    assert.equal(fvd.getDisplayLabels()[0].getLang(), 'en-US');
43
    assert.equal(fvd.getDisplayLabels()[0].getValue(), 'Name');
44
  });
45
  
46
  it('toJSON', function(){
47
    var data = {
48
      id: 'fvd',
49
      optional: true,
50
      type: 'http://gedcomx.org/Original',
51
      labelId: 'name',
52
      displayLabels: [
53
        { lang: 'en-US', value: 'Name' }
54
      ]
55
    }, fvd = GedcomX.FieldValueDescriptor(data);
56
    assert.deepEqual(fvd.toJSON(), data);
57
  });
58
  
59
  it('constructor does not copy instances', function(){
60
    var obj1 = GedcomX.FieldValueDescriptor();
61
    var obj2 = GedcomX.FieldValueDescriptor(obj1);
62
    assert.strictEqual(obj1, obj2);
63
  });
64
  
65
});