hono 1.2.2 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -19
- package/dist/context.d.ts +2 -2
- package/dist/context.js +24 -6
- package/dist/hono.d.ts +21 -29
- package/dist/hono.js +27 -65
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -2
- package/dist/middleware/cookie/index.d.ts +4 -1
- package/dist/middleware/cookie/index.js +9 -4
- package/dist/middleware/serve-static/index.d.ts +1 -1
- package/dist/middleware/serve-static/index.js +7 -2
- package/dist/utils/url.js +4 -0
- package/package.json +3 -3
- package/dist/compose.test.d.ts +0 -1
- package/dist/compose.test.js +0 -511
- package/dist/context.test.d.ts +0 -1
- package/dist/context.test.js +0 -127
- package/dist/hono.test.d.ts +0 -1
- package/dist/hono.test.js +0 -592
- package/dist/middleware/basic-auth/index.test.d.ts +0 -1
- package/dist/middleware/basic-auth/index.test.js +0 -119
- package/dist/middleware/body-parse/index.test.d.ts +0 -1
- package/dist/middleware/body-parse/index.test.js +0 -59
- package/dist/middleware/cookie/index.test.d.ts +0 -1
- package/dist/middleware/cookie/index.test.js +0 -54
- package/dist/middleware/cors/index.test.d.ts +0 -1
- package/dist/middleware/cors/index.test.js +0 -59
- package/dist/middleware/etag/index.test.d.ts +0 -1
- package/dist/middleware/etag/index.test.js +0 -45
- package/dist/middleware/graphql-server/index.test.d.ts +0 -1
- package/dist/middleware/graphql-server/index.test.js +0 -480
- package/dist/middleware/graphql-server/parse-body.test.d.ts +0 -1
- package/dist/middleware/graphql-server/parse-body.test.js +0 -57
- package/dist/middleware/jwt/index.test.d.ts +0 -1
- package/dist/middleware/jwt/index.test.js +0 -51
- package/dist/middleware/logger/index.test.d.ts +0 -1
- package/dist/middleware/logger/index.test.js +0 -49
- package/dist/middleware/mustache/index.test.d.ts +0 -1
- package/dist/middleware/mustache/index.test.js +0 -49
- package/dist/middleware/powered-by/index.test.d.ts +0 -1
- package/dist/middleware/powered-by/index.test.js +0 -15
- package/dist/middleware/pretty-json/index.test.d.ts +0 -1
- package/dist/middleware/pretty-json/index.test.js +0 -28
- package/dist/middleware/serve-static/index.test.d.ts +0 -1
- package/dist/middleware/serve-static/index.test.js +0 -58
- package/dist/router/reg-exp-router/router.test.d.ts +0 -1
- package/dist/router/reg-exp-router/router.test.js +0 -212
- package/dist/router/trie-router/node.test.d.ts +0 -1
- package/dist/router/trie-router/node.test.js +0 -351
- package/dist/router/trie-router/router.test.d.ts +0 -1
- package/dist/router/trie-router/router.test.js +0 -98
- package/dist/utils/body.test.d.ts +0 -1
- package/dist/utils/body.test.js +0 -45
- package/dist/utils/buffer.test.d.ts +0 -1
- package/dist/utils/buffer.test.js +0 -36
- package/dist/utils/cloudflare.test.d.ts +0 -1
- package/dist/utils/cloudflare.test.js +0 -42
- package/dist/utils/crypto.test.d.ts +0 -1
- package/dist/utils/crypto.test.js +0 -15
- package/dist/utils/encode.test.d.ts +0 -1
- package/dist/utils/encode.test.js +0 -54
- package/dist/utils/http-status.test.d.ts +0 -1
- package/dist/utils/http-status.test.js +0 -8
- package/dist/utils/jwt/jwt.test.d.ts +0 -1
- package/dist/utils/jwt/jwt.test.js +0 -171
- package/dist/utils/jwt/types.test.d.ts +0 -1
- package/dist/utils/jwt/types.test.js +0 -12
- package/dist/utils/mime.test.d.ts +0 -1
- package/dist/utils/mime.test.js +0 -13
- package/dist/utils/url.test.d.ts +0 -1
- package/dist/utils/url.test.js +0 -87
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const crypto_js_1 = require("crypto-js");
|
|
4
|
-
const hono_1 = require("../../hono");
|
|
5
|
-
const _1 = require(".");
|
|
6
|
-
describe('Basic Auth by Middleware', () => {
|
|
7
|
-
const crypto = global.crypto;
|
|
8
|
-
beforeAll(() => {
|
|
9
|
-
global.crypto = require('crypto').webcrypto;
|
|
10
|
-
});
|
|
11
|
-
afterAll(() => {
|
|
12
|
-
global.crypto = crypto;
|
|
13
|
-
});
|
|
14
|
-
const app = new hono_1.Hono();
|
|
15
|
-
const username = 'hono-user-a';
|
|
16
|
-
const password = 'hono-password-a';
|
|
17
|
-
const unicodePassword = '炎';
|
|
18
|
-
const usernameB = 'hono-user-b';
|
|
19
|
-
const passwordB = 'hono-password-b';
|
|
20
|
-
const usernameC = 'hono-user-c';
|
|
21
|
-
const passwordC = 'hono-password-c';
|
|
22
|
-
app.use('/auth/*', (0, _1.basicAuth)({
|
|
23
|
-
username,
|
|
24
|
-
password,
|
|
25
|
-
}));
|
|
26
|
-
app.use('/auth-unicode/*', (0, _1.basicAuth)({
|
|
27
|
-
username: username,
|
|
28
|
-
password: unicodePassword,
|
|
29
|
-
}));
|
|
30
|
-
app.use('/auth-multi/*', (0, _1.basicAuth)({
|
|
31
|
-
username: usernameB,
|
|
32
|
-
password: passwordB,
|
|
33
|
-
}, {
|
|
34
|
-
username: usernameC,
|
|
35
|
-
password: passwordC,
|
|
36
|
-
}));
|
|
37
|
-
app.use('/auth-override-func/*', (0, _1.basicAuth)({
|
|
38
|
-
username: username,
|
|
39
|
-
password: password,
|
|
40
|
-
hashFunction: (data) => (0, crypto_js_1.SHA256)(data).toString(),
|
|
41
|
-
}));
|
|
42
|
-
app.use('/nested/*', async (c, next) => {
|
|
43
|
-
const auth = (0, _1.basicAuth)({ username: username, password: password });
|
|
44
|
-
await auth(c, next);
|
|
45
|
-
});
|
|
46
|
-
app.get('/auth/*', () => new Response('auth'));
|
|
47
|
-
app.get('/auth-unicode/*', () => new Response('auth'));
|
|
48
|
-
app.get('/auth-multi/*', () => new Response('auth'));
|
|
49
|
-
app.get('/auth-override-func/*', () => new Response('auth'));
|
|
50
|
-
app.get('/nested/*', () => new Response('nested'));
|
|
51
|
-
it('Should not authorize', async () => {
|
|
52
|
-
const req = new Request('http://localhost/auth/a');
|
|
53
|
-
const res = await app.request(req);
|
|
54
|
-
expect(res).not.toBeNull();
|
|
55
|
-
expect(res.status).toBe(401);
|
|
56
|
-
expect(await res.text()).toBe('Unauthorized');
|
|
57
|
-
});
|
|
58
|
-
it('Should authorize', async () => {
|
|
59
|
-
const credential = Buffer.from(username + ':' + password).toString('base64');
|
|
60
|
-
const req = new Request('http://localhost/auth/a');
|
|
61
|
-
req.headers.set('Authorization', `Basic ${credential}`);
|
|
62
|
-
const res = await app.request(req);
|
|
63
|
-
expect(res).not.toBeNull();
|
|
64
|
-
expect(res.status).toBe(200);
|
|
65
|
-
expect(await res.text()).toBe('auth');
|
|
66
|
-
});
|
|
67
|
-
it('Should authorize Unicode', async () => {
|
|
68
|
-
const credential = Buffer.from(username + ':' + unicodePassword).toString('base64');
|
|
69
|
-
const req = new Request('http://localhost/auth-unicode/a');
|
|
70
|
-
req.headers.set('Authorization', `Basic ${credential}`);
|
|
71
|
-
const res = await app.request(req);
|
|
72
|
-
expect(res).not.toBeNull();
|
|
73
|
-
expect(res.status).toBe(200);
|
|
74
|
-
expect(await res.text()).toBe('auth');
|
|
75
|
-
});
|
|
76
|
-
it('Should authorize multiple users', async () => {
|
|
77
|
-
let credential = Buffer.from(usernameB + ':' + passwordB).toString('base64');
|
|
78
|
-
let req = new Request('http://localhost/auth-multi/b');
|
|
79
|
-
req.headers.set('Authorization', `Basic ${credential}`);
|
|
80
|
-
let res = await app.request(req);
|
|
81
|
-
expect(res).not.toBeNull();
|
|
82
|
-
expect(res.status).toBe(200);
|
|
83
|
-
expect(await res.text()).toBe('auth');
|
|
84
|
-
credential = Buffer.from(usernameC + ':' + passwordC).toString('base64');
|
|
85
|
-
req = new Request('http://localhost/auth-multi/c');
|
|
86
|
-
req.headers.set('Authorization', `Basic ${credential}`);
|
|
87
|
-
res = await app.request(req);
|
|
88
|
-
expect(res).not.toBeNull();
|
|
89
|
-
expect(res.status).toBe(200);
|
|
90
|
-
expect(await res.text()).toBe('auth');
|
|
91
|
-
});
|
|
92
|
-
it('Should authorize with sha256 function override', async () => {
|
|
93
|
-
const credential = Buffer.from(username + ':' + password).toString('base64');
|
|
94
|
-
const req = new Request('http://localhost/auth-override-func/a');
|
|
95
|
-
req.headers.set('Authorization', `Basic ${credential}`);
|
|
96
|
-
const res = await app.request(req);
|
|
97
|
-
expect(res).not.toBeNull();
|
|
98
|
-
expect(res.status).toBe(200);
|
|
99
|
-
expect(await res.text()).toBe('auth');
|
|
100
|
-
});
|
|
101
|
-
it('Should authorize - nested', async () => {
|
|
102
|
-
const credential = Buffer.from(username + ':' + password).toString('base64');
|
|
103
|
-
const req = new Request('http://localhost/nested');
|
|
104
|
-
req.headers.set('Authorization', `Basic ${credential}`);
|
|
105
|
-
const res = await app.request(req);
|
|
106
|
-
expect(res).not.toBeNull();
|
|
107
|
-
expect(res.status).toBe(200);
|
|
108
|
-
expect(await res.text()).toBe('nested');
|
|
109
|
-
});
|
|
110
|
-
it('Should not authorize - nested', async () => {
|
|
111
|
-
const credential = Buffer.from('foo' + ':' + 'bar').toString('base64');
|
|
112
|
-
const req = new Request('http://localhost/nested');
|
|
113
|
-
req.headers.set('Authorization', `Basic ${credential}`);
|
|
114
|
-
const res = await app.request(req);
|
|
115
|
-
expect(res).not.toBeNull();
|
|
116
|
-
expect(res.status).toBe(401);
|
|
117
|
-
expect(await res.text()).toBe('Unauthorized');
|
|
118
|
-
});
|
|
119
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const hono_1 = require("../../hono");
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
describe('Parse Body Middleware', () => {
|
|
6
|
-
const app = new hono_1.Hono();
|
|
7
|
-
app.use('*', (0, _1.bodyParse)());
|
|
8
|
-
app.post('/json', async (ctx) => {
|
|
9
|
-
return ctx.json(ctx.req.parsedBody, 200);
|
|
10
|
-
});
|
|
11
|
-
app.post('/text', async (ctx) => {
|
|
12
|
-
return ctx.text(ctx.req.parsedBody, 200);
|
|
13
|
-
});
|
|
14
|
-
app.post('/form', async (ctx) => {
|
|
15
|
-
return ctx.json(ctx.req.parsedBody, 200);
|
|
16
|
-
});
|
|
17
|
-
it('POST with JSON', async () => {
|
|
18
|
-
const payload = { message: 'hello hono' };
|
|
19
|
-
const req = new Request('http://localhost/json', {
|
|
20
|
-
method: 'POST',
|
|
21
|
-
body: JSON.stringify(payload),
|
|
22
|
-
headers: new Headers({ 'Content-Type': 'application/json' }),
|
|
23
|
-
});
|
|
24
|
-
const res = await app.request(req);
|
|
25
|
-
expect(res).not.toBeNull();
|
|
26
|
-
expect(res.status).toBe(200);
|
|
27
|
-
expect(req.parsedBody).toEqual(payload);
|
|
28
|
-
expect(await res.json()).toEqual(payload);
|
|
29
|
-
});
|
|
30
|
-
it('POST with text', async () => {
|
|
31
|
-
const payload = 'hello';
|
|
32
|
-
const req = new Request('http://localhost/text', {
|
|
33
|
-
method: 'POST',
|
|
34
|
-
body: 'hello',
|
|
35
|
-
headers: new Headers({ 'Content-Type': 'application/text' }),
|
|
36
|
-
});
|
|
37
|
-
const res = await app.request(req);
|
|
38
|
-
expect(res).not.toBeNull();
|
|
39
|
-
expect(res.status).toBe(200);
|
|
40
|
-
expect(req.parsedBody).toEqual(payload);
|
|
41
|
-
expect(await res.text()).toEqual(payload);
|
|
42
|
-
});
|
|
43
|
-
it('POST with form', async () => {
|
|
44
|
-
const formData = new URLSearchParams();
|
|
45
|
-
formData.append('message', 'hello');
|
|
46
|
-
const req = new Request('https://localhost/form', {
|
|
47
|
-
method: 'POST',
|
|
48
|
-
body: formData,
|
|
49
|
-
headers: {
|
|
50
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
const res = await app.request(req);
|
|
54
|
-
expect(res).not.toBeNull();
|
|
55
|
-
expect(res.status).toBe(200);
|
|
56
|
-
expect(req.parsedBody).toEqual({ message: 'hello' });
|
|
57
|
-
expect(await res.json()).toEqual({ message: 'hello' });
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const hono_1 = require("../../hono");
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
describe('Cookie Middleware', () => {
|
|
6
|
-
const app = new hono_1.Hono();
|
|
7
|
-
app.use('/cookie', (0, _1.cookie)());
|
|
8
|
-
app.get('/cookie', (c) => {
|
|
9
|
-
const yummyCookie = c.req.cookie('yummy_cookie');
|
|
10
|
-
const tastyCookie = c.req.cookie('tasty_cookie');
|
|
11
|
-
const res = new Response('Good cookie');
|
|
12
|
-
res.headers.set('Yummy-Cookie', yummyCookie);
|
|
13
|
-
res.headers.set('Tasty-Cookie', tastyCookie);
|
|
14
|
-
return res;
|
|
15
|
-
});
|
|
16
|
-
it('Parse cookie on c.req.cookie', async () => {
|
|
17
|
-
const req = new Request('http://localhost/cookie');
|
|
18
|
-
const cookieString = 'yummy_cookie=choco; tasty_cookie = strawberry ';
|
|
19
|
-
req.headers.set('Cookie', cookieString);
|
|
20
|
-
const res = await app.request(req);
|
|
21
|
-
expect(res.headers.get('Yummy-Cookie')).toBe('choco');
|
|
22
|
-
expect(res.headers.get('Tasty-Cookie')).toBe('strawberry');
|
|
23
|
-
});
|
|
24
|
-
app.use('/set-cookie', (0, _1.cookie)());
|
|
25
|
-
app.get('/set-cookie', (c) => {
|
|
26
|
-
c.cookie('delicious_cookie', 'macha');
|
|
27
|
-
return c.text('Give cookie');
|
|
28
|
-
});
|
|
29
|
-
it('Set cookie on c.cookie', async () => {
|
|
30
|
-
const res = await app.request('http://localhost/set-cookie');
|
|
31
|
-
expect(res.status).toBe(200);
|
|
32
|
-
const header = res.headers.get('Set-Cookie');
|
|
33
|
-
expect(header).toBe('delicious_cookie=macha');
|
|
34
|
-
});
|
|
35
|
-
app.use('/set-cookie-complex', (0, _1.cookie)());
|
|
36
|
-
app.get('/set-cookie-complex', (c) => {
|
|
37
|
-
c.cookie('great_cookie', 'banana', {
|
|
38
|
-
path: '/',
|
|
39
|
-
secure: true,
|
|
40
|
-
domain: 'example.com',
|
|
41
|
-
httpOnly: true,
|
|
42
|
-
maxAge: 1000,
|
|
43
|
-
expires: new Date(Date.UTC(2000, 11, 24, 10, 30, 59, 900)),
|
|
44
|
-
sameSite: 'Strict',
|
|
45
|
-
});
|
|
46
|
-
return c.text('Give cookie');
|
|
47
|
-
});
|
|
48
|
-
it('Complex pattern', async () => {
|
|
49
|
-
const res = await app.request('http://localhost/set-cookie-complex');
|
|
50
|
-
expect(res.status).toBe(200);
|
|
51
|
-
const header = res.headers.get('Set-Cookie');
|
|
52
|
-
expect(header).toBe('great_cookie=banana; Max-Age=1000; Domain=example.com; Path=/; Expires=Sun, 24 Dec 2000 10:30:59 GMT; HttpOnly; Secure; SameSite=Strict');
|
|
53
|
-
});
|
|
54
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const hono_1 = require("../../hono");
|
|
4
|
-
const cors_1 = require("../../middleware/cors");
|
|
5
|
-
describe('CORS by Middleware', () => {
|
|
6
|
-
const app = new hono_1.Hono();
|
|
7
|
-
app.use('/api/*', (0, cors_1.cors)());
|
|
8
|
-
app.use('/api2/*', (0, cors_1.cors)({
|
|
9
|
-
origin: 'http://example.com',
|
|
10
|
-
allowHeaders: ['X-Custom-Header', 'Upgrade-Insecure-Requests'],
|
|
11
|
-
allowMethods: ['POST', 'GET', 'OPTIONS'],
|
|
12
|
-
exposeHeaders: ['Content-Length', 'X-Kuma-Revision'],
|
|
13
|
-
maxAge: 600,
|
|
14
|
-
credentials: true,
|
|
15
|
-
}));
|
|
16
|
-
app.all('/api/abc', (c) => {
|
|
17
|
-
return c.json({ success: true });
|
|
18
|
-
});
|
|
19
|
-
app.all('/api2/abc', (c) => {
|
|
20
|
-
return c.json({ success: true });
|
|
21
|
-
});
|
|
22
|
-
it('GET default', async () => {
|
|
23
|
-
const res = await app.request('http://localhost/api/abc');
|
|
24
|
-
expect(res.headers.get('Access-Control-Allow-Origin')).toBe('*');
|
|
25
|
-
expect(res.headers.get('Vary')).toBeNull();
|
|
26
|
-
});
|
|
27
|
-
it('Preflight default', async () => {
|
|
28
|
-
const req = new Request('https://localhost/api/abc', { method: 'OPTIONS' });
|
|
29
|
-
req.headers.append('Access-Control-Request-Headers', 'X-PINGOTHER, Content-Type');
|
|
30
|
-
const res = await app.request(req);
|
|
31
|
-
expect(res.status).toBe(204);
|
|
32
|
-
expect(res.headers.get('Access-Control-Allow-Methods').split(',')[0]).toBe('GET');
|
|
33
|
-
expect(res.headers.get('Access-Control-Allow-Headers').split(',')).toEqual([
|
|
34
|
-
'X-PINGOTHER',
|
|
35
|
-
'Content-Type',
|
|
36
|
-
]);
|
|
37
|
-
});
|
|
38
|
-
it('Preflight with options', async () => {
|
|
39
|
-
const req = new Request('https://localhost/api2/abc', { method: 'OPTIONS' });
|
|
40
|
-
const res = await app.request(req);
|
|
41
|
-
expect(res.headers.get('Access-Control-Allow-Origin')).toBe('http://example.com');
|
|
42
|
-
expect(res.headers.get('Vary').split(/\s*,\s*/)).toEqual(expect.arrayContaining(['Origin']));
|
|
43
|
-
expect(res.headers.get('Access-Control-Allow-Headers').split(/\s*,\s*/)).toEqual([
|
|
44
|
-
'X-Custom-Header',
|
|
45
|
-
'Upgrade-Insecure-Requests',
|
|
46
|
-
]);
|
|
47
|
-
expect(res.headers.get('Access-Control-Allow-Methods').split(/\s*,\s*/)).toEqual([
|
|
48
|
-
'POST',
|
|
49
|
-
'GET',
|
|
50
|
-
'OPTIONS',
|
|
51
|
-
]);
|
|
52
|
-
expect(res.headers.get('Access-Control-Expose-Headers').split(/\s*,\s*/)).toEqual([
|
|
53
|
-
'Content-Length',
|
|
54
|
-
'X-Kuma-Revision',
|
|
55
|
-
]);
|
|
56
|
-
expect(res.headers.get('Access-Control-Max-Age')).toBe('600');
|
|
57
|
-
expect(res.headers.get('Access-Control-Allow-Credentials')).toBe('true');
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const hono_1 = require("../../hono");
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
describe('Etag Middleware', () => {
|
|
6
|
-
const app = new hono_1.Hono();
|
|
7
|
-
app.use('/etag/*', (0, _1.etag)());
|
|
8
|
-
app.get('/etag/abc', (c) => {
|
|
9
|
-
return c.text('Hono is cool');
|
|
10
|
-
});
|
|
11
|
-
app.get('/etag/def', (c) => {
|
|
12
|
-
return c.json({ message: 'Hono is cool' });
|
|
13
|
-
});
|
|
14
|
-
app.use('/etag-weak/*', (0, _1.etag)({ weak: true }));
|
|
15
|
-
app.get('/etag-weak/abc', (c) => {
|
|
16
|
-
return c.text('Hono is cool');
|
|
17
|
-
});
|
|
18
|
-
it('Should return etag header', async () => {
|
|
19
|
-
let res = await app.request('http://localhost/etag/abc');
|
|
20
|
-
expect(res.headers.get('ETag')).not.toBeFalsy();
|
|
21
|
-
expect(res.headers.get('ETag')).toBe('"4e32298b1cb4edc595237405e5b696e105c2399a"');
|
|
22
|
-
res = await app.request('http://localhost/etag/def');
|
|
23
|
-
expect(res.headers.get('ETag')).not.toBeFalsy();
|
|
24
|
-
expect(res.headers.get('ETag')).toBe('"c1d44ff03aff1372856c281854f454e2e1d15b7c"');
|
|
25
|
-
});
|
|
26
|
-
it('Should return etag header - weak', async () => {
|
|
27
|
-
const res = await app.request('http://localhost/etag-weak/abc');
|
|
28
|
-
expect(res.headers.get('ETag')).not.toBeFalsy();
|
|
29
|
-
expect(res.headers.get('ETag')).toBe('W/"4e32298b1cb4edc595237405e5b696e105c2399a"');
|
|
30
|
-
});
|
|
31
|
-
it('Should return 304 response', async () => {
|
|
32
|
-
let res = await app.request('http://localhost/etag/abc');
|
|
33
|
-
expect(res.status).toBe(200);
|
|
34
|
-
expect(res.headers.get('ETag')).not.toBeFalsy();
|
|
35
|
-
const etag = res.headers.get('Etag');
|
|
36
|
-
const req = new Request('http://localhost/etag/abc', {
|
|
37
|
-
headers: {
|
|
38
|
-
'If-None-Match': etag,
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
res = await app.request(req);
|
|
42
|
-
expect(res.status).toBe(304);
|
|
43
|
-
expect(await res.text()).toBe('');
|
|
44
|
-
});
|
|
45
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|