@@ -29,6 +29,7 @@ describe('setup', () => {
29
29
mockInit = jest . fn ( ) ;
30
30
jest . resetModules ( ) ;
31
31
} ) ;
32
+
32
33
it ( 'default redirectUrl should not include location.hash' , ( ) => {
33
34
setURL ( 'https://test.com/path/#not-this-part' ) ;
34
35
const options = { } ;
@@ -38,6 +39,7 @@ describe('setup', () => {
38
39
const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
39
40
expect ( model . auth . redirectUrl ) . toBe ( 'https://test.com/path/' ) ;
40
41
} ) ;
42
+
41
43
it ( 'default redirectUrl should work when `window.location.origin` is not available' , ( ) => {
42
44
setURL ( 'https://test.com/path/#not-this-part' , { noOrigin : true } ) ;
43
45
const options = { } ;
@@ -47,19 +49,106 @@ describe('setup', () => {
47
49
const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
48
50
expect ( model . auth . redirectUrl ) . toBe ( 'https://test.com/path/' ) ;
49
51
} ) ;
52
+
50
53
it ( 'should work with redirect:false and responseType:id_token' , ( ) => {
51
54
const options = {
52
55
auth : {
53
56
redirect : false ,
54
57
responseType : 'id_token'
55
58
}
56
59
} ;
60
+
57
61
setup ( 'id' , 'clientID' , 'domain' , options , 'hookRunner' , 'emitEventFn' , 'handleEventFn' ) ;
58
62
const { mock } = mockInit ;
59
63
expect ( mock . calls . length ) . toBe ( 1 ) ;
60
64
const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
61
65
expect ( model ) . toMatchSnapshot ( ) ;
62
66
} ) ;
67
+
68
+ it ( 'default clientBaseUrl should use the specified domain' , ( ) => {
69
+ const { mock } = mockInit ;
70
+
71
+ setup (
72
+ 'id' ,
73
+ 'clientID' ,
74
+ 'my-tenant.us.auth0.com' ,
75
+ { } ,
76
+ 'hookRunner' ,
77
+ 'emitEventFn' ,
78
+ 'handleEventFn'
79
+ ) ;
80
+
81
+ expect ( mock . calls . length ) . toBe ( 1 ) ;
82
+
83
+ const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
84
+ expect ( model . clientBaseUrl ) . toBe ( 'https://my-tenant.us.auth0.com' ) ;
85
+ } ) ;
86
+
87
+ it ( 'clientBaseUrl should use clientBaseUrl if given' , ( ) => {
88
+ const { mock } = mockInit ;
89
+
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
+ ) ;
103
+
104
+ expect ( mock . calls . length ) . toBe ( 1 ) ;
105
+
106
+ const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
107
+ expect ( model . clientBaseUrl ) . toBe ( 'https://client-base-url.example.com' ) ;
108
+ } ) ;
109
+
110
+ it ( 'clientBaseUrl should use configurationBaseUrl if given' , ( ) => {
111
+ const { mock } = mockInit ;
112
+
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
+ ) ;
125
+
126
+ expect ( mock . calls . length ) . toBe ( 1 ) ;
127
+
128
+ const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
129
+ expect ( model . clientBaseUrl ) . toBe ( 'https://config-base-url.example.com' ) ;
130
+ } ) ;
131
+
132
+ it ( 'clientBaseUrl should use assetsUrl if given' , ( ) => {
133
+ const { mock } = mockInit ;
134
+
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
+ ) ;
146
+
147
+ expect ( mock . calls . length ) . toBe ( 1 ) ;
148
+
149
+ const model = mock . calls [ 0 ] [ 1 ] . toJS ( ) ;
150
+ expect ( model . clientBaseUrl ) . toBe ( 'https://assets-url.example.com' ) ;
151
+ } ) ;
63
152
} ) ;
64
153
65
154
describe ( 'setResolvedConnection' , ( ) => {
0 commit comments