-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mod_test.ts
50 lines (45 loc) · 1.56 KB
/
mod_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
import { superdeno } from 'https://deno.land/x/superdeno@4.8.0/mod.ts'
import { describe, it, run } from 'https://deno.land/x/tincan@1.0.1/mod.ts'
import { compression } from './mod.ts'
describe('options', () => {
it('does not apply compression if "Accept-Encoding" is "identity"', async () => {
const request = superdeno(compression({ path: 'LICENSE' }))
await request
.get('/')
.set('Accept-Encoding', 'identity')
.expect(200)
.expect('Content-Encoding', 'identity')
.expect('Content-Length', '1071')
})
it('applies compression to a file', async () => {
const request = superdeno(
compression({
path: 'LICENSE',
}),
)
await request
.get('/')
.set('Accept-Encoding', 'br, gzip, deflate')
.expect('Content-Length', '628')
.expect('Content-Encoding', 'br, gzip, deflate')
})
it('applies compression to a string', async () => {
const bodyText = await Deno.readTextFile('LICENSE')
const request = superdeno(compression({ bodyText }))
await request
.get('/')
.set('Accept-Encoding', 'br, gzip, deflate')
.expect('Content-Length', '628')
.expect('Content-Encoding', 'br, gzip, deflate')
})
it('applies compression to a byte array', async () => {
const bodyBinary = await Deno.readFile('LICENSE')
const request = superdeno(compression({ bodyBinary }))
await request
.get('/')
.set('Accept-Encoding', 'br, gzip, deflate')
.expect('Content-Length', '628')
.expect('Content-Encoding', 'br, gzip, deflate')
})
})
run()