diff options
author | Fabio Berger <me@fabioberger.com> | 2019-01-15 22:13:24 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2019-01-15 22:13:24 +0800 |
commit | 7c37d10d1f93791db75b1622efa775a361965c49 (patch) | |
tree | 7017104bea27120661f71701552214dc5efba909 /packages/tslint-config/test/enumNamingSpec.spec.ts | |
parent | affd6170540034c31593a4f36ce1dbacb91b6b3e (diff) | |
parent | 18084588ea9fa724d6e32c9a49c79d49f189ba7c (diff) | |
download | dexon-sol-tools-7c37d10d1f93791db75b1622efa775a361965c49.tar dexon-sol-tools-7c37d10d1f93791db75b1622efa775a361965c49.tar.gz dexon-sol-tools-7c37d10d1f93791db75b1622efa775a361965c49.tar.bz2 dexon-sol-tools-7c37d10d1f93791db75b1622efa775a361965c49.tar.lz dexon-sol-tools-7c37d10d1f93791db75b1622efa775a361965c49.tar.xz dexon-sol-tools-7c37d10d1f93791db75b1622efa775a361965c49.tar.zst dexon-sol-tools-7c37d10d1f93791db75b1622efa775a361965c49.zip |
Merge branch 'development' into feature/monorepo-scripts/publishToDockerHub
* development: (87 commits)
Update packages/sol-tracing-utils/src/trace_collection_subprovider.ts
Make mapping namings direct
Remove unused tslint disable
Revert "Remove logAsyncErrors hack"
Remove logAsyncErrors hack
Refactor logAsyncErrors to follow our conventions
Export Sources and SourceCodes out of tracing utils
Replace console.log with logUtils.log (#1515)
strict decoding of return values using generics
makerAssetFillAmount -> takerAssetFillAmount
Ran prettier
Linter
Fix build after rebase
Style cleanup for Compressed Calldata in Contract Wrappers PR
Use simpler `_.find` to locate fillOrderBai
Updated dutch auction wrapper
Added back abi-gen-wrappers
Renamed signatureParser.ts to signature_parser.ts
Renamed decode rule `structsAsObjects` to `shouldConvertStructsToObjects`
circle build failed. New commit to resubmit job.
...
Diffstat (limited to 'packages/tslint-config/test/enumNamingSpec.spec.ts')
-rw-r--r-- | packages/tslint-config/test/enumNamingSpec.spec.ts | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/packages/tslint-config/test/enumNamingSpec.spec.ts b/packages/tslint-config/test/enumNamingSpec.spec.ts new file mode 100644 index 000000000..d5b864eba --- /dev/null +++ b/packages/tslint-config/test/enumNamingSpec.spec.ts @@ -0,0 +1,88 @@ +import * as assert from 'assert'; + +import { Rule } from '../rules/enumNamingRule'; + +import { getFixedResult, helper } from './lintrunner'; +const rule = 'enum-naming'; + +describe('enumNamingRule', () => { + it(`should not fail PascalCase`, () => { + const src = `enum test { MemberOne, MemberTwo }`; + const result = helper(src, rule); + assert.equal(result.errorCount, 0); + }); + it(`should not fail PascalCase keys with uncased values`, () => { + const src = `enum test { MemberOne = 'member_one', MemberTwo = 'member two' }`; + const result = helper(src, rule); + assert.equal(result.errorCount, 0); + }); + it(`should not fail PascalCase keys with numbers`, () => { + const src = `enum test { Member1 = 'member_one', MemberTwo = 'member two' }`; + const result = helper(src, rule); + assert.equal(result.errorCount, 0); + }); + it(`should fail with camelCase`, () => { + const src = `enum test { memberOne, memberTwo }`; + const result = helper(src, rule); + assert.equal(result.errorCount, 2); + }); + it(`should fail with snake case`, () => { + const src = `enum test { member_one, member_two }`; + const result = helper(src, rule); + assert.equal(result.errorCount, 2); + }); + it(`should fail with all caps`, () => { + const src = `enum test { MEMBERONE, MEMBER_TWO }`; + const result = helper(src, rule); + assert.equal(result.errorCount, 2); + }); + it(`should fail with mixed case`, () => { + const src = `enum test { member_one, MemberTwo }`; + const result = helper(src, rule); + assert.equal(result.errorCount, 1); + }); + + it(`should fail with the right position`, () => { + const src = `enum test { MemberOne, member_two }`; + const startPosition = src.indexOf('member_two'); + const endPosition = startPosition + 'member_two'.length; + const failure = helper(src, rule).failures[0]; + + assert.equal(failure.getStartPosition().getPosition(), startPosition); + assert.equal(failure.getEndPosition().getPosition(), endPosition); + assert.equal(failure.getFailure(), Rule.FAILURE_STRING); + }); + + it(`should fail with the right message`, () => { + const src = `enum test { memberOne, memberTwo }`; + const failure = helper(src, rule).failures[0]; + + assert.equal(failure.getFailure(), Rule.FAILURE_STRING); + }); +}); +describe('enumNaming fixer', () => { + it('should fix keys', () => { + const src = `enum test { MemberOne, memberTwo, member_three, MEMBER_FOUR, MEMBERFIVE }`; + const expected = `enum test { MemberOne, MemberTwo, MemberThree, MemberFour, Memberfive }`; + const actual = getFixedResult(src, rule); + const result = helper(src, rule); + assert.equal(result.errorCount, 4); // tslint:disable-line:custom-no-magic-numbers + assert.equal(actual, expected); + }); + it('should not fix values', () => { + const src = `enum test { MemberOne = 'MemberOne', memberTwo = 'memberTwo', member_three = 'member_three', MEMBER_FOUR = 'MEMBER_FOUR' }`; + const expected = `enum test { MemberOne = 'MemberOne', MemberTwo = 'memberTwo', MemberThree = 'member_three', MemberFour = 'MEMBER_FOUR' }`; + const actual = getFixedResult(src, rule); + const result = helper(src, rule); + assert.equal(result.errorCount, 3); // tslint:disable-line:custom-no-magic-numbers + assert.equal(actual, expected); + }); + it('should preserve values with equals sign', () => { + const src = `enum Operators { assign = '=', EQUALS = '==', Triple_Equals = '===' }`; + const expected = `enum Operators { Assign = '=', Equals = '==', TripleEquals = '===' }`; + const actual = getFixedResult(src, rule); + const result = helper(src, rule); + assert.equal(result.errorCount, 3); // tslint:disable-line:custom-no-magic-numbers + assert.equal(actual, expected); + }); +}); |