Completed
Push — master ( bdfcbe...91ed9c )
by
unknown
02:02
created

sort.js ➔ describe(ꞌSortꞌ)   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 39

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
dl 0
loc 39
rs 8.8571
nop 0

4 Functions

Rating   Name   Duplication   Size   Complexity  
A sort.js ➔ ... ➔ before 0 7 1
A sort.js ➔ ... ➔ it(ꞌcoreUtils.sort.shuffleꞌ) 0 5 1
A sort.js ➔ ... ➔ it(ꞌcoreUtils.sort.byDateDescꞌ) 0 5 1
A sort.js ➔ ... ➔ it(ꞌcoreUtils.sort.byDateAscꞌ) 0 5 1
1
var chai = require('chai');
2
var fse = require('fs-extra');
3
var config = require('../src/cli').config
4
config.set({root: __dirname + '/fixtures'})
0 ignored issues
show
Compatibility introduced by
Consider using the path module for constructing paths since they are otherwise not cross-OS compatible.
Loading history...
5
6
var Manager = require('../src/cli').Manager;
7
var coreUtils = require('../src/cli').coreUtils
8
9
describe('Sort', function() {
10
  before( function(done) {
11
    Manager.instance.init()
12
      .then(function () {
13
        done()
14
        
15
      }.bind(this))
0 ignored issues
show
unused-code introduced by
The call to bind does not seem necessary since the function does not use this. Consider calling it directly.
Loading history...
16
  });
17
18
  /**
19
   * coreUtils.sort.byDateAsc
20
   * 
21
   */
22
  it('coreUtils.sort.byDateAsc', function() {
23
  	var list = Manager.instance.getList()
24
  	list.sort(coreUtils.sort.byDateAsc)
25
  	chai.expect(list[0].name).to.contain('homepage');
26
  });
27
28
  /**
29
   * coreUtils.sort.byDateDesc
30
   * 
31
   */
32
  it('coreUtils.sort.byDateDesc', function() {
33
  	var list = Manager.instance.getList()
34
  	list.sort(coreUtils.sort.byDateDesc)
35
  	chai.expect(list[0].name).to.contain('article');
36
  });
37
38
  /**
39
   * coreUtils.sort.shuffle
40
   * 
41
   */
42
  it('coreUtils.sort.shuffle', function() {
43
  	var list = Manager.instance.getList()
44
  	var shuffled = coreUtils.sort.shuffle(list)
45
  	chai.expect(shuffled[0].name).to.be.oneOf(['article-1.json', 'homepage-1.json']);
46
  });
47
});
48