@@ -5,10 +5,7 @@ describe('format(credentials)', function () {
55 describe ( 'arguments' , function ( ) {
66 describe ( 'credentials' , function ( ) {
77 it ( 'should be required' , function ( ) {
8- assert . throws (
9- ( ) => ( format as any ) ( ) ,
10- / a r g u m e n t c r e d e n t i a l s i s r e q u i r e d / ,
11- ) ;
8+ assert . throws ( ( ) => ( format as any ) ( ) , / E x p e c t e d a n o b j e c t / ) ;
129 } ) ;
1310
1411 it ( 'should accept credentials' , function ( ) {
@@ -17,65 +14,56 @@ describe('format(credentials)', function () {
1714 } ) ;
1815
1916 it ( 'should reject null' , function ( ) {
20- assert . throws (
21- format . bind ( null , null as any ) ,
22- / a r g u m e n t c r e d e n t i a l s i s r e q u i r e d / ,
23- ) ;
17+ assert . throws ( format . bind ( null , null as any ) , / E x p e c t e d a n o b j e c t / ) ;
2418 } ) ;
2519
2620 it ( 'should reject a number' , function ( ) {
27- assert . throws (
28- format . bind ( null , 42 as any ) ,
29- / a r g u m e n t c r e d e n t i a l s i s r e q u i r e d / ,
30- ) ;
21+ assert . throws ( format . bind ( null , 42 as any ) , / E x p e c t e d a n o b j e c t / ) ;
3122 } ) ;
3223
3324 it ( 'should reject a string' , function ( ) {
34- assert . throws (
35- format . bind ( null , '' as any ) ,
36- / a r g u m e n t c r e d e n t i a l s i s r e q u i r e d / ,
37- ) ;
25+ assert . throws ( format . bind ( null , '' as any ) , / E x p e c t e d a n o b j e c t / ) ;
3826 } ) ;
3927
4028 it ( 'should reject an object without name' , function ( ) {
4129 assert . throws (
4230 format . bind ( null , { pass : 'bar' } as any ) ,
43- / a r g u m e n t c r e d e n t i a l s i s r e q u i r e d t o h a v e n a m e a n d p a s s p r o p e r t i e s / ,
31+ / O b j e c t m u s t h a v e s t r i n g p r o p e r t i e s " n a m e " a n d " p a s s " / ,
4432 ) ;
4533 } ) ;
4634
4735 it ( 'should reject an object without pass' , function ( ) {
4836 assert . throws (
4937 format . bind ( null , { name : 'foo' } as any ) ,
50- / a r g u m e n t c r e d e n t i a l s i s r e q u i r e d t o h a v e n a m e a n d p a s s p r o p e r t i e s / ,
38+ / O b j e c t m u s t h a v e s t r i n g p r o p e r t i e s " n a m e " a n d " p a s s " / ,
5139 ) ;
5240 } ) ;
5341
5442 it ( 'should reject an object with non-string name' , function ( ) {
5543 assert . throws (
5644 format . bind ( null , { name : 42 , pass : 'bar' } as any ) ,
57- / a r g u m e n t c r e d e n t i a l s i s r e q u i r e d t o h a v e n a m e a n d p a s s p r o p e r t i e s / ,
45+ / O b j e c t m u s t h a v e s t r i n g p r o p e r t i e s " n a m e " a n d " p a s s " / ,
5846 ) ;
5947 } ) ;
6048
6149 it ( 'should reject an object with non-string pass' , function ( ) {
6250 assert . throws (
6351 format . bind ( null , { name : 'foo' , pass : 42 } as any ) ,
64- / a r g u m e n t c r e d e n t i a l s i s r e q u i r e d t o h a v e n a m e a n d p a s s p r o p e r t i e s / ,
52+ / O b j e c t m u s t h a v e s t r i n g p r o p e r t i e s " n a m e " a n d " p a s s " / ,
6553 ) ;
6654 } ) ;
6755
6856 it ( 'should reject userid containing colon' , function ( ) {
6957 assert . throws (
7058 format . bind ( null , { name : 'foo:bar' , pass : 'baz' } ) ,
71- / m u s t n o t c o n t a i n a c o l o n o r c o n t r o l c h a r a c t e r s / ,
59+ / m u s t n o t c o n t a i n a c o l o n / ,
7260 ) ;
7361 } ) ;
7462
7563 it ( 'should reject control chars in userid' , function ( ) {
7664 assert . throws (
7765 format . bind ( null , { name : 'foo\u0000bar' , pass : 'baz' } ) ,
78- / m u s t n o t c o n t a i n a c o l o n o r c o n t r o l c h a r a c t e r s / ,
66+ / m u s t n o t c o n t a i n c o n t r o l c h a r a c t e r s / ,
7967 ) ;
8068 } ) ;
8169
@@ -96,21 +84,21 @@ describe('format(credentials)', function () {
9684 } ) ;
9785
9886 describe ( 'with empty password' , function ( ) {
99- it ( 'should throw ' , function ( ) {
87+ it ( 'should return header ' , function ( ) {
10088 const header = format ( { name : 'foo' , pass : '' } ) ;
10189 assert . strictEqual ( header , 'Basic Zm9vOg==' ) ;
10290 } ) ;
10391 } ) ;
10492
10593 describe ( 'with empty userid' , function ( ) {
106- it ( 'should throw ' , function ( ) {
94+ it ( 'should return header ' , function ( ) {
10795 const header = format ( { name : '' , pass : 'pass' } ) ;
10896 assert . strictEqual ( header , 'Basic OnBhc3M=' ) ;
10997 } ) ;
11098 } ) ;
11199
112100 describe ( 'with empty userid and pass' , function ( ) {
113- it ( 'should throw ' , function ( ) {
101+ it ( 'should return header ' , function ( ) {
114102 const header = format ( { name : '' , pass : '' } ) ;
115103 assert . strictEqual ( header , 'Basic Og==' ) ;
116104 } ) ;
0 commit comments