@@ -65,89 +65,182 @@ describe('setup', () => {
65
65
expect ( model ) . toMatchSnapshot ( ) ;
66
66
} ) ;
67
67
68
- it ( 'default clientBaseUrl should use the specified domain' , ( ) => {
69
- const { mock } = mockInit ;
68
+ describe ( 'clientBaseUrl' , ( ) => {
69
+ it ( 'should default to the specified domain' , ( ) => {
70
+ const { mock } = mockInit ;
70
71
71
- setup (
72
- 'id' ,
73
- 'clientID' ,
74
- 'my-tenant.us.auth0.com' ,
75
- { } ,
76
- 'hookRunner' ,
77
- 'emitEventFn' ,
78
- 'handleEventFn'
79
- ) ;
72
+ setup (
73
+ 'id' ,
74
+ 'clientID' ,
75
+ 'my-tenant.us.auth0.com' ,
76
+ { } ,
77
+ 'hookRunner' ,
78
+ 'emitEventFn' ,
79
+ 'handleEventFn'
80
+ ) ;
80
81
81
- expect ( mock . calls . length ) . toBe ( 1 ) ;
82
+ expect ( mock . calls . length ) . toBe ( 1 ) ;
82
83
83
- const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
84
- expect ( model . clientBaseUrl ) . toBe ( 'https://my-tenant.us.auth0.com' ) ;
85
- } ) ;
84
+ const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
85
+ expect ( model . clientBaseUrl ) . toBe ( 'https://my-tenant.us.auth0.com' ) ;
86
+ } ) ;
86
87
87
- it ( 'clientBaseUrl should use clientBaseUrl if given' , ( ) => {
88
- const { mock } = mockInit ;
88
+ it ( 'should use the clientBaseUrl option if given' , ( ) => {
89
+ const { mock } = mockInit ;
89
90
90
- setup (
91
- 'id' ,
92
- 'clientID' ,
93
- 'my-tenant.us.auth0.com' ,
94
- {
95
- clientBaseUrl : 'https://client-base-url.example.com' ,
96
- configurationBaseUrl : 'https://config-base-url.example.com' ,
97
- assetsUrl : 'https://assets-url.example.com'
98
- } ,
99
- 'hookRunner' ,
100
- 'emitEventFn' ,
101
- 'handleEventFn'
102
- ) ;
91
+ setup (
92
+ 'id' ,
93
+ 'clientID' ,
94
+ 'my-tenant.us.auth0.com' ,
95
+ {
96
+ clientBaseUrl : 'https://client-base-url.example.com' ,
97
+ configurationBaseUrl : 'https://config-base-url.example.com' ,
98
+ assetsUrl : 'https://assets-url.example.com'
99
+ } ,
100
+ 'hookRunner' ,
101
+ 'emitEventFn' ,
102
+ 'handleEventFn'
103
+ ) ;
103
104
104
- expect ( mock . calls . length ) . toBe ( 1 ) ;
105
+ expect ( mock . calls . length ) . toBe ( 1 ) ;
105
106
106
- const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
107
- expect ( model . clientBaseUrl ) . toBe ( 'https://client-base-url.example.com' ) ;
108
- } ) ;
107
+ const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
108
+ expect ( model . clientBaseUrl ) . toBe ( 'https://client-base-url.example.com' ) ;
109
+ } ) ;
109
110
110
- it ( 'clientBaseUrl should use configurationBaseUrl if given' , ( ) => {
111
- const { mock } = mockInit ;
111
+ it ( 'should use configurationBaseUrl if given' , ( ) => {
112
+ const { mock } = mockInit ;
112
113
113
- setup (
114
- 'id' ,
115
- 'clientID' ,
116
- 'my-tenant.us.auth0.com' ,
117
- {
118
- configurationBaseUrl : 'https://config-base-url.example.com' ,
119
- assetsUrl : 'https://assets-url.example.com'
120
- } ,
121
- 'hookRunner' ,
122
- 'emitEventFn' ,
123
- 'handleEventFn'
124
- ) ;
114
+ setup (
115
+ 'id' ,
116
+ 'clientID' ,
117
+ 'my-tenant.us.auth0.com' ,
118
+ {
119
+ configurationBaseUrl : 'https://config-base-url.example.com' ,
120
+ assetsUrl : 'https://assets-url.example.com'
121
+ } ,
122
+ 'hookRunner' ,
123
+ 'emitEventFn' ,
124
+ 'handleEventFn'
125
+ ) ;
125
126
126
- expect ( mock . calls . length ) . toBe ( 1 ) ;
127
+ expect ( mock . calls . length ) . toBe ( 1 ) ;
127
128
128
- const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
129
- expect ( model . clientBaseUrl ) . toBe ( 'https://config-base-url.example.com' ) ;
129
+ const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
130
+ expect ( model . clientBaseUrl ) . toBe ( 'https://config-base-url.example.com' ) ;
131
+ } ) ;
132
+
133
+ it ( 'should use assetsUrl if given' , ( ) => {
134
+ const { mock } = mockInit ;
135
+
136
+ setup (
137
+ 'id' ,
138
+ 'clientID' ,
139
+ 'my-tenant.us.auth0.com' ,
140
+ {
141
+ assetsUrl : 'https://assets-url.example.com'
142
+ } ,
143
+ 'hookRunner' ,
144
+ 'emitEventFn' ,
145
+ 'handleEventFn'
146
+ ) ;
147
+
148
+ expect ( mock . calls . length ) . toBe ( 1 ) ;
149
+
150
+ const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
151
+ expect ( model . clientBaseUrl ) . toBe ( 'https://assets-url.example.com' ) ;
152
+ } ) ;
130
153
} ) ;
131
154
132
- it ( 'clientBaseUrl should use assetsUrl if given' , ( ) => {
133
- const { mock } = mockInit ;
155
+ describe ( 'tenantBaseUrl' , ( ) => {
156
+ it ( 'tenantBaseUrl should default to domain URL when using auth0.com' , ( ) => {
157
+ const { mock } = mockInit ;
134
158
135
- setup (
136
- 'id' ,
137
- 'clientID' ,
138
- 'my-tenant.us.auth0.com' ,
139
- {
140
- assetsUrl : 'https://assets-url.example.com'
141
- } ,
142
- 'hookRunner' ,
143
- 'emitEventFn' ,
144
- 'handleEventFn'
145
- ) ;
159
+ setup (
160
+ 'id' ,
161
+ 'clientID' ,
162
+ 'my-tenant.us.auth0.com' ,
163
+ {
164
+ __useTenantInfo : true
165
+ } ,
166
+ 'hookRunner' ,
167
+ 'emitEventFn' ,
168
+ 'handleEventFn'
169
+ ) ;
146
170
147
- expect ( mock . calls . length ) . toBe ( 1 ) ;
171
+ expect ( mock . calls . length ) . toBe ( 1 ) ;
148
172
149
- const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
150
- expect ( model . clientBaseUrl ) . toBe ( 'https://assets-url.example.com' ) ;
173
+ const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
174
+ expect ( model . tenantBaseUrl ) . toBe ( 'https://my-tenant.us.auth0.com/tenants/v1/my-tenant.js' ) ;
175
+ } ) ;
176
+
177
+ it ( 'should default to domain URL when using a custom domain' , ( ) => {
178
+ const { mock } = mockInit ;
179
+
180
+ setup (
181
+ 'id' ,
182
+ 'clientID' ,
183
+ 'auth.my-tenant.com' ,
184
+ {
185
+ __useTenantInfo : true
186
+ } ,
187
+ 'hookRunner' ,
188
+ 'emitEventFn' ,
189
+ 'handleEventFn'
190
+ ) ;
191
+
192
+ expect ( mock . calls . length ) . toBe ( 1 ) ;
193
+
194
+ const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
195
+ expect ( model . tenantBaseUrl ) . toBe ( 'https://auth.my-tenant.com/info-v1.js' ) ;
196
+ } ) ;
197
+
198
+ it ( 'should use configurationBaseUrl if specified' , ( ) => {
199
+ const { mock } = mockInit ;
200
+
201
+ setup (
202
+ 'id' ,
203
+ 'clientID' ,
204
+ 'auth.my-tenant.com' ,
205
+ {
206
+ __useTenantInfo : true ,
207
+ configurationBaseUrl : 'https://config-base-url.com'
208
+ } ,
209
+ 'hookRunner' ,
210
+ 'emitEventFn' ,
211
+ 'handleEventFn'
212
+ ) ;
213
+
214
+ expect ( mock . calls . length ) . toBe ( 1 ) ;
215
+
216
+ const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
217
+ expect ( model . tenantBaseUrl ) . toBe ( 'https://config-base-url.com/info-v1.js' ) ;
218
+ } ) ;
219
+
220
+ it ( 'should use configurationBaseUrl with a custom tenant if specified' , ( ) => {
221
+ const { mock } = mockInit ;
222
+
223
+ setup (
224
+ 'id' ,
225
+ 'clientID' ,
226
+ 'auth.my-tenant.com' ,
227
+ {
228
+ __useTenantInfo : true ,
229
+ configurationBaseUrl : 'https://config-base-url.com' ,
230
+ overrides : {
231
+ __tenant : 'custom-tenant'
232
+ }
233
+ } ,
234
+ 'hookRunner' ,
235
+ 'emitEventFn' ,
236
+ 'handleEventFn'
237
+ ) ;
238
+
239
+ expect ( mock . calls . length ) . toBe ( 1 ) ;
240
+
241
+ const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
242
+ expect ( model . tenantBaseUrl ) . toBe ( 'https://config-base-url.com/tenants/v1/custom-tenant.js' ) ;
243
+ } ) ;
151
244
} ) ;
152
245
} ) ;
153
246
0 commit comments