From 56ff52d01e1ef018e68f89615f1e074c7a06248a Mon Sep 17 00:00:00 2001 From: M-Scott-Lassiter Date: Sat, 30 Apr 2022 20:05:11 -0700 Subject: [PATCH] build: add @types/jest for type checking support in the testing suite --- index.test.js | 21 +++++++++++++++++---- package-lock.json | 21 +++++++++++++++++++++ package.json | 1 + 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/index.test.js b/index.test.js index a810faf..a73ea98 100644 --- a/index.test.js +++ b/index.test.js @@ -66,16 +66,18 @@ describe('Allow Lower Case Dictionaries', () => { test.each([true, 1, [123], { value: 1 }])( 'allowLowerCaseDictionary with truthy value %p', - (truthyValue) => { - encoder.allowLowerCaseDictionary = truthyValue + (truthyTestValue) => { + // @ts-ignore + encoder.allowLowerCaseDictionary = truthyTestValue expect(encoder.allowLowerCaseDictionary).toBeTruthy() } ) test.each([false, 0, null, undefined])( 'allowLowerCaseDictionary with falsy value %p', - (truthyValue) => { - encoder.allowLowerCaseDictionary = truthyValue + (truthyTestValue) => { + // @ts-ignore + encoder.allowLowerCaseDictionary = truthyTestValue expect(encoder.allowLowerCaseDictionary).toBeFalsy() } ) @@ -198,6 +200,7 @@ describe('Test Encoding', () => { test.each(numberToEncodedLetters)( 'Under default dictionary, expect %p to encode to %p', (number, letter) => { + // @ts-ignore expect(encoder.encode(number)).toBe(letter) } ) @@ -207,7 +210,9 @@ describe('Test Encoding', () => { test.each(numberWithDictionaryToEncodedLetters)( 'Under dictionary %p, expect %p to encode to %p', (dictionary, number, letter) => { + // @ts-ignore encoder.dictionary = dictionary + // @ts-ignore expect(encoder.encode(number)).toBe(letter) } ) @@ -218,7 +223,9 @@ describe('Test Encoding', () => { 'Under dictionary %p, expect %p to encode to %p', (dictionary, number, letter) => { encoder.allowLowerCaseDictionary = true + // @ts-ignore encoder.dictionary = dictionary + // @ts-ignore expect(encoder.encode(number)).toBe(letter) } ) @@ -243,6 +250,7 @@ describe('Test Decoding', () => { test.each(encodedWithNonexistentCharacter)( 'Under default dictionary, trying to decode %p will return "undefined" due to character not existing in dictionary', (letter) => { + // @ts-ignore expect(encoder.decode(letter)).toBeUndefined() } ) @@ -252,6 +260,7 @@ describe('Test Decoding', () => { test.each(numberToEncodedLetters)( 'Under default dictionary, expect %p to be decoded from %p', (number, letter) => { + // @ts-ignore expect(encoder.decode(letter)).toBe(number) } ) @@ -261,7 +270,9 @@ describe('Test Decoding', () => { test.each(numberWithDictionaryToEncodedLetters)( 'Under dictionary %p, expect %p to be decoded from %p', (dictionary, number, letter) => { + // @ts-ignore encoder.dictionary = dictionary + // @ts-ignore expect(encoder.decode(letter)).toBe(number) } ) @@ -272,7 +283,9 @@ describe('Test Decoding', () => { 'Under dictionary %p, expect %p to be decoded from %p', (dictionary, number, letter) => { encoder.allowLowerCaseDictionary = true + // @ts-ignore encoder.dictionary = dictionary + // @ts-ignore expect(encoder.decode(letter)).toBe(number) } ) diff --git a/package-lock.json b/package-lock.json index 4e719f7..c198f7d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "devDependencies": { "@semantic-release/changelog": "^6.0.1", "@semantic-release/git": "^10.0.1", + "@types/jest": "^27.4.1", "commitizen": "^4.2.4", "cz-customizable": "^6.3.0", "documentation": "^13.2.5", @@ -2300,6 +2301,16 @@ "@types/istanbul-lib-report": "*" } }, + "node_modules/@types/jest": { + "version": "27.4.1", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-27.4.1.tgz", + "integrity": "sha512-23iPJADSmicDVrWk+HT58LMJtzLAnB2AgIzplQuq/bSrGaxCrlvRFjGbXmamnnk/mAmCdLStiGqggu28ocUyiw==", + "dev": true, + "dependencies": { + "jest-matcher-utils": "^27.0.0", + "pretty-format": "^27.0.0" + } + }, "node_modules/@types/json-schema": { "version": "7.0.11", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", @@ -21257,6 +21268,16 @@ "@types/istanbul-lib-report": "*" } }, + "@types/jest": { + "version": "27.4.1", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-27.4.1.tgz", + "integrity": "sha512-23iPJADSmicDVrWk+HT58LMJtzLAnB2AgIzplQuq/bSrGaxCrlvRFjGbXmamnnk/mAmCdLStiGqggu28ocUyiw==", + "dev": true, + "requires": { + "jest-matcher-utils": "^27.0.0", + "pretty-format": "^27.0.0" + } + }, "@types/json-schema": { "version": "7.0.11", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", diff --git a/package.json b/package.json index 08ffd0a..50e3eb9 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "devDependencies": { "@semantic-release/changelog": "^6.0.1", "@semantic-release/git": "^10.0.1", + "@types/jest": "^27.4.1", "commitizen": "^4.2.4", "cz-customizable": "^6.3.0", "documentation": "^13.2.5",