@@ -8,6 +8,12 @@ import {
88 oldestSupported ,
99} from '@/versions/lib/enterprise-server-releases'
1010
11+ // Test helper type for mocking contexts
12+ type TestContext = {
13+ pages : Record < string , any >
14+ redirects : Record < string , string >
15+ }
16+
1117const previousEnterpriserServerVersion = supported [ 1 ]
1218
1319describe ( 'getRedirect basics' , ( ) => {
@@ -19,7 +25,7 @@ describe('getRedirect basics', () => {
1925 // part.
2026 // But some redirects from `developer.json` as old and static.
2127 const uri = '/enterprise/3.0/foo/bar'
22- const ctx = {
28+ const ctx : TestContext = {
2329 pages : { } ,
2430 redirects : {
2531 '/enterprise/3.0/foo/bar' : '/something/else' ,
@@ -29,15 +35,15 @@ describe('getRedirect basics', () => {
2935 } )
3036
3137 test ( 'should return undefined if nothing could be found' , ( ) => {
32- const ctx = {
38+ const ctx : TestContext = {
3339 pages : { } ,
3440 redirects : { } ,
3541 }
3642 expect ( getRedirect ( '/foo/pizza' , ctx ) ) . toBeUndefined ( )
3743 } )
3844
3945 test ( 'should just inject language on version "home pages"' , ( ) => {
40- const ctx = {
46+ const ctx : TestContext = {
4147 pages : { } ,
4248 redirects : { } ,
4349 }
@@ -69,7 +75,7 @@ describe('getRedirect basics', () => {
6975 } )
7076
7177 test ( 'should handle some odd exceptions' , ( ) => {
72- const ctx = {
78+ const ctx : TestContext = {
7379 pages : { } ,
7480 redirects : { } ,
7581 }
@@ -86,7 +92,7 @@ describe('getRedirect basics', () => {
8692 } )
8793
8894 test ( 'should figure out redirect based on presence of pages in certain cases' , ( ) => {
89- const ctx = {
95+ const ctx : TestContext = {
9096 pages : {
9197 [ `/en/enterprise-server@${ previousEnterpriserServerVersion } /foo/bar` ] : null ,
9298 [ `/en/enterprise-server@${ previousEnterpriserServerVersion } /admin/github-management` ] : null ,
@@ -131,7 +137,7 @@ describe('getRedirect basics', () => {
131137 } )
132138
133139 test ( 'should not do anything on some prefixes' , ( ) => {
134- const ctx = {
140+ const ctx : TestContext = {
135141 pages : { } ,
136142 redirects : { } ,
137143 }
@@ -159,7 +165,7 @@ describe('getRedirect basics', () => {
159165 test ( 'should work for some deprecated enterprise-server URLs too' , ( ) => {
160166 // Starting with enterprise-server 3.0, we have made redirects become
161167 // a *function* rather than a lookup on a massive object.
162- const ctx = {
168+ const ctx : TestContext = {
163169 pages : { } ,
164170 redirects : { } ,
165171 }
@@ -170,23 +176,23 @@ describe('getRedirect basics', () => {
170176
171177describe ( 'github-ae@latest' , ( ) => {
172178 test ( 'home page should redirect to enterprise-cloud home page' , ( ) => {
173- const ctx = {
179+ const ctx : TestContext = {
174180 pages : { } ,
175181 redirects : { } ,
176182 }
177183 expect ( getRedirect ( '/github-ae@latest' , ctx ) ) . toBe ( '/en/enterprise-cloud@latest' )
178184 expect ( getRedirect ( '/en/github-ae@latest' , ctx ) ) . toBe ( '/en/enterprise-cloud@latest' )
179185 } )
180186 test ( 'should redirect to home page for admin/release-notes' , ( ) => {
181- const ctx = {
187+ const ctx : TestContext = {
182188 pages : { } ,
183189 redirects : { } ,
184190 }
185191 expect ( getRedirect ( '/github-ae@latest/admin/release-notes' , ctx ) ) . toBe ( '/en' )
186192 expect ( getRedirect ( '/en/github-ae@latest/admin/release-notes' , ctx ) ) . toBe ( '/en' )
187193 } )
188194 test ( 'a page that does exits, without correction, in enterprise-cloud' , ( ) => {
189- const ctx = {
195+ const ctx : TestContext = {
190196 pages : {
191197 '/en/enterprise-cloud@latest/foo' : null ,
192198 } ,
@@ -196,7 +202,7 @@ describe('github-ae@latest', () => {
196202 expect ( getRedirect ( '/en/github-ae@latest/foo' , ctx ) ) . toBe ( '/en/enterprise-cloud@latest/foo' )
197203 } )
198204 test ( "a page that doesn't exist in enterprise-cloud but in FPT" , ( ) => {
199- const ctx = {
205+ const ctx : TestContext = {
200206 pages : {
201207 '/en/foo' : true ,
202208 } ,
@@ -206,7 +212,7 @@ describe('github-ae@latest', () => {
206212 expect ( getRedirect ( '/en/github-ae@latest/foo' , ctx ) ) . toBe ( '/en/foo' )
207213 } )
208214 test ( "a page that doesn't exist in enterprise-cloud or in FPT" , ( ) => {
209- const ctx = {
215+ const ctx : TestContext = {
210216 pages : {
211217 '/en/foo' : true ,
212218 } ,
@@ -216,7 +222,7 @@ describe('github-ae@latest', () => {
216222 expect ( getRedirect ( '/en/github-ae@latest/bar' , ctx ) ) . toBe ( '/en' )
217223 } )
218224 test ( 'a URL with legacy redirects, that redirects to enterprise-cloud' , ( ) => {
219- const ctx = {
225+ const ctx : TestContext = {
220226 pages : {
221227 '/en/foo' : true ,
222228 '/en/enterprise-cloud@latest/foo' : true ,
@@ -229,7 +235,7 @@ describe('github-ae@latest', () => {
229235 expect ( getRedirect ( '/en/github-ae@latest/food' , ctx ) ) . toBe ( '/en/enterprise-cloud@latest/foo' )
230236 } )
231237 test ( "a URL with legacy redirects, that can't redirect to enterprise-cloud" , ( ) => {
232- const ctx = {
238+ const ctx : TestContext = {
233239 pages : {
234240 '/en/foo' : true ,
235241 // Note the lack of an enterprise-cloud page here
0 commit comments