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/disallow-identical-destructuring-names', function() { | |
| var checker; | |
| function assertNum(str, num) { | |
| expect(checker.checkString(str)).to.have.error.count.equal(num); | |
| } | |
| function assertEmpty(str) { | |
| assertNum(str, 0); | |
| } | |
| beforeEach(function() { | |
| checker = new Checker(); | |
| checker.registerDefaultRules(); | |
| checker.configure({ disallowIdenticalDestructuringNames: true }); | |
| }); | |
| it('should report identical destructuring names', function() { | |
| assertNum('var { a: a } = obj;', 1); | |
| }); | |
| it('should report multiple identical destructuring names', function() { | |
| assertNum('var { a: a, b: b, c: c } = obj;', 3); | |
| }); | |
| it('should report only identical destructuring names', function() { | |
| assertNum('var { a, b: b } = obj;', 1); | |
| }); | |
| it('should not report other destructuring', function() { | |
| assertEmpty('var { a } = obj;'); | |
| assertEmpty('var { a, b, c } = obj;'); | |
| assertEmpty('var { a: a1, b: b2, c: c3 } = obj;'); | |
| assertEmpty('var { [a]: a } = obj;'); | |
| }); | |
| }); |