@@ -60,55 +60,3 @@ describe('fromMatrixID', () => {
6060 expect ( fromMatrixID ( `custom_${ encoded . split ( '_' ) [ 1 ] } ` ) ) . toBe ( 'file.txt' ) ;
6161 } ) ;
6262} ) ;
63-
64- describe ( 'runtime fallbacks' , ( ) => {
65- const originalBtoa = globalThis . btoa ;
66- const originalAtob = globalThis . atob ;
67- const originalBuffer = globalThis . Buffer ;
68-
69- afterEach ( ( ) => {
70- globalThis . btoa = originalBtoa ;
71- globalThis . atob = originalAtob ;
72- globalThis . Buffer = originalBuffer ;
73- } ) ;
74-
75- it ( 'uses Buffer fallback when btoa is unavailable' , ( ) => {
76- // @ts -expect-error test override
77- globalThis . btoa = undefined ;
78-
79- const result = toMatrixID ( 'buffer-test.txt' , 'mxc_' ) ;
80-
81- expect ( result ) . toBe ( 'mxc_YnVmZmVyLXRlc3QudHh0' ) ;
82- } ) ;
83-
84- it ( 'uses Buffer fallback when atob is unavailable' , ( ) => {
85- // @ts -expect-error test override
86- globalThis . atob = undefined ;
87-
88- const encoded = toMatrixID ( 'buffer-decode.txt' , 'mxc_' ) ;
89-
90- expect ( fromMatrixID ( encoded ) ) . toBe ( 'buffer-decode.txt' ) ;
91- } ) ;
92-
93- it ( 'throws if no encoder runtime is available' , async ( ) => {
94- // @ts -expect-error test override
95- globalThis . btoa = undefined ;
96- // @ts -expect-error test override
97- globalThis . Buffer = undefined ;
98-
99- expect ( ( ) => toMatrixID ( 'fail.txt' , 'mxc_' ) ) . toThrow (
100- 'No base64 encoder available in this runtime' ,
101- ) ;
102- } ) ;
103-
104- it ( 'throws if no decoder runtime is available' , async ( ) => {
105- // @ts -expect-error test override
106- globalThis . atob = undefined ;
107- // @ts -expect-error test override
108- globalThis . Buffer = undefined ;
109-
110- expect ( ( ) => fromMatrixID ( 'mxc_ZmlsZS50eHQ' ) ) . toThrow (
111- 'No base64 decoder available in this runtime' ,
112- ) ;
113- } ) ;
114- } ) ;
0 commit comments