File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
packages/optimizely-sdk/lib/utils/user_id_validator Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 11/**
2- * Copyright 2016, Optimizely
2+ * Copyright 2016, 2018, Optimizely
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -45,6 +45,20 @@ describe('lib/utils/user_id_validator', function() {
4545 userIdValidator . validate ( '' ) ;
4646 } , sprintf ( ERROR_MESSAGES . INVALID_USER_ID , 'USER_ID_VALIDATOR' ) ) ;
4747 } ) ;
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+ } ) ;
4862 } ) ;
4963 } ) ;
5064} ) ;
You can’t perform that action at this time.
0 commit comments