@@ -17,16 +17,11 @@ describe('base64ToUnicode/unicodeToBase64', () => {
17
17
expect ( BASE64_REGEX . test ( unicodeToBase64 ( unicodeString ) ) ) . to . be . true ;
18
18
} ) ;
19
19
20
- it ( 'works as expected' , ( ) => {
20
+ it ( 'works as expected (and conversion functions are inverses) ' , ( ) => {
21
21
expect ( unicodeToBase64 ( unicodeString ) ) . to . equal ( base64String ) ;
22
22
expect ( base64ToUnicode ( base64String ) ) . to . equal ( unicodeString ) ;
23
23
} ) ;
24
24
25
- it ( 'conversion functions are inverses' , ( ) => {
26
- expect ( base64ToUnicode ( unicodeToBase64 ( unicodeString ) ) ) . to . equal ( unicodeString ) ;
27
- expect ( unicodeToBase64 ( base64ToUnicode ( base64String ) ) ) . to . equal ( base64String ) ;
28
- } ) ;
29
-
30
25
it ( 'can handle and preserve multi-byte characters in original string' , ( ) => {
31
26
[ '🐶' , 'Καλό κορίτσι, Μάιζεϊ!' , 'Of margir hundar! Ég geri ráð fyrir að ég þurfi stærra rúm.' ] . forEach ( orig => {
32
27
expect ( ( ) => {
@@ -56,9 +51,9 @@ describe('base64ToUnicode/unicodeToBase64', () => {
56
51
expect ( ( ) => {
57
52
base64ToUnicode ( { } as any ) ;
58
53
} ) . 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' ) ;
63
58
} ) ;
64
59
} ) ;
0 commit comments