-
Notifications
You must be signed in to change notification settings - Fork 270
Expand file tree
/
Copy pathapp-locator.test.js
More file actions
114 lines (97 loc) · 3.17 KB
/
app-locator.test.js
File metadata and controls
114 lines (97 loc) · 3.17 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import appIds from './known-app-ids'
import { parseAppLocator } from './app-locator'
const CUSTOM_APP_1 =
'0x0000000000000000000000000000000000000000000000000000000000000000'
const CUSTOM_APP_2 =
'0x0000000000000000000000000000000000000000000000000000000000000001'
test('all known apps local', () => {
expect(parseAppLocator('local')).toEqual({
[appIds['Voting']]: 'http://localhost:3001/',
[appIds['Finance']]: 'http://localhost:3002/',
[appIds['TokenManager']]: 'http://localhost:3003/',
[appIds['Survey']]: 'http://localhost:3004/',
[appIds['Agent']]: 'http://localhost:3005/',
[appIds['Fundraising']]: 'http://localhost:3006/',
})
})
test('one local app', () => {
const result = {
[appIds['Voting']]: 'http://localhost:3001/',
}
expect(parseAppLocator('Voting:local')).toEqual(result)
expect(parseAppLocator('Voting:')).toEqual(result)
expect(parseAppLocator('Voting')).toEqual(result)
expect(parseAppLocator(',Voting,')).toEqual(result)
expect(parseAppLocator(',Voting:,')).toEqual(result)
expect(parseAppLocator(',Voting:local,')).toEqual(result)
expect(parseAppLocator(',Voting:local,')).toEqual(result)
})
test('multiple local apps', () => {
const result = {
[appIds['Voting']]: 'http://localhost:3001/',
[appIds['TokenManager']]: 'http://localhost:3003/',
}
expect(parseAppLocator('Voting:local,TokenManager')).toEqual(result)
expect(parseAppLocator('Voting,TokenManager:,')).toEqual(result)
})
test('local port', () => {
expect(parseAppLocator('Voting:1234,TokenManager:3333')).toEqual({
[appIds['Voting']]: 'http://localhost:1234/',
[appIds['TokenManager']]: 'http://localhost:3333/',
})
})
test('custom app', () => {
const result = {
[CUSTOM_APP_1]: 'http://example.org/',
[CUSTOM_APP_2]: 'http://example.org:4444/',
}
expect(
parseAppLocator(
`${CUSTOM_APP_1}:http://example.org/` +
`,${CUSTOM_APP_2}:http://example.org:4444/`
)
).toEqual(result)
})
test('mixed apps', () => {
const result = {
[appIds['Voting']]: 'http://localhost:3001/',
[appIds['TokenManager']]: 'http://example.com/',
[CUSTOM_APP_1]: 'http://example.org/',
}
expect(
parseAppLocator(
`Voting:local,TokenManager:http://example.com/,${CUSTOM_APP_1}:http://example.org/`
)
).toEqual(result)
})
test('domain', () => {
const result = {
[appIds['Voting']]: 'http://localhost/',
[appIds['Finance']]: 'http://finance.local/app',
[appIds['TokenManager']]: 'http://token-manager/',
[appIds['Fundraising']]: 'http://localhost:3333/',
}
expect(
parseAppLocator(
'Voting:localhost,Finance:finance.local/app,TokenManager:token-manager,Fundraising:localhost:3333'
)
).toEqual(result)
})
test('IP', () => {
const result = {
[appIds['Voting']]: 'http://1.2.3.4/',
[appIds['Finance']]: 'http://1.2.3.4:3423/app',
}
expect(parseAppLocator('Voting:1.2.3.4,Finance:1.2.3.4:3423/app')).toEqual(
result
)
})
test('ENS IDs', () => {
const result = {
[appIds['Voting']]: 'http://localhost:3001/',
[appIds['Finance']]: 'http://localhost:3333/',
}
expect(
parseAppLocator('voting.aragonpm.eth,finance.aragonpm.eth:3333')
).toEqual(result)
})