@@ -17,16 +17,11 @@ describe('base64ToUnicode/unicodeToBase64', () => {
1717 expect ( BASE64_REGEX . test ( unicodeToBase64 ( unicodeString ) ) ) . to . be . true ;
1818 } ) ;
1919
20- it ( 'works as expected' , ( ) => {
20+ it ( 'works as expected (and conversion functions are inverses) ' , ( ) => {
2121 expect ( unicodeToBase64 ( unicodeString ) ) . to . equal ( base64String ) ;
2222 expect ( base64ToUnicode ( base64String ) ) . to . equal ( unicodeString ) ;
2323 } ) ;
2424
25- it ( 'conversion functions are inverses' , ( ) => {
26- expect ( base64ToUnicode ( unicodeToBase64 ( unicodeString ) ) ) . to . equal ( unicodeString ) ;
27- expect ( unicodeToBase64 ( base64ToUnicode ( base64String ) ) ) . to . equal ( base64String ) ;
28- } ) ;
29-
3025 it ( 'can handle and preserve multi-byte characters in original string' , ( ) => {
3126 [ '🐶' , 'Καλό κορίτσι, Μάιζεϊ!' , 'Of margir hundar! Ég geri ráð fyrir að ég þurfi stærra rúm.' ] . forEach ( orig => {
3227 expect ( ( ) => {
@@ -56,9 +51,9 @@ describe('base64ToUnicode/unicodeToBase64', () => {
5651 expect ( ( ) => {
5752 base64ToUnicode ( { } as any ) ;
5853 } ) . to . throw ( 'Unable to convert from base64' ) ;
59-
60- // Note that by design, in node base64 encoding and decoding will accept any string, whether or not it's valid
61- // base64, by ignoring all invalid characters, including whitespace. Therefore, no wacky strings have been included
62- // here because they don't actually error.
54+ expect ( ( ) => {
55+ // the exclamation point makes this invalid base64
56+ base64ToUnicode ( 'Dogs are great!' ) ;
57+ } ) . to . throw ( 'Unable to convert from base64' ) ;
6358 } ) ;
6459} ) ;
0 commit comments