xref: /expo/docs/common/error-utilities.test.ts (revision 0dfbbd2a)
1import { getRedirectPath } from './error-utilities';
2
3test('redirects version vX.0.0 renamed path', () => {
4  const redirectPath = '/versions/v32.0.0/guides/push-notifications/';
5  const newPath = getRedirectPath(redirectPath);
6
7  expect(newPath).toEqual('/push-notifications/overview/');
8});
9
10test('redirects version latest renamed path', () => {
11  const redirectPath = '/versions/latest/guides/push-notifications/';
12  const newPath = getRedirectPath(redirectPath);
13
14  expect(newPath).toEqual('/push-notifications/overview/');
15});
16
17test('redirects versionless renamed path', () => {
18  const redirectPath = '/guides/push-notifications/';
19  const newPath = getRedirectPath(redirectPath);
20
21  expect(newPath).toEqual('/push-notifications/overview/');
22});
23
24test('redirects versioned non-renamed path', () => {
25  const redirectPath = '/versions/latest/workflow/expo-cli/';
26  const newPath = getRedirectPath(redirectPath);
27
28  expect(newPath).toEqual('/workflow/expo-cli/');
29});
30
31test('does not redirect non-renamed path', () => {
32  const redirectPath = '/workflow/expo-cli/';
33  const newPath = getRedirectPath(redirectPath);
34
35  expect(newPath).toEqual('/workflow/expo-cli/');
36});
37
38test('adds forward slash to end of path', () => {
39  const redirectPath = '/workflow/expo-cli';
40  const newPath = getRedirectPath(redirectPath);
41
42  expect(newPath).toEqual('/workflow/expo-cli/');
43});
44
45test('redirects old versions to latest', () => {
46  const redirectPath = '/versions/v32.0.0/sdk/admob/';
47  const newPath = getRedirectPath(redirectPath);
48
49  expect(newPath).toEqual('/versions/latest/sdk/admob/');
50});
51
52test('redirects versionless SDK paths to new version', () => {
53  const redirectPath = '/sdk/admob/';
54  const newPath = getRedirectPath(redirectPath);
55
56  expect(newPath).toEqual('/versions/latest/sdk/admob/');
57});
58
59test('removes null from end of paths', () => {
60  const redirectPath = '/get-started/errors/null';
61  const newPath = getRedirectPath(redirectPath);
62
63  expect(newPath).toEqual('/get-started/errors/');
64});
65