-
-
Notifications
You must be signed in to change notification settings - Fork 793
/
velocityContextTest.js
33 lines (29 loc) · 967 Bytes
/
velocityContextTest.js
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
import VelocityContext from '../../src/events/api-gateway/lambda-events/VelocityContext.js'
describe('#urlDecode', () => {
test('should decode url query parameters', () => {
const fakeRequest = {
headers: {},
info: {},
method: 'post',
raw: {
req: {
rawHeaders: null,
},
},
route: {},
}
const velocity = new VelocityContext(fakeRequest, 'dev', {}).getContext()
const tests = [
['%3E%2C%2F%3F%3A%3B%27%22%5B%5D%5C%7B%7D%7C', '>,/?:;\'"[]\\{}|'],
['%20%21%40%23%24%25%5E%26%2A%28%29%2B%3D%60%3C', ' !@#$%^&*()+=`<'],
['%D0%80%D0%81%D0%82%D0%83%D0%84%D0%85%D0%86%D0%87%D0%88', 'ЀЁЂЃЄЅІЇЈ'],
['Rock%2b%26%2bRoll', 'Rock+&+Roll'],
['Rock%20%26%20Roll', 'Rock & Roll'],
['Rock+%26+Roll', 'Rock & Roll'],
]
tests.forEach((test) => {
const [key, value] = test
expect(velocity.util.urlDecode(key)).toEqual(value)
})
})
})