@@ -4,14 +4,10 @@ beforeAll(() => {
44 Math . random = jest . fn ( ( ) => 0.123 ) ;
55} ) ;
66
7- // afterAll(() => {
8- // Math.random.mockRestore()
9- // });
10-
117test ( 'oauthAuthorizationUrl({clientId: "1234567890abcdef1234"})' , ( ) => {
128 expect (
139 oauthAuthorizationUrl ( {
14- clientId : "1234567890abcdef1234"
10+ clientId : "1234567890abcdef1234" ,
1511 } )
1612 ) . toEqual ( {
1713 allowSignup : true ,
@@ -21,14 +17,14 @@ test('oauthAuthorizationUrl({clientId: "1234567890abcdef1234"})', () => {
2117 scopes : [ ] ,
2218 state : "4feornbt361" ,
2319 url :
24- "https://github.com/login/oauth/authorize?allow_signup=true&client_id=1234567890abcdef1234&state=4feornbt361"
20+ "https://github.com/login/oauth/authorize?allow_signup=true&client_id=1234567890abcdef1234&state=4feornbt361" ,
2521 } ) ;
2622} ) ;
2723
2824test ( 'oauthAuthorizationUrl({clientId: "4321fedcba0987654321"})' , ( ) => {
2925 expect (
3026 oauthAuthorizationUrl ( {
31- clientId : "4321fedcba0987654321"
27+ clientId : "4321fedcba0987654321" ,
3228 } )
3329 ) . toEqual ( {
3430 allowSignup : true ,
@@ -38,15 +34,15 @@ test('oauthAuthorizationUrl({clientId: "4321fedcba0987654321"})', () => {
3834 scopes : [ ] ,
3935 state : "4feornbt361" ,
4036 url :
41- "https://github.com/login/oauth/authorize?allow_signup=true&client_id=4321fedcba0987654321&state=4feornbt361"
37+ "https://github.com/login/oauth/authorize?allow_signup=true&client_id=4321fedcba0987654321&state=4feornbt361" ,
4238 } ) ;
4339} ) ;
4440
4541test ( "redirectUrl option" , ( ) => {
4642 expect (
4743 oauthAuthorizationUrl ( {
4844 clientId : "1234567890abcdef1234" ,
49- redirectUrl : "https://example.com"
45+ redirectUrl : "https://example.com" ,
5046 } )
5147 ) . toEqual ( {
5248 allowSignup : true ,
@@ -56,15 +52,15 @@ test("redirectUrl option", () => {
5652 scopes : [ ] ,
5753 state : "4feornbt361" ,
5854 url :
59- "https://github.com/login/oauth/authorize?allow_signup=true&client_id=1234567890abcdef1234&redirect_uri=https://example.com&state=4feornbt361"
55+ "https://github.com/login/oauth/authorize?allow_signup=true&client_id=1234567890abcdef1234&redirect_uri=https://example.com&state=4feornbt361" ,
6056 } ) ;
6157} ) ;
6258
6359test ( "login option" , ( ) => {
6460 expect (
6561 oauthAuthorizationUrl ( {
6662 clientId : "1234567890abcdef1234" ,
67- login : "octocat"
63+ login : "octocat" ,
6864 } )
6965 ) . toEqual ( {
7066 allowSignup : true ,
@@ -74,7 +70,7 @@ test("login option", () => {
7470 scopes : [ ] ,
7571 state : "4feornbt361" ,
7672 url :
77- "https://github.com/login/oauth/authorize?allow_signup=true&client_id=1234567890abcdef1234&login=octocat&state=4feornbt361"
73+ "https://github.com/login/oauth/authorize?allow_signup=true&client_id=1234567890abcdef1234&login=octocat&state=4feornbt361" ,
7874 } ) ;
7975} ) ;
8076
@@ -83,7 +79,7 @@ test("scopes = []", () => {
8379 oauthAuthorizationUrl ( {
8480 clientId : "1234567890abcdef1234" ,
8581 login : "octocat" ,
86- scopes : [ ]
82+ scopes : [ ] ,
8783 } )
8884 ) . toEqual ( {
8985 allowSignup : true ,
@@ -93,7 +89,7 @@ test("scopes = []", () => {
9389 scopes : [ ] ,
9490 state : "4feornbt361" ,
9591 url :
96- "https://github.com/login/oauth/authorize?allow_signup=true&client_id=1234567890abcdef1234&login=octocat&state=4feornbt361"
92+ "https://github.com/login/oauth/authorize?allow_signup=true&client_id=1234567890abcdef1234&login=octocat&state=4feornbt361" ,
9793 } ) ;
9894} ) ;
9995
@@ -102,7 +98,7 @@ test('scopes = ""', () => {
10298 oauthAuthorizationUrl ( {
10399 clientId : "1234567890abcdef1234" ,
104100 login : "octocat" ,
105- scopes : ""
101+ scopes : "" ,
106102 } )
107103 ) . toEqual ( {
108104 allowSignup : true ,
@@ -112,7 +108,7 @@ test('scopes = ""', () => {
112108 scopes : [ ] ,
113109 state : "4feornbt361" ,
114110 url :
115- "https://github.com/login/oauth/authorize?allow_signup=true&client_id=1234567890abcdef1234&login=octocat&state=4feornbt361"
111+ "https://github.com/login/oauth/authorize?allow_signup=true&client_id=1234567890abcdef1234&login=octocat&state=4feornbt361" ,
116112 } ) ;
117113} ) ;
118114
@@ -121,7 +117,7 @@ test('scopes = "user,public_repo, gist notifications"', () => {
121117 oauthAuthorizationUrl ( {
122118 clientId : "1234567890abcdef1234" ,
123119 login : "octocat" ,
124- scopes : "user,public_repo, gist notifications"
120+ scopes : "user,public_repo, gist notifications" ,
125121 } )
126122 ) . toEqual ( {
127123 allowSignup : true ,
@@ -131,7 +127,7 @@ test('scopes = "user,public_repo, gist notifications"', () => {
131127 scopes : [ "user" , "public_repo" , "gist" , "notifications" ] ,
132128 state : "4feornbt361" ,
133129 url :
134- "https://github.com/login/oauth/authorize?allow_signup=true&client_id=1234567890abcdef1234&login=octocat&scope=user,public_repo,gist,notifications&state=4feornbt361"
130+ "https://github.com/login/oauth/authorize?allow_signup=true&client_id=1234567890abcdef1234&login=octocat&scope=user,public_repo,gist,notifications&state=4feornbt361" ,
135131 } ) ;
136132} ) ;
137133
@@ -141,7 +137,7 @@ test("allowSignup = false", () => {
141137 allowSignup : false ,
142138 clientId : "1234567890abcdef1234" ,
143139 login : "octocat" ,
144- scopes : "user,public_repo, gist notifications"
140+ scopes : "user,public_repo, gist notifications" ,
145141 } )
146142 ) . toEqual ( {
147143 allowSignup : false ,
@@ -151,7 +147,7 @@ test("allowSignup = false", () => {
151147 scopes : [ "user" , "public_repo" , "gist" , "notifications" ] ,
152148 state : "4feornbt361" ,
153149 url :
154- "https://github.com/login/oauth/authorize?allow_signup=false&client_id=1234567890abcdef1234&login=octocat&scope=user,public_repo,gist,notifications&state=4feornbt361"
150+ "https://github.com/login/oauth/authorize?allow_signup=false&client_id=1234567890abcdef1234&login=octocat&scope=user,public_repo,gist,notifications&state=4feornbt361" ,
155151 } ) ;
156152} ) ;
157153
@@ -160,7 +156,7 @@ test("state = Sjn2oMwNFZPiVm6Mtjn2o9b3xxZ4sVEI", () => {
160156 oauthAuthorizationUrl ( {
161157 clientId : "1234567890abcdef1234" ,
162158 login : "octocat" ,
163- state : "Sjn2oMwNFZPiVm6Mtjn2o9b3xxZ4sVEI"
159+ state : "Sjn2oMwNFZPiVm6Mtjn2o9b3xxZ4sVEI" ,
164160 } )
165161 ) . toEqual ( {
166162 allowSignup : true ,
@@ -170,6 +166,24 @@ test("state = Sjn2oMwNFZPiVm6Mtjn2o9b3xxZ4sVEI", () => {
170166 scopes : [ ] ,
171167 state : "Sjn2oMwNFZPiVm6Mtjn2o9b3xxZ4sVEI" ,
172168 url :
173- "https://github.com/login/oauth/authorize?allow_signup=true&client_id=1234567890abcdef1234&login=octocat&state=Sjn2oMwNFZPiVm6Mtjn2o9b3xxZ4sVEI"
169+ "https://github.com/login/oauth/authorize?allow_signup=true&client_id=1234567890abcdef1234&login=octocat&state=Sjn2oMwNFZPiVm6Mtjn2o9b3xxZ4sVEI" ,
170+ } ) ;
171+ } ) ;
172+
173+ test ( 'oauthAuthorizationUrl({clientId: "1234567890abcdef1234", baseUrl: "https://github.my-enterprise.com/"})' , ( ) => {
174+ expect (
175+ oauthAuthorizationUrl ( {
176+ clientId : "1234567890abcdef1234" ,
177+ baseUrl : "https://github.my-enterprise.com" ,
178+ } )
179+ ) . toEqual ( {
180+ allowSignup : true ,
181+ clientId : "1234567890abcdef1234" ,
182+ login : null ,
183+ redirectUrl : null ,
184+ scopes : [ ] ,
185+ state : "4feornbt361" ,
186+ url :
187+ "https://github.my-enterprise.com/login/oauth/authorize?allow_signup=true&client_id=1234567890abcdef1234&state=4feornbt361" ,
174188 } ) ;
175189} ) ;
0 commit comments