Skip to content

Commit

Permalink
chore: update deps, linting and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlexLichter committed Aug 18, 2019
1 parent 15be0ab commit 34f27b1
Show file tree
Hide file tree
Showing 21 changed files with 2,594 additions and 2,210 deletions.
4 changes: 2 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"presets": [
"env"
"@babel/preset-env"
],
"plugins": [
"transform-object-rest-spread"
"@babel/plugin-proposal-object-rest-spread"
]
}
61 changes: 29 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,42 +44,39 @@
"author": "Alexander Lichter <[email protected]>",
"license": "MIT",
"devDependencies": {
"@commitlint/cli": "^7.2.1",
"@commitlint/config-conventional": "^7.3.0",
"@commitlint/travis-cli": "^7.2.1",
"babel-core": "^6.26.3",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.5",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-2": "^6.24.1",
"babel-register": "^6.26.0",
"@babel/core": "^7.5.5",
"@babel/plugin-proposal-object-rest-spread": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"@commitlint/travis-cli": "^8.1.0",
"babel-eslint": "^10.0.2",
"babel-jest": "^24.9.0",
"babel-loader": "^8.0.6",
"babel-register": "^6.22.0",
"chalk": "^2.4.2",
"codecov": "^3.1.0",
"codecov": "^3.5.0",
"cross-spawn": "^6.0.5",
"eslint": "^5.12.0",
"eslint-config-standard": "^11.0.0",
"eslint": "^6.2.0",
"eslint-config-standard": "^13.0.1",
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.1.1",
"eslint-plugin-html": "^5.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jest": "^22.1.3",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-loader": "^2.2.1",
"eslint-plugin-html": "^6.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^22.15.1",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"husky": "^1.3.1",
"jest": "^23.6.0",
"jest-each": "^23.6.0",
"jest-environment-node": "^23.4.0",
"regenerator-runtime": "^0.13.1",
"rollup": "^1.1.0",
"rollup-plugin-babel": "^4.3.0",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-uglify": "^6.0.1"
"husky": "^3.0.4",
"jest": "^24.9.0",
"jest-each": "^24.9.0",
"jest-environment-node": "^24.9.0",
"regenerator-runtime": "^0.13.3",
"rollup": "^1.19.4",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.0.2",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-uglify": "^6.0.2"
},
"jest": {
"moduleDirectories": [
Expand Down
2 changes: 1 addition & 1 deletion src/dtmf.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const decode = (input, options = {}) => {
return foundCell[1]
}

if (lookup.hasOwnProperty(i)) {
if (typeof lookup[i] !== 'undefined') {
return lookup[i]
}

Expand Down
2 changes: 1 addition & 1 deletion src/fractionatedMorse.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const decode = (input, options = {}) => {
options = { ...DEFAULT_OPTIONS, ...options }
const morseOptions = { ...DEFAULT_MORSE_OPTION, ...{ failOnUnknownCharacter: options.failOnUnknownCharacter } }

let morseCode = [...input]
const morseCode = [...input]
.map(c => {
const decodedCharacterIndex = options.keyAlphabet.indexOf(c)
if (decodedCharacterIndex !== -1) {
Expand Down
2 changes: 1 addition & 1 deletion src/morse.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const ALPHABET = {
';': '-.-.-.',
'?': '..--..',
'-': '-....-',
'_': '..--.-',
_: '..--.-',
'(': '-.--.',
')': '-.--.-',
'\'': '.----.',
Expand Down
2 changes: 1 addition & 1 deletion src/polybius.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const decode = (input, options = {}) => {
options = { ...DEFAULT_OPTIONS, ...options }

const grid = prepareGridString(options)
let squareSize = options.withNumbers ? 6 : 5
const squareSize = options.withNumbers ? 6 : 5

return input
.split(' ')
Expand Down
10 changes: 5 additions & 5 deletions src/wolfenbuetteler.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const retrieveOptions = options => ({
})

const DEFAULT_MAPPING = {
'A': 'M',
'E': 'K',
'I': 'D',
'O': 'T',
'U': 'H'
A: 'M',
E: 'K',
I: 'D',
O: 'T',
U: 'H'
}
6 changes: 3 additions & 3 deletions test/aer256.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import aer256 from 'aer256'

describe('encoding', () => {
test('default', () => {
expect(() => { aer256.encode('1432.382960035134') }).toThrowError('Key is too short! It must be at least 3 characters')
expect(() => { aer256.encode('1432.382960035134') }).toThrow('Key is too short! It must be at least 3 characters')
})
test('with key', () => {
expect(aer256.encode('hey', { key: 'ABCDEF' })).toBe('1432.382960035134')
Expand All @@ -12,13 +12,13 @@ describe('encoding', () => {
expect(aer256.encode('hey!*Aäää', { key: 'ABCDEF*' })).toBe('384574.7097057532, 155650.8842775582, -27.9211682037769')
})
test('invalid characters', () => {
expect(() => { aer256.encode('💯文', {key: 'ABCDEF*'}) }).toThrowError('Invalid character')
expect(() => { aer256.encode('💯文', { key: 'ABCDEF*' }) }).toThrow('Invalid character')
})
})

describe('decoding', () => {
test('default', () => {
expect(() => { aer256.decode('1432.382960035134') }).toThrowError('Key is too short! It must be at least 3 characters')
expect(() => { aer256.decode('1432.382960035134') }).toThrow('Key is too short! It must be at least 3 characters')
})
test('with key', () => {
expect(aer256.decode('1432.382960035134', { key: 'ABCDEF' })).toBe('hey')
Expand Down
8 changes: 4 additions & 4 deletions test/affine.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('encoding', () => {
})
test('failing with unknown character', () => {
expect(() => { affine.encode('AB/', { failOnUnknownCharacter: true }) })
.toThrowError('Could not transform character')
.toThrow('Could not transform character')
})
test('omitting unknown character', () => {
expect(affine.encode('AB/', { omitUnknownCharacter: true })).toBe('BE')
Expand All @@ -24,7 +24,7 @@ describe('encoding', () => {
expect(affine.encode('ABCDEFGHIJKLMNOPQRSTUVWXYZ'.toLowerCase(), { keys: [25, 3] })).toBe('DCBAZYXWVUTSRQPONMLKJIHGFE'.toLowerCase())
})
test('illegal key', () => {
expect(() => { affine.encode('ABCDEFGHIJKLMNOPQRSTUVWXYZ', { keys: [1, 1] }) }).toThrowError('Illegal key')
expect(() => { affine.encode('ABCDEFGHIJKLMNOPQRSTUVWXYZ', { keys: [1, 1] }) }).toThrow('Illegal key')
})
})

Expand All @@ -40,7 +40,7 @@ describe('decoding', () => {
})
test('failing with unknown character', () => {
expect(() => { affine.decode('BE/', { failOnUnknownCharacter: true }) })
.toThrowError('Could not transform character')
.toThrow('Could not transform character')
})
test('omitting unknown character', () => {
expect(affine.decode('BE/', { omitUnknownCharacter: true })).toBe('AB')
Expand All @@ -52,6 +52,6 @@ describe('decoding', () => {
expect(affine.decode('DCBAZYXWVUTSRQPONMLKJIHGFE'.toLowerCase(), { keys: [25, 3] })).toBe('ABCDEFGHIJKLMNOPQRSTUVWXYZ'.toLowerCase())
})
test('illegal key', () => {
expect(() => { affine.decode('DCBAZYXWVUTSRQPONMLKJIHGFE', { keys: [1, 1] }) }).toThrowError('Illegal key')
expect(() => { affine.decode('DCBAZYXWVUTSRQPONMLKJIHGFE', { keys: [1, 1] }) }).toThrow('Illegal key')
})
})
4 changes: 2 additions & 2 deletions test/armon64.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import armon64 from 'armon64'

describe('encoding', () => {
test('default', () => {
expect(() => { armon64.encode('1007.3509783549783') }).toThrowError('Key is too short! It must be at least 3 characters')
expect(() => { armon64.encode('1007.3509783549783') }).toThrow('Key is too short! It must be at least 3 characters')
})
test('with key', () => {
expect(armon64.encode('hey', { key: 'ABCDEF' })).toBe('1007.3509783549783')
Expand All @@ -13,7 +13,7 @@ describe('encoding', () => {

describe('decoding', () => {
test('default', () => {
expect(() => { armon64.decode('1432.382960035134') }).toThrowError('Key is too short! It must be at least 3 characters')
expect(() => { armon64.decode('1432.382960035134') }).toThrow('Key is too short! It must be at least 3 characters')
})
test('with key', () => {
expect(armon64.decode('1007.3509783549783', { key: 'ABCDEF' })).toBe('hey')
Expand Down
12 changes: 6 additions & 6 deletions test/dtmf.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ describe('encoding', () => {
})

test('unknown mode', () => {
expect(() => { dtmf.encode(alphabet, { mode: 'UH' }) }).toThrowError('Unknown mode')
expect(() => { dtmf.encode(alphabet, { mode: 'UH' }) }).toThrow('Unknown mode')
})

test('invalid input', () => {
expect(() => { dtmf.encode('Y') }).toThrowError('Invalid input')
expect(() => { dtmf.encode('Y') }).toThrow('Invalid input')
})

test('invalid input with silentFail', () => {
Expand Down Expand Up @@ -74,13 +74,13 @@ describe('decoding', () => {
})

test('unknown mode', () => {
expect(() => { dtmf.decode(alphabet, { mode: 'UH' }) }).toThrowError('Unknown mode')
expect(() => { dtmf.decode(alphabet, { mode: 'UH' }) }).toThrow('Unknown mode')
})

test('invalid input', () => {
expect(() => { dtmf.decode('a') }).toThrowError('Could not decode a - No row found')
expect(() => { dtmf.decode('697') }).toThrowError('Could not decode 697 - No cell found')
expect(() => { dtmf.decode('a', { mode: 'sum' }) }).toThrowError('Could not decode a - No matching value')
expect(() => { dtmf.decode('a') }).toThrow('Could not decode a - No row found')
expect(() => { dtmf.decode('697') }).toThrow('Could not decode 697 - No cell found')
expect(() => { dtmf.decode('a', { mode: 'sum' }) }).toThrow('Could not decode a - No matching value')
})

test('invalid input with silent fail', () => {
Expand Down
8 changes: 4 additions & 4 deletions test/fractionatedMorse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ describe('encoding', () => {
expect(fractionatedMorse.encode('1234567890.,:;?-_()\'=+/@')).toBe('EOBOAOAFACJCMCNCNLNODKWBQMCKDSMHAFBKVMVMPNLJFDLJLED')
expect(fractionatedMorse.encode('A D E F')).toBe('FVIIBI')

expect(() => { fractionatedMorse.encode('€€€') }).toThrowError('Unencodable character')
expect(() => { fractionatedMorse.encode('Ü') }).toThrowError('Unencodable character')
expect(() => { fractionatedMorse.encode('A A') }).toThrowError('Unencodable character')
expect(() => { fractionatedMorse.encode('€€€') }).toThrow('Unencodable character')
expect(() => { fractionatedMorse.encode('Ü') }).toThrow('Unencodable character')
expect(() => { fractionatedMorse.encode('A A') }).toThrow('Unencodable character')
})

test('with different keyAlphabet', () => {
Expand All @@ -43,7 +43,7 @@ describe('decoding', () => {
expect(fractionatedMorse.decode('EOBOAOAFACJCMCNCNLNODKWBQMCKDSMHAFBKVMVMPNLJFDLJLED')).toBe('1234567890.,:;?-_()\'=+/@')
expect(fractionatedMorse.decode('FT')).toBe('A A')
expect(fractionatedMorse.decode('FVIIBI')).toBe('A D E F')
expect(() => { fractionatedMorse.decode('ÜÄÖ') }).toThrowError('Undecodable character')
expect(() => { fractionatedMorse.decode('ÜÄÖ') }).toThrow('Undecodable character')
})

test('with different keyAlphabet', () => {
Expand Down
10 changes: 5 additions & 5 deletions test/helpers/helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('randomInRange', () => {
expect(randomInRange(0, 0)).toBe(0)
})
test('returns error when min > max', () => {
expect(() => { randomInRange(1, 0) }).toThrowError('Min cannot be larger than max')
expect(() => { randomInRange(1, 0) }).toThrow('Min cannot be larger than max')
})
})

Expand All @@ -22,10 +22,10 @@ describe('modInverse', () => {
expect(modInverse(1, 2)).toBe(1)
})
test('it throws error on invalid input', () => {
expect(() => { modInverse(-1, 26) }).toThrowError()
expect(() => { modInverse(3, 1) }).toThrowError()
expect(() => { modInverse(3, 0) }).toThrowError()
expect(() => { modInverse('b', 'A') }).toThrowError()
expect(() => { modInverse(-1, 26) }).toThrow()
expect(() => { modInverse(3, 1) }).toThrow()
expect(() => { modInverse(3, 0) }).toThrow()
expect(() => { modInverse('b', 'A') }).toThrow()
})
test('it returns correct inverse for prime mods', () => {
expect(modInverse(1, 7)).toBe(1)
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/substitute.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { substitute } from 'helpers/substitute'

describe('substitute', () => {
const mappingOptions = { mapping: { 'A': 'M' } }
const mappingAndCaseInsensitiveOptions = { mapping: { 'A': 'M' }, caseSensitive: false }
const mappingOptions = { mapping: { A: 'M' } }
const mappingAndCaseInsensitiveOptions = { mapping: { A: 'M' }, caseSensitive: false }
test('default', () => {
expect(substitute('A')).toBe('A')
})
Expand Down
14 changes: 7 additions & 7 deletions test/manchester.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ describe('encoding', () => {

test('empty', () => {
expect(manchester.encode('', silentFailOptions)).toBe('')
expect(() => { manchester.encode('') }).toThrowError('Invalid Input after splitting')
expect(() => { manchester.encode('') }).toThrow('Invalid Input after splitting')
})

test('invalid', () => {
expect(manchester.encode('A', silentFailOptions)).toBe('')
expect(manchester.encode('€', silentFailOptions)).toBe('')
expect(manchester.encode('€0', silentFailOptions)).toBe('01')

expect(() => { manchester.encode('A') }).toThrowError('Invalid Input')
expect(() => { manchester.encode('€') }).toThrowError('Invalid Input')
expect(() => { manchester.encode('A') }).toThrow('Invalid Input')
expect(() => { manchester.encode('€') }).toThrow('Invalid Input')
})
})

Expand All @@ -55,7 +55,7 @@ describe('decoding', () => {

test('empty', () => {
expect(manchester.decode('', silentFailOptions)).toBe('')
expect(() => { manchester.decode('') }).toThrowError('Invalid Input after splitting')
expect(() => { manchester.decode('') }).toThrow('Invalid Input after splitting')
})

test('invalid', () => {
Expand All @@ -64,8 +64,8 @@ describe('decoding', () => {
expect(manchester.decode('€', silentFailOptions)).toBe('')
expect(manchester.decode('€01', silentFailOptions)).toBe('0')

expect(() => { manchester.decode('0') }).toThrowError('Invalid Input')
expect(() => { manchester.decode('A') }).toThrowError('Invalid Input')
expect(() => { manchester.decode('€') }).toThrowError('Invalid Input')
expect(() => { manchester.decode('0') }).toThrow('Invalid Input')
expect(() => { manchester.decode('A') }).toThrow('Invalid Input')
expect(() => { manchester.decode('€') }).toThrow('Invalid Input')
})
})
4 changes: 2 additions & 2 deletions test/morse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('decoding', () => {
})

test('decoding invalid character', () => {
expect(() => { morse.decode(invalidMorseCharacter.input) }).toThrowError('Undecodable character')
expect(() => { morse.decode(invalidMorseCharacter.input) }).toThrow('Undecodable character')
expect(morse.decode(invalidMorseCharacter.input, {
failOnUnknownCharacter: false
})).toBe(invalidMorseCharacter.preserve)
Expand All @@ -42,7 +42,7 @@ describe('encoding', () => {
expect(morse.encode(alphabet)).toBe(encodedAlphabet)
})
test('encoding invalid character', () => {
expect(() => { morse.encode(invalidCharacter.input) }).toThrowError('Unencodable character')
expect(() => { morse.encode(invalidCharacter.input) }).toThrow('Unencodable character')
expect(morse.encode(invalidCharacter.input, {
separator: '',
failOnUnknownCharacter: false
Expand Down
4 changes: 2 additions & 2 deletions test/multiTap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('encoding', () => {
})

test('with invalid characters', () => {
expect(() => { multiTap.encode('$') }).toThrowError('Unencodable character $')
expect(() => { multiTap.encode('$') }).toThrow('Unencodable character $')
})

test('with invalid characters and silent fail', () => {
Expand Down Expand Up @@ -81,7 +81,7 @@ describe('decoding', () => {
})

test('with invalid characters', () => {
expect(() => { multiTap.decode('$2') }).toThrowError('Undecodable character')
expect(() => { multiTap.decode('$2') }).toThrow('Undecodable character')
})

test('with invalid characters and silent fail', () => {
Expand Down
Loading

0 comments on commit 34f27b1

Please sign in to comment.