@@ -38,7 +38,8 @@ describe('base64 utils', () => {
38
38
39
39
it ( 'should throw for incorrect base64 string' , ( ) => {
40
40
expect ( ( ) => base64ToText ( 'a' ) ) . to . throw ( 'Incorrect base64 string' ) ;
41
- expect ( ( ) => base64ToText ( ' ' ) ) . to . throw ( 'Incorrect base64 string' ) ;
41
+ // should not really be false because trimming of space is now implied
42
+ // expect(() => base64ToText(' ')).to.throw('Incorrect base64 string');
42
43
expect ( ( ) => base64ToText ( 'é' ) ) . to . throw ( 'Incorrect base64 string' ) ;
43
44
// missing final '='
44
45
expect ( ( ) => base64ToText ( 'bG9yZW0gaXBzdW0' ) ) . to . throw ( 'Incorrect base64 string' ) ;
@@ -56,17 +57,17 @@ describe('base64 utils', () => {
56
57
57
58
it ( 'should return false for incorrect base64 string' , ( ) => {
58
59
expect ( isValidBase64 ( 'a' ) ) . to . eql ( false ) ;
59
- expect ( isValidBase64 ( ' ' ) ) . to . eql ( false ) ;
60
60
expect ( isValidBase64 ( 'é' ) ) . to . eql ( false ) ;
61
61
expect ( isValidBase64 ( 'data:text/plain;notbase64,YQ==' ) ) . to . eql ( false ) ;
62
62
// missing final '='
63
63
expect ( isValidBase64 ( 'bG9yZW0gaXBzdW0' ) ) . to . eql ( false ) ;
64
64
} ) ;
65
65
66
- it ( 'should return false for untrimmed correct base64 string' , ( ) => {
67
- expect ( isValidBase64 ( 'bG9yZW0gaXBzdW0= ' ) ) . to . eql ( false ) ;
68
- expect ( isValidBase64 ( ' LTE=' ) ) . to . eql ( false ) ;
69
- expect ( isValidBase64 ( ' YQ== ' ) ) . to . eql ( false ) ;
66
+ it ( 'should return true for untrimmed correct base64 string' , ( ) => {
67
+ expect ( isValidBase64 ( 'bG9yZW0gaXBzdW0= ' ) ) . to . eql ( true ) ;
68
+ expect ( isValidBase64 ( ' LTE=' ) ) . to . eql ( true ) ;
69
+ expect ( isValidBase64 ( ' YQ== ' ) ) . to . eql ( true ) ;
70
+ expect ( isValidBase64 ( ' ' ) ) . to . eql ( true ) ;
70
71
} ) ;
71
72
} ) ;
72
73
0 commit comments