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
|
import { expect } from 'chai';
import { it, describe } from 'mocha';
import RelaySettingsBuilder from '../src/shared/relay-settings-builder';
describe('Relay settings builder', () => {
it('should set location to any', () => {
expect(RelaySettingsBuilder.normal().location.any().build()).to.deep.equal({
normal: {
location: 'any',
},
});
});
it('should bound location to city', () => {
expect(RelaySettingsBuilder.normal().location.city('se', 'mma').build()).to.deep.equal({
normal: {
location: {
only: {
city: ['se', 'mma'],
},
},
},
});
});
it('should bound location to country', () => {
expect(RelaySettingsBuilder.normal().location.country('se').build()).to.deep.equal({
normal: {
location: {
only: { country: 'se' },
},
},
});
});
it('should set openvpn settings to any', () => {
expect(
RelaySettingsBuilder.normal()
.tunnel.openvpn((openvpn) => {
openvpn.port.any().protocol.any();
})
.build(),
).to.deep.equal({
normal: {
openvpnConstraints: {
port: 'any',
protocol: 'any',
},
},
});
});
it('should set openvpn settings to exact values', () => {
expect(
RelaySettingsBuilder.normal()
.tunnel.openvpn((openvpn) => {
openvpn.port.exact(80).protocol.exact('tcp');
})
.build(),
).to.deep.equal({
normal: {
openvpnConstraints: {
port: { only: 80 },
protocol: { only: 'tcp' },
},
},
});
});
it('should set location from raw RelayLocation', () => {
expect(RelaySettingsBuilder.normal().location.fromRaw('any').build()).to.deep.equal({
normal: {
location: 'any',
},
});
expect(RelaySettingsBuilder.normal().location.fromRaw({ country: 'se' }).build()).to.deep.equal(
{
normal: {
location: {
only: { country: 'se' },
},
},
},
);
expect(
RelaySettingsBuilder.normal()
.location.fromRaw({ city: ['se', 'mma'] })
.build(),
).to.deep.equal({
normal: {
location: {
only: { city: ['se', 'mma'] },
},
},
});
});
});
|