-
-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add unit tests for "getPublicData"
- Loading branch information
1 parent
77f4ad2
commit 3ed3d49
Showing
1 changed file
with
38 additions
and
0 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,38 @@ | ||
import { getPublicData } from './getPublicData' | ||
|
||
it('returns a short string as-is', async () => { | ||
expect(await getPublicData('')).toBe('') | ||
expect(await getPublicData('hello')).toBe('hello') | ||
}) | ||
|
||
it('returns a truncated long string', async () => { | ||
expect(await getPublicData('this is a very long string')).toBe( | ||
'this is a very long stri…', | ||
) | ||
}) | ||
|
||
it('returns a short Blob text as-is', async () => { | ||
expect(await getPublicData(new Blob(['']))).toBe('Blob()') | ||
expect(await getPublicData(new Blob(['hello']))).toBe('Blob(hello)') | ||
}) | ||
|
||
it('returns a truncated long Blob text', async () => { | ||
expect(await getPublicData(new Blob(['this is a very long string']))).toBe( | ||
'Blob(this is a very long stri…)', | ||
) | ||
}) | ||
|
||
it('returns a short ArrayBuffer text as-is', async () => { | ||
expect(await getPublicData(new TextEncoder().encode(''))).toBe( | ||
'ArrayBuffer()', | ||
) | ||
expect(await getPublicData(new TextEncoder().encode('hello'))).toBe( | ||
'ArrayBuffer(hello)', | ||
) | ||
}) | ||
|
||
it('returns a truncated ArrayBuffer text', async () => { | ||
expect( | ||
await getPublicData(new TextEncoder().encode('this is a very long string')), | ||
).toBe('ArrayBuffer(this is a very long stri…)') | ||
}) |