2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00
Files
axios/test/specs/helpers/cookies.spec.js
T
Jay fa337332b9 Update unit testing flows as part of migration to vitest (#7484)
* chore: small fixes to tests

* feat: transitional move to vitests

* feat: moving unit tests in progress

* feat: moving more unit tests over

* feat: more tests moved

* feat: updated more sections of the http test

* chore: wip http tests

* chore: wip http tests

* chore: more http tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: remove un-needed docs

* chore: update package lock

* chore: update lock
2026-03-06 20:42:14 +02:00

41 lines
1.1 KiB
JavaScript

/* eslint-env mocha */
import cookies from '../../../lib/helpers/cookies';
describe('helpers::cookies', function () {
afterEach(function () {
// Remove all the cookies
const expires = Date.now() - 60 * 60 * 24 * 7;
document.cookie
.split(';')
.map(function (cookie) {
return cookie.split('=')[0];
})
.forEach(function (name) {
document.cookie = name + '=; expires=' + new Date(expires).toGMTString();
});
});
it('should write cookies', function () {
cookies.write('foo', 'baz');
expect(document.cookie).toEqual('foo=baz');
});
it('should read cookies', function () {
cookies.write('foo', 'abc');
cookies.write('bar', 'def');
expect(cookies.read('foo')).toEqual('abc');
expect(cookies.read('bar')).toEqual('def');
});
it('should remove cookies', function () {
cookies.write('foo', 'bar');
cookies.remove('foo');
expect(cookies.read('foo')).toEqual(null);
});
it('should uri encode values', function () {
cookies.write('foo', 'bar baz%');
expect(document.cookie).toEqual('foo=bar%20baz%25');
});
});