-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for getBytes and getDeepLApiBaseUrl
(#31)
- Loading branch information
1 parent
730ca16
commit 2d9e729
Showing
3 changed files
with
68 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { getBlobBytes } from '../src/sheetsl'; | ||
|
||
Utilities.newBlob = jest.fn((text: string) => ({ | ||
getBytes: jest.fn(() => ({ | ||
length: text.length, | ||
})), | ||
})) as any; | ||
|
||
const patterns = [ | ||
{ | ||
input: 'test string', | ||
expectedOutput: 11, | ||
}, | ||
]; | ||
|
||
describe.each(patterns)('getBlobBytes', ({ input, expectedOutput }) => { | ||
test(`getBlobBytes test: ${input}`, () => { | ||
expect(getBlobBytes(input)).toBe(expectedOutput); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { | ||
DEEPL_API_BASE_URL_FREE, | ||
DEEPL_API_BASE_URL_PRO, | ||
getDeepLApiBaseUrl, | ||
} from '../src/sheetsl'; | ||
|
||
const patterns = [ | ||
{ | ||
title: 'DeepL API Free account', | ||
input: 'xxxxxxxxxxx:fx', | ||
expectedOutput: DEEPL_API_BASE_URL_FREE, | ||
}, | ||
{ | ||
title: 'DeepL API Pro account', | ||
input: 'xxxxxxxxxxx', | ||
expectedOutput: DEEPL_API_BASE_URL_PRO, | ||
}, | ||
]; | ||
|
||
describe.each(patterns)( | ||
'getDeepLApiBaseUrl', | ||
({ title, input, expectedOutput }) => { | ||
test(`getDeepLApiBaseUrl test: ${title}`, () => { | ||
expect(getDeepLApiBaseUrl(input)).toBe(expectedOutput); | ||
}); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters