From 6a7fcb14aaff70d8438167b652b365406b37613c Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 7 Feb 2022 18:16:03 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/frontend/authentication/webauthn/util_spec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 spec/frontend/authentication/webauthn/util_spec.js (limited to 'spec/frontend/authentication') diff --git a/spec/frontend/authentication/webauthn/util_spec.js b/spec/frontend/authentication/webauthn/util_spec.js new file mode 100644 index 00000000000..c9b8bfd8679 --- /dev/null +++ b/spec/frontend/authentication/webauthn/util_spec.js @@ -0,0 +1,19 @@ +import { base64ToBuffer, bufferToBase64 } from '~/authentication/webauthn/util'; + +const encodedString = 'SGVsbG8gd29ybGQh'; +const stringBytes = [72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33]; + +describe('Webauthn utils', () => { + it('base64ToBuffer', () => { + const toArray = (val) => new Uint8Array(val); + + expect(base64ToBuffer(encodedString)).toBeInstanceOf(ArrayBuffer); + + expect(toArray(base64ToBuffer(encodedString))).toEqual(toArray(stringBytes)); + }); + + it('bufferToBase64', () => { + const buffer = base64ToBuffer(encodedString); + expect(bufferToBase64(buffer)).toBe(encodedString); + }); +}); -- cgit v1.2.3