Skip to content
Myr

encode.test.ts

This file

Path

src/utils/encode.test.ts

71 lines · 2.2 KiB · TypeScript

Last changed by

refactor(TypeScript): enable strict null check (#280)Yusuke Wadabefore adoptionb55eb2e

History of this file

Take it

refactor(TypeScript): enable strict null check (#280)Yusuke Wadabefore adoptionb55eb2e

line 1why, one step back
1/* eslint-disable @typescript-eslint/ban-ts-comment */

feat(jwt): export jwt utils (#187)Minghebefore adoption4f97c6d

lines 2–7why, one step back
2import {
3 utf8ToUint8Array,4 decodeBase64,5 encodeBase64,6 encodeBase64URL,7 decodeBase64URL,

chore: absolute import to relative import (#228)Yusuke Wadabefore adoption6ddba47

line 8why, one step back
8} from './encode'

feat(jwt): jwt middleware (#169)Minghebefore adoption3ed40d5

lines 9–17why, one step back
9
10describe('encode', () => {11 describe('base64', () => {12 it('encodeBase64', () => {13 expect(encodeBase64('hooooooooo')).toBe('aG9vb29vb29vbw==')14 expect(encodeBase64('炎')).toBe('54KO')15 expect(encodeBase64('abcdef')).not.toBe('abcdedf')16 expect(encodeBase64('')).toBe('')17 expect(() => {

refactor(TypeScript): enable strict null check (#280)Yusuke Wadabefore adoptionb55eb2e

line 18why, one step back
18 // @ts-ignore

feat(jwt): jwt middleware (#169)Minghebefore adoption3ed40d5

lines 19–28why, one step back
19 encodeBase64(null)
20 }).toThrow(TypeError)21 })2223 it('decodeBase64', async () => {24 expect(decodeBase64('aG9vb29vb29vbw==')).toBe('hooooooooo')25 expect(decodeBase64('54KO')).toBe('炎')26 expect(decodeBase64('abcdedf')).not.toBe('abcdef')27 expect(decodeBase64('')).toBe('')28 expect(() => {

refactor(TypeScript): enable strict null check (#280)Yusuke Wadabefore adoptionb55eb2e

line 29why, one step back
29 // @ts-ignore

feat(jwt): jwt middleware (#169)Minghebefore adoption3ed40d5

lines 30–36why, one step back
30 decodeBase64(null)
31 }).toThrowError(TypeError)32 })33 })34 describe('base64url', () => {35 it('encodeBase64URL', () => {36 expect(encodeBase64URL('hooooooooo')).toBe('aG9vb29vb29vbw')

feat: enable adding types for Env variables (#191)Yusuke Wadabefore adoption77b93ab

lines 37–39why, one step back
37 expect(encodeBase64URL('http://github.com/honojs/hono')).toBe(
38 'aHR0cDovL2dpdGh1Yi5jb20vaG9ub2pzL2hvbm8'39 )

feat(jwt): jwt middleware (#169)Minghebefore adoption3ed40d5

lines 40–43why, one step back
40 expect(encodeBase64URL('炎')).toBe('54KO')
41 expect(encodeBase64URL('abcdef')).not.toBe('abcdedf')42 expect(encodeBase64URL('')).toBe('')43 expect(() => {

refactor(TypeScript): enable strict null check (#280)Yusuke Wadabefore adoptionb55eb2e

line 44why, one step back
44 // @ts-ignore

feat(jwt): jwt middleware (#169)Minghebefore adoption3ed40d5

lines 45–50why, one step back
45 encodeBase64URL(null)
46 }).toThrow(TypeError)47 })4849 it('decodeBase64URL', async () => {50 expect(decodeBase64URL('aG9vb29vb29vbw')).toBe('hooooooooo')

feat: enable adding types for Env variables (#191)Yusuke Wadabefore adoption77b93ab

lines 51–53why, one step back
51 expect(decodeBase64URL('aHR0cDovL2dpdGh1Yi5jb20vaG9ub2pzL2hvbm8')).toBe(
52 'http://github.com/honojs/hono'53 )

feat(jwt): jwt middleware (#169)Minghebefore adoption3ed40d5

lines 54–57why, one step back
54 expect(decodeBase64URL('54KO')).toBe('炎')
55 expect(decodeBase64URL('abcdedf')).not.toBe('abcdef')56 expect(decodeBase64URL('')).toBe('')57 expect(() => {

refactor(TypeScript): enable strict null check (#280)Yusuke Wadabefore adoptionb55eb2e

line 58why, one step back
58 // @ts-ignore

feat(jwt): jwt middleware (#169)Minghebefore adoption3ed40d5

lines 59–60why, one step back
59 decodeBase64URL(null)
60 }).toThrowError(TypeError)

feat(jwt): export jwt utils (#187)Minghebefore adoption4f97c6d

lines 61–64why, one step back
61 })
62 })6364 describe('utf8ToUint8Array', () => {

feat: enable adding types for Env variables (#191)Yusuke Wadabefore adoption77b93ab

line 65why, one step back
65 it('should be equal', () => {

feat(jwt): export jwt utils (#187)Minghebefore adoption4f97c6d

lines 66–68why, one step back
66 const k = 'a-secret-key'
67 const arr = utf8ToUint8Array(k)68 expect(String(arr)).toEqual('97,45,115,101,99,114,101,116,45,107,101,121')

feat(jwt): jwt middleware (#169)Minghebefore adoption3ed40d5

lines 69–71why, one step back
69 })
70 })71})