/
trailingSlash.test.js
55 lines (48 loc) · 1.42 KB
/
trailingSlash.test.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { resolve } from 'path'
import fetch from 'node-fetch'
import {
joinUrl,
setup,
teardown,
} from '../../integration/_testHelpers/index.js'
jest.setTimeout(30000)
describe('noStripTrailingSlashInUrl option', () => {
// init
beforeAll(() =>
setup({
servicePath: resolve(__dirname),
args: ['--noStripTrailingSlashInUrl'],
}),
)
// cleanup
afterAll(() => teardown())
describe('when --noStripTrailingSlashInUrl is used, and request is made ending with slash', () => {
test('it should not be removed', async () => {
const url = joinUrl(TEST_BASE_URL, '/dev/echo/something/')
const response = await fetch(url)
const json = await response.json()
expect(json).toEqual({
path: '/echo/something/',
resource: '/echo/{any*}',
})
})
})
describe('when --noStripTrailingSlashInUrl is used, events with and without slash can co-exist', () => {
test('it should not be removed', async () => {
let url = joinUrl(TEST_BASE_URL, '/dev/echo/test')
let response = await fetch(url)
let json = await response.json()
expect(json).toEqual({
path: '/echo/test',
resource: '/echo/test',
})
url = joinUrl(TEST_BASE_URL, '/dev/echo/test/')
response = await fetch(url)
json = await response.json()
expect(json).toEqual({
path: '/echo/test/',
resource: '/echo/test/',
})
})
})
})