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