@@ -21,7 +21,7 @@ describe('AppAuth', () => {
21
21
mockRefresh . mockReturnValue ( 'REFRESHED' ) ;
22
22
} ) ;
23
23
24
- const baseConfig = {
24
+ const config = {
25
25
issuer : 'test-issuer' ,
26
26
redirectUrl : 'test-redirectUrl' ,
27
27
clientId : 'test-clientId' ,
@@ -37,42 +37,42 @@ describe('AppAuth', () => {
37
37
38
38
it ( 'throws an error when issuer is not a string' , ( ) => {
39
39
expect ( ( ) => {
40
- authorize ( { ...baseConfig , issuer : ( ) => ( { } ) } ) ;
40
+ authorize ( { ...config , issuer : ( ) => ( { } ) } ) ;
41
41
} ) . toThrow ( 'Config error: issuer must be a string' ) ;
42
42
} ) ;
43
43
44
44
it ( 'throws an error when redirectUrl is not a string' , ( ) => {
45
45
expect ( ( ) => {
46
- authorize ( { ...baseConfig , redirectUrl : { } } ) ;
46
+ authorize ( { ...config , redirectUrl : { } } ) ;
47
47
} ) . toThrow ( 'Config error: redirectUrl must be a string' ) ;
48
48
} ) ;
49
49
50
50
it ( 'throws an error when clientId is not a string' , ( ) => {
51
51
expect ( ( ) => {
52
- authorize ( { ...baseConfig , clientId : 123 } ) ;
52
+ authorize ( { ...config , clientId : 123 } ) ;
53
53
} ) . toThrow ( 'Config error: clientId must be a string' ) ;
54
54
} ) ;
55
55
56
56
it ( 'throws an error when no scopes are passed in' , ( ) => {
57
57
expect ( ( ) => {
58
- authorize ( { ...baseConfig , scopes : undefined } ) ;
58
+ authorize ( { ...config , scopes : undefined } ) ;
59
59
} ) . toThrow ( 'Scope error: please add at least one scope' ) ;
60
60
} ) ;
61
61
62
62
it ( 'throws an error when an empty scope array is passed in' , ( ) => {
63
63
expect ( ( ) => {
64
- authorize ( { ...baseConfig , scopes : [ ] } ) ;
64
+ authorize ( { ...config , scopes : [ ] } ) ;
65
65
} ) . toThrow ( 'Scope error: please add at least one scope' ) ;
66
66
} ) ;
67
67
68
68
it ( 'calls the native wrapper with the correct args' , ( ) => {
69
- authorize ( baseConfig ) ;
69
+ authorize ( config ) ;
70
70
expect ( mockAuthorize ) . toHaveBeenCalledWith (
71
- baseConfig . issuer ,
72
- baseConfig . redirectUrl ,
73
- baseConfig . clientId ,
74
- baseConfig . scopes ,
75
- baseConfig . additionalParameters
71
+ config . issuer ,
72
+ config . redirectUrl ,
73
+ config . clientId ,
74
+ config . scopes ,
75
+ config . additionalParameters
76
76
) ;
77
77
} ) ;
78
78
} ) ;
@@ -85,49 +85,49 @@ describe('AppAuth', () => {
85
85
86
86
it ( 'throws an error when issuer is not a string' , ( ) => {
87
87
expect ( ( ) => {
88
- authorize ( { ...baseConfig , issuer : ( ) => ( { } ) } ) ;
88
+ authorize ( { ...config , issuer : ( ) => ( { } ) } ) ;
89
89
} ) . toThrow ( 'Config error: issuer must be a string' ) ;
90
90
} ) ;
91
91
92
92
it ( 'throws an error when redirectUrl is not a string' , ( ) => {
93
93
expect ( ( ) => {
94
- authorize ( { ...baseConfig , redirectUrl : { } } ) ;
94
+ authorize ( { ...config } , { redirectUrl : { } } ) ;
95
95
} ) . toThrow ( 'Config error: redirectUrl must be a string' ) ;
96
96
} ) ;
97
97
98
98
it ( 'throws an error when clientId is not a string' , ( ) => {
99
99
expect ( ( ) => {
100
- authorize ( { ...baseConfig , clientId : 123 } ) ;
100
+ authorize ( { ...config , clientId : 123 } ) ;
101
101
} ) . toThrow ( 'Config error: clientId must be a string' ) ;
102
102
} ) ;
103
103
104
104
it ( 'throws an error when no refreshToken is passed in' , ( ) => {
105
105
expect ( ( ) => {
106
- refresh ( baseConfig ) ;
106
+ refresh ( config ) ;
107
107
} ) . toThrow ( 'Please pass in a refresh token' ) ;
108
108
} ) ;
109
109
110
110
it ( 'throws an error when no scopes are passed in' , ( ) => {
111
111
expect ( ( ) => {
112
- refresh ( { ...baseConfig , refreshToken : 'such-token' , scopes : undefined } ) ;
112
+ refresh ( { ...config , scopes : undefined } , { refreshToken : 'such-token' } ) ;
113
113
} ) . toThrow ( 'Scope error: please add at least one scope' ) ;
114
114
} ) ;
115
115
116
116
it ( 'throws an error when an empty scope array is passed in' , ( ) => {
117
117
expect ( ( ) => {
118
- refresh ( { ...baseConfig , refreshToken : 'such-token' , scopes : [ ] } ) ;
118
+ refresh ( { ...config , scopes : [ ] } , { refreshToken : 'such-token' } ) ;
119
119
} ) . toThrow ( 'Scope error: please add at least one scope' ) ;
120
120
} ) ;
121
121
122
122
it ( 'calls the native wrapper with the correct args' , ( ) => {
123
- refresh ( { ...baseConfig , refreshToken : 'such-token' } ) ;
123
+ refresh ( { ...config } , { refreshToken : 'such-token' } ) ;
124
124
expect ( mockRefresh ) . toHaveBeenCalledWith (
125
- baseConfig . issuer ,
126
- baseConfig . redirectUrl ,
127
- baseConfig . clientId ,
125
+ config . issuer ,
126
+ config . redirectUrl ,
127
+ config . clientId ,
128
128
'such-token' ,
129
- baseConfig . scopes ,
130
- baseConfig . additionalParameters
129
+ config . scopes ,
130
+ config . additionalParameters
131
131
) ;
132
132
} ) ;
133
133
} ) ;
0 commit comments