+ describe('ingestCookie', function () {
+ let req, res, ctx;
+ beforeEach(function () {
+ req = {
+ getHeader: sinon.stub(),
+ };
+ ctx = {};
+ });
+ it('covers no header', function () {
+ const expected = {};
+ Dingus.ingestCookie(req, res, ctx);
+ assert.deepStrictEqual(ctx.cookie, expected);
+ });
+ it('covers non variable', function () {
+ req.getHeader.returns('foo');
+ const expected = {
+ foo: null,
+ };
+ Dingus.ingestCookie(req, res, ctx);
+ assert.deepStrictEqual(ctx.cookie, expected);
+ });
+ it('parses cookies', function () {
+ req.getHeader.returns('foo=bar; baz="quux"');
+ const expected = {
+ foo: 'bar',
+ baz: 'quux',
+ };
+ Dingus.ingestCookie(req, res, ctx);
+ assert.deepStrictEqual(ctx.cookie, expected);
+ });
+ it('parses nulls', function () {
+ req.getHeader.returns('foo=; bar=');
+ const expected = {
+ foo: '',
+ bar: '',
+ };
+ Dingus.ingestCookie(req, res, ctx);
+ assert.deepStrictEqual(ctx.cookie, expected);
+ });
+ it('parses non-uri-encoded', function () {
+ req.getHeader.returns('foo%=%qux');
+ const expected = {
+ 'foo%': '%qux',
+ };
+ Dingus.ingestCookie(req, res, ctx);
+ assert.deepStrictEqual(ctx.cookie, expected);
+ });
+ it('covers nameless cookie', function () {
+ req.getHeader.returns('=bar');
+ const expected = {
+ };
+ Dingus.ingestCookie(req, res, ctx);
+ assert.deepStrictEqual(ctx.cookie, expected);
+
+ });
+ it('covers duplicate cookie', function () {
+ req.getHeader.returns('foo=bar; foo="quux"');
+ const expected = {
+ foo: 'bar',
+ };
+ Dingus.ingestCookie(req, res, ctx);
+ assert.deepStrictEqual(ctx.cookie, expected);
+ });
+ }); // ingestCookie
+