| Total Complexity | 6 |
| Complexity/F | 1 |
| Lines of Code | 47 |
| Function Count | 6 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | var chai = require('chai'); |
||
| 2 | var fse = require('fs-extra'); |
||
| 3 | var config = require('../src/cli').config |
||
| 4 | config.set({root: __dirname + '/fixtures'}) |
||
|
|
|||
| 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)) |
||
| 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 |