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 (41 sloc) 2.07 KB
var Checker = require('../../../lib/checker');
var expect = require('chai').expect;
describe('rules/disallow-spaces-in-function-declaration', function() {
var checker;
beforeEach(function() {
checker = new Checker();
checker.registerDefaultRules();
});
describe('beforeOpeningRoundBrace', function() {
beforeEach(function() {
checker.configure({ disallowSpacesInFunctionDeclaration: { beforeOpeningRoundBrace: true } });
});
it('should not report missing space before round brace in FunctionDeclaration', function() {
expect(checker.checkString('function abc(){}')).to.have.no.errors();
});
it('should report space before round brace in FunctionDeclaration', function() {
expect(checker.checkString('function abc (){}'))
.to.have.one.validation.error.from('disallowSpacesInFunctionDeclaration');
});
it('should not report missing space before round brace in export default function', function() {
checker.configure({ esnext: true });
expect(checker.checkString('export default function(){}')).to.have.no.errors();
});
});
describe('beforeOpeningCurlyBrace', function() {
beforeEach(function() {
checker.configure({ disallowSpacesInFunctionDeclaration: { beforeOpeningCurlyBrace: true } });
});
it('should not report missing space before curly brace in FunctionDeclaration', function() {
expect(checker.checkString('function abc(){}')).to.have.no.errors();
});
it('should report space before curly brace in FunctionDeclaration', function() {
expect(checker.checkString('function abc() {}'))
.to.have.one.validation.error.from('disallowSpacesInFunctionDeclaration');
});
it('should not report missing space before curly brace in export default function', function() {
checker.configure({ esnext: true });
expect(checker.checkString('export default function(){}')).to.have.no.errors();
});
});
});
Jump to Line
Something went wrong with that request. Please try again.