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.06 KB
var Checker = require('../../../lib/checker');
var expect = require('chai').expect;
describe('rules/require-spaces-in-function-declaration', function() {
var checker;
beforeEach(function() {
checker = new Checker();
checker.registerDefaultRules();
});
describe('beforeOpeningRoundBrace', function() {
beforeEach(function() {
checker.configure({ requireSpacesInFunctionDeclaration: { beforeOpeningRoundBrace: true } });
});
it('should report missing space before round brace in FunctionDeclaration', function() {
expect(checker.checkString('function abc(){}'))
.to.have.one.validation.error.from('requireSpacesInFunctionDeclaration');
});
it('should not report space before round brace in FunctionDeclaration', function() {
expect(checker.checkString('function abc (){}')).to.have.no.errors();
});
it('should not report 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({ requireSpacesInFunctionDeclaration: { beforeOpeningCurlyBrace: true } });
});
it('should report missing space before curly brace in FunctionDeclaration', function() {
expect(checker.checkString('function abc(){}'))
.to.have.one.validation.error.from('requireSpacesInFunctionDeclaration');
});
it('should not report space before curly brace in FunctionDeclaration', function() {
expect(checker.checkString('function abc() {}')).to.have.no.errors();
});
it('should not report 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.