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-shorthand-arrow-functions', function() { | |
| var checker; | |
| beforeEach(function() { | |
| checker = new Checker(); | |
| checker.registerDefaultRules(); | |
| checker.configure({ esnext: true, requireShorthandArrowFunctions: true }); | |
| }); | |
| it('should report a shorthand arrow function expression', function() { | |
| expect(checker.checkString('evens.map(v => v + 1);')).to.have.no.errors(); | |
| }); | |
| it('should report an arrow function expression that could be shorthand', function() { | |
| expect(checker.checkString('evens.map(v => { return v + 1; });')) | |
| .to.have.one.validation.error.from('requireShorthandArrowFunctions'); | |
| }); | |
| it('should not report an arrow function expression with multiple statements in the body', function() { | |
| expect(checker.checkString('evens.map(v => { v = v + 1; return v; });')).to.have.no.errors(); | |
| }); | |
| }); |