@@ -127,19 +127,19 @@ describe("ScopeSet.ts", () => {
127
127
} ) ;
128
128
129
129
it ( "appendScope() does nothing if given scope is empty, null or undefined" , ( ) => {
130
+ const testScopes = [ testScope ] ;
130
131
const setAddSpy = sinon . spy ( Set . prototype , "add" ) ;
131
-
132
- expect ( ( ) => scopes . appendScope ( "" ) ) . to . throw ( ClientAuthError ) ;
133
- expect ( ( ) => scopes . appendScope ( "" ) ) . to . throw ( ClientAuthErrorMessage . appendEmptyScopeError . desc ) ;
132
+ scopes . appendScope ( "" ) ;
134
133
expect ( setAddSpy . called ) . to . be . false ;
134
+ expect ( scopes . asArray ( ) ) . to . be . deep . eq ( testScopes ) ;
135
135
136
- expect ( ( ) => scopes . appendScope ( null ) ) . to . throw ( ClientAuthError ) ;
137
- expect ( ( ) => scopes . appendScope ( null ) ) . to . throw ( ClientAuthErrorMessage . appendEmptyScopeError . desc ) ;
136
+ scopes . appendScope ( null ) ;
138
137
expect ( setAddSpy . called ) . to . be . false ;
138
+ expect ( scopes . asArray ( ) ) . to . be . deep . eq ( testScopes ) ;
139
139
140
- expect ( ( ) => scopes . appendScope ( undefined ) ) . to . throw ( ClientAuthError ) ;
141
- expect ( ( ) => scopes . appendScope ( undefined ) ) . to . throw ( ClientAuthErrorMessage . appendEmptyScopeError . desc ) ;
140
+ scopes . appendScope ( undefined ) ;
142
141
expect ( setAddSpy . called ) . to . be . false ;
142
+ expect ( scopes . asArray ( ) ) . to . be . deep . eq ( testScopes ) ;
143
143
} ) ;
144
144
145
145
it ( "appendScopes() throws error if given array is null or undefined" , ( ) => {
@@ -164,6 +164,16 @@ describe("ScopeSet.ts", () => {
164
164
expect ( scopes . asArray ( ) ) . to . contain ( testScope3 ) ;
165
165
} ) ;
166
166
167
+ it ( "appendScopes() trims and converts scopes to lower case before adding" , ( ) => {
168
+ const testScope2 = "TestScope2" ;
169
+ const expectedTestScope2 = "testscope2" ;
170
+ const testScope3 = " testscope3 " ;
171
+ const expectedTestScope3 = "testscope3" ;
172
+ scopes . appendScopes ( [ testScope2 , testScope3 ] ) ;
173
+ expect ( scopes . asArray ( ) ) . to . contain ( expectedTestScope2 ) ;
174
+ expect ( scopes . asArray ( ) ) . to . contain ( expectedTestScope3 ) ;
175
+ } )
176
+
167
177
it ( "appendScopes() does not add duplicate scopes" , ( ) => {
168
178
const unchangedScopes = new ScopeSet ( [ testScope , Constants . OFFLINE_ACCESS_SCOPE ] ) ;
169
179
const scopeArr = unchangedScopes . asArray ( ) ;
0 commit comments