Permalink
Jump to Line
Branch:
master
Switch branches/tags
dollar-ignores
feature/new-rule-require-new-lines-in-array
gh-pages
issues/1242
issues/1271-related
master
mdevils/cst
Nothing to show
Nothing to show
Fetching contributors…
![]()
Cannot retrieve contributors at this time
| var Checker = require('../../../lib/checker'); | |
| var expect = require('chai').expect; | |
| describe('rules/require-spaces-in-for-statement', function() { | |
| var checker; | |
| beforeEach(function() { | |
| checker = new Checker(); | |
| checker.registerDefaultRules(); | |
| }); | |
| describe('true option', function() { | |
| beforeEach(function() { | |
| checker.configure({ requireSpacesInForStatement: true }); | |
| }); | |
| it('should report missing spaces in for statement in both cases', function() { | |
| expect(checker.checkString('for(i=0;i<l;i++){}')).to.have.error.count.equal(2); | |
| }); | |
| it('should report missing spaces in for statement before test statement', function() { | |
| expect(checker.checkString('for(i=0; i<l;i++){}')) | |
| .to.have.one.validation.error.from('requireSpacesInForStatement'); | |
| }); | |
| it('should report missing spaces in for statement behind test statement', function() { | |
| expect(checker.checkString('for(i=0;i<l; i++){}')) | |
| .to.have.one.validation.error.from('requireSpacesInForStatement'); | |
| }); | |
| it('should not report with spaces', function() { | |
| expect(checker.checkString('for(i=0; i<l; i++){}')).to.have.no.errors(); | |
| }); | |
| it('should report even without init', function() { | |
| expect(checker.checkString('for(;i<l; i++){}')) | |
| .to.have.one.validation.error.from('requireSpacesInForStatement'); | |
| }); | |
| it('should report even without test', function() { | |
| expect(checker.checkString('for(i=0; ;i++){}')) | |
| .to.have.one.validation.error.from('requireSpacesInForStatement'); | |
| }); | |
| it('should report even without update', function() { | |
| expect(checker.checkString('for(i=0;i<l;){}')) | |
| .to.have.one.validation.error.from('requireSpacesInForStatement'); | |
| }); | |
| }); | |
| }); |