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

55 lines (43 sloc) 1.67 KB
var Checker = require('../../../lib/checker');
var expect = require('chai').expect;
describe('rules/require-capitalized-constructors', function() {
var checker;
function baseCases() {
it('should report uncapitalized construction', function() {
expect(checker.checkString('var x = new y();'))
.to.have.one.validation.error.from('requireCapitalizedConstructors');
});
it('should not report capitalized construction', function() {
expect(checker.checkString('var x = new Y();')).to.have.no.errors();
});
it('should not report member expression construction', function() {
expect(checker.checkString('var x = new ns.y();')).to.have.no.errors();
});
it('should not report construction with "this" keyword', function() {
expect(checker.checkString('var x = new this();')).to.have.no.errors();
});
}
beforeEach(function() {
checker = new Checker();
checker.registerDefaultRules();
});
describe('with `true` value', function() {
beforeEach(function() {
checker.configure({ requireCapitalizedConstructors: true });
});
baseCases();
});
describe('with `allExcept` value', function() {
beforeEach(function() {
checker.configure({
requireCapitalizedConstructors: {
allExcept: ['somethingNative']
}
});
});
baseCases();
it('should not report exempted construction', function() {
expect(checker.checkString('var x = new somethingNative();')).to.have.no.errors();
});
});
});
Jump to Line
Something went wrong with that request. Please try again.