1import { getRedirectPath } from './error-utilities'; 2 3test('redirects old building-standalone-apps paths versioned path', () => { 4 const redirectPath = '/versions/latest/distribution/building-standalone-apps/'; 5 const newPath = getRedirectPath(redirectPath); 6 7 expect(newPath).toEqual('/archive/classic-updates/building-standalone-apps/'); 8 9 // The path with guides instead of distribution is very old 10 expect(getRedirectPath('/versions/latest/guides/building-standalone-apps/')).toEqual(newPath); 11}); 12 13test('redirects version vX.0.0 renamed path', () => { 14 const redirectPath = '/versions/v32.0.0/guides/push-notifications/'; 15 const newPath = getRedirectPath(redirectPath); 16 17 expect(newPath).toEqual('/push-notifications/overview/'); 18}); 19 20test('redirects version latest renamed path', () => { 21 const redirectPath = '/versions/latest/guides/push-notifications/'; 22 const newPath = getRedirectPath(redirectPath); 23 24 expect(newPath).toEqual('/push-notifications/overview/'); 25}); 26 27test('redirects versionless renamed path', () => { 28 const redirectPath = '/guides/push-notifications/'; 29 const newPath = getRedirectPath(redirectPath); 30 31 expect(newPath).toEqual('/push-notifications/overview/'); 32}); 33 34test('redirects versioned non-renamed path', () => { 35 const redirectPath = '/versions/latest/workflow/expo-cli/'; 36 const newPath = getRedirectPath(redirectPath); 37 38 expect(newPath).toEqual('/more/expo-cli/'); 39}); 40 41test('does not redirect non-renamed path', () => { 42 const redirectPath = '/workflow/expo-cli/'; 43 const newPath = getRedirectPath(redirectPath); 44 45 expect(newPath).toEqual('/more/expo-cli/'); 46}); 47 48test('adds forward slash to end of path', () => { 49 const redirectPath = '/workflow/expo-cli'; 50 const newPath = getRedirectPath(redirectPath); 51 52 expect(newPath).toEqual('/more/expo-cli/'); 53}); 54 55test('redirects old versions to latest', () => { 56 const redirectPath = '/versions/v32.0.0/sdk/admob/'; 57 const newPath = getRedirectPath(redirectPath); 58 59 expect(newPath).toEqual('/versions/latest/sdk/admob/'); 60}); 61 62test('redirects versionless SDK paths to new version', () => { 63 const redirectPath = '/sdk/admob/'; 64 const newPath = getRedirectPath(redirectPath); 65 66 expect(newPath).toEqual('/versions/latest/sdk/admob/'); 67}); 68 69test('removes null from end of paths', () => { 70 const redirectPath = '/debugging/errors-and-warnings/null'; 71 const newPath = getRedirectPath(redirectPath); 72 73 expect(newPath).toEqual('/debugging/errors-and-warnings/'); 74}); 75 76test('redirect SDK permissions to the permission guide', () => { 77 expect(getRedirectPath('/versions/v40.0.0/sdk/permissions/')).toEqual('/guides/permissions/'); 78 expect(getRedirectPath('/versions/v41.0.0/sdk/permissions/')).toEqual('/guides/permissions/'); 79 expect(getRedirectPath('/versions/v42.0.0/sdk/permissions/')).toEqual('/guides/permissions/'); 80 expect(getRedirectPath('/versions/v43.0.0/sdk/permissions/')).toEqual('/guides/permissions/'); 81 expect(getRedirectPath('/versions/latest/sdk/permissions/')).toEqual('/guides/permissions/'); 82}); 83