Completed
Push — master ( 395a8a...5b5be3 )
by greg
02:00
created

describe(ꞌcoreUtils.arrayꞌ)   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 9.4285
1
import chai from 'chai'
2
import path from 'path'
3
import sinonChai from'sinon-chai'
4
chai.use(sinonChai)
5
import sinon from 'sinon'
6
7
import {
8
  coreUtils,
9
  abeExtend,
0 ignored issues
show
Unused Code introduced by
The variable abeExtend seems to be never used. Consider removing it.
Loading history...
10
  cmsData,
0 ignored issues
show
Unused Code introduced by
The variable cmsData seems to be never used. Consider removing it.
Loading history...
11
  config
12
} from '../../../src/cli'
13
config.set({root: path.join(process.cwd(), 'test', 'fixtures')})
14
15
describe('coreUtils.array', function() {
16
17
  var arr = [{'test': 'val'}, {'test2': 'val2'}];
18
19
  /**
20
   * coreUtils.array.find
21
   * 
22
   */
23
  it('coreUtils.array.find()', function() {
24
    var result = coreUtils.array.find(arr, 'test', 'val');
25
    chai.expect(result).to.be.a('array')
26
    chai.expect(result.length).to.equal(1)
27
    chai.expect(result[0]).to.equal(0)
28
    var result2 = coreUtils.array.find(arr, 'test2', 'val2');
29
    chai.expect(result2).to.be.a('array')
30
    chai.expect(result2.length).to.equal(1)
31
    chai.expect(result2[0]).to.equal(1)
32
  });
33
34
  /**
35
   * coreUtils.array.filter
36
   * 
37
   */
38
  it('coreUtils.array.filter()', function() {
39
    var result = coreUtils.array.filter(arr, 'test', 'val');
40
    chai.expect(result).to.be.a('array')
41
    chai.expect(result.length).to.equal(1)
42
    chai.expect(result[0]).to.have.test
0 ignored issues
show
introduced by
The result of the property access to chai.expect(result.0).to.have.test is not used.
Loading history...
43
    chai.expect(result[0].test).to.equal('val')
44
  });
45
46
  /**
47
   * coreUtils.array.removeByAttr
48
   * 
49
   */
50
  it('coreUtils.array.removeByAttr()', function() {
51
    var result = coreUtils.array.removeByAttr(arr, 'test2', 'val2');
52
    chai.expect(result).to.be.a('array')
53
    chai.expect(result.length).to.equal(1)
54
    chai.expect(result[0]).to.have.test
0 ignored issues
show
introduced by
The result of the property access to chai.expect(result.0).to.have.test is not used.
Loading history...
55
    chai.expect(result[0].test).to.equal('val')
56
  });
57
58
  /**
59
   * coreUtils.array.contains
60
   * 
61
   */
62
  it('coreUtils.array.contains()', function() {
63
    var testArray = ["test0", "test1", "test2"];
64
    var result = coreUtils.array.contains(testArray, 'test1');
65
    chai.expect(result).to.be.true
0 ignored issues
show
introduced by
The result of the property access to chai.expect(result).to.be.true is not used.
Loading history...
66
    var result2 = coreUtils.array.contains(testArray, 'test3');
67
    chai.expect(result2).to.be.false
0 ignored issues
show
introduced by
The result of the property access to chai.expect(result2).to.be.false is not used.
Loading history...
68
  });
69
70
});
71