diff options
Diffstat (limited to 'spec/frontend/authentication/webauthn/util_spec.js')
-rw-r--r-- | spec/frontend/authentication/webauthn/util_spec.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/spec/frontend/authentication/webauthn/util_spec.js b/spec/frontend/authentication/webauthn/util_spec.js index c9b8bfd8679..bc44b47d0ba 100644 --- a/spec/frontend/authentication/webauthn/util_spec.js +++ b/spec/frontend/authentication/webauthn/util_spec.js @@ -1,4 +1,4 @@ -import { base64ToBuffer, bufferToBase64 } from '~/authentication/webauthn/util'; +import { base64ToBuffer, bufferToBase64, base64ToBase64Url } from '~/authentication/webauthn/util'; const encodedString = 'SGVsbG8gd29ybGQh'; const stringBytes = [72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33]; @@ -16,4 +16,19 @@ describe('Webauthn utils', () => { const buffer = base64ToBuffer(encodedString); expect(bufferToBase64(buffer)).toBe(encodedString); }); + + describe('base64ToBase64Url', () => { + it.each` + argument | expectedResult + ${'asd+'} | ${'asd-'} + ${'asd/'} | ${'asd_'} + ${'asd='} | ${'asd'} + ${'+asd'} | ${'-asd'} + ${'/asd'} | ${'_asd'} + ${'=asd'} | ${'=asd'} + ${'a+bc/def=ghigjk=='} | ${'a-bc_def=ghigjk'} + `('returns $expectedResult when argument is $argument', ({ argument, expectedResult }) => { + expect(base64ToBase64Url(argument)).toBe(expectedResult); + }); + }); }); |