Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Clone in Desktop Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

51 lines (40 sloc) 1.89 KB
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');
});
});
});
Jump to Line
Something went wrong with that request. Please try again.