blob: 351893d1e044bddad520c7c82cd7a55d2653187b (
plain) (
blame)
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 * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { AstroCookies } from '../../../dist/core/cookies/index.js';
import { apply as applyPolyfill } from '../../../dist/core/polyfill.js';
applyPolyfill();
describe('astro/src/core/cookies', () => {
describe('Astro.cookies.has', () => {
it('returns true if the request has the cookie', () => {
let req = new Request('http://example.com/', {
headers: {
cookie: 'foo=bar',
},
});
let cookies = new AstroCookies(req);
assert.equal(cookies.has('foo'), true);
});
it('returns false if the request does not have the cookie', () => {
let req = new Request('http://example.com/');
let cookies = new AstroCookies(req);
assert.equal(cookies.has('foo'), false);
});
it('returns true if the cookie has been set', () => {
let req = new Request('http://example.com/');
let cookies = new AstroCookies(req);
cookies.set('foo', 'bar');
assert.equal(cookies.has('foo'), true);
});
});
});
|