Skip to content

Commit

Permalink
build: add @types/jest for type checking support in the testing suite
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Scott-Lassiter committed May 1, 2022
1 parent a1b7066 commit 56ff52d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
21 changes: 17 additions & 4 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
)
Expand Down Expand Up @@ -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)
}
)
Expand All @@ -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)
}
)
Expand All @@ -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)
}
)
Expand All @@ -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()
}
)
Expand All @@ -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)
}
)
Expand All @@ -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)
}
)
Expand All @@ -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)
}
)
Expand Down
21 changes: 21 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 56ff52d

Please sign in to comment.