File tree 1 file changed +15
-1
lines changed
packages/optimizely-sdk/lib/utils/user_id_validator
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
- * Copyright 2016, Optimizely
2
+ * Copyright 2016, 2018, Optimizely
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -45,6 +45,20 @@ describe('lib/utils/user_id_validator', function() {
45
45
userIdValidator . validate ( '' ) ;
46
46
} , sprintf ( ERROR_MESSAGES . INVALID_USER_ID , 'USER_ID_VALIDATOR' ) ) ;
47
47
} ) ;
48
+
49
+ it ( 'should throw an error if userId is not a string' , function ( ) {
50
+ assert . throws ( function ( ) {
51
+ userIdValidator . validate ( 3 ) ;
52
+ } , sprintf ( ERROR_MESSAGES . INVALID_USER_ID , 'USER_ID_VALIDATOR' ) ) ;
53
+
54
+ assert . throws ( function ( ) {
55
+ userIdValidator . validate ( true ) ;
56
+ } , sprintf ( ERROR_MESSAGES . INVALID_USER_ID , 'USER_ID_VALIDATOR' ) ) ;
57
+
58
+ assert . throws ( function ( ) {
59
+ userIdValidator . validate ( [ ] ) ;
60
+ } , sprintf ( ERROR_MESSAGES . INVALID_USER_ID , 'USER_ID_VALIDATOR' ) ) ;
61
+ } ) ;
48
62
} ) ;
49
63
} ) ;
50
64
} ) ;
You can’t perform that action at this time.
0 commit comments