| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | var chai = require('chai'); |
||
| 11 | describe('Revision', function() { |
||
| 12 | before( function(done) { |
||
| 13 | Manager.instance.init() |
||
| 14 | .then(function () { |
||
| 15 | |||
| 16 | this.fixture = { |
||
| 17 | tag: fse.readFileSync(__dirname + '/fixtures/templates/article.html', 'utf8'), |
||
| 18 | jsonArticle: fse.readJsonSync(__dirname + '/fixtures/data/article-1.json'), |
||
| 19 | jsonHomepage: fse.readJsonSync(__dirname + '/fixtures/data/homepage-1.json') |
||
| 20 | } |
||
| 21 | done() |
||
| 22 | |||
| 23 | }.bind(this)) |
||
| 24 | }); |
||
| 25 | |||
| 26 | /** |
||
| 27 | * cmsData.revision.getVersions |
||
| 28 | * |
||
| 29 | */ |
||
| 30 | it('cmsData.revision.getVersions()', function() { |
||
| 31 | var versions = cmsData.revision.getVersions('article-1.html') |
||
| 32 | chai.expect(versions[0].name).to.be.equal('article-1.json'); |
||
| 33 | }); |
||
| 34 | |||
| 35 | /** |
||
| 36 | * cmsData.revision.getDocumentRevision |
||
| 37 | * |
||
| 38 | */ |
||
| 39 | it('cmsData.revision.getDocumentRevision()', function() { |
||
| 40 | var version = cmsData.revision.getDocumentRevision('article-1.html') |
||
| 41 | chai.expect(version.name).to.be.equal('article-1.json'); |
||
| 42 | }); |
||
| 43 | |||
| 44 | /** |
||
| 45 | * cmsData.revision.getStatusAndDateToFileName |
||
| 46 | * |
||
| 47 | */ |
||
| 48 | it('cmsData.revision.getStatusAndDateToFileName()', function() { |
||
| 49 | var date = cmsData.revision.getStatusAndDateToFileName('20160919T125255138Z') |
||
| 50 | chai.expect(date).to.be.equal('2016-09-19T12:52:55.138Z'); |
||
| 51 | }); |
||
| 52 | |||
| 53 | /** |
||
| 54 | * cmsData.revision.removeStatusAndDateFromFileName |
||
| 55 | * |
||
| 56 | */ |
||
| 57 | it('cmsData.revision.removeStatusAndDateFromFileName()', function() { |
||
| 58 | var date = cmsData.revision.removeStatusAndDateFromFileName('2016-09-19T12:52:55.138Z') |
||
| 59 | chai.expect(date).to.be.equal('20160919T125255138Z'); |
||
| 60 | }); |
||
| 61 | }); |
||
| 62 |