+ assert.throws(() => common.addCookie(res, name, value, { sameSite: 'Whatever' }), RangeError);
+ });
+ it('covers invalid sameSite/secure setting', function () {
+ assert.throws(() => common.addCookie(res, name, value, { sameSite: 'None', secure: false }), RangeError);
+ });
+ it('covers invalid path', function () {
+ assert.throws(() => common.addCookie(res, name, value, { path: '/bad;path' }), RangeError);
+ });
+ it('covers invalid domain', function () {
+ assert.throws(() => common.addCookie(res, name, value, { domain: 'a-.com' }), RangeError);
+ });
+ it('covers invalid extension type', function () {
+ assert.throws(() => common.addCookie(res, name, value, { extension: 'extension' }), TypeError);
+ });
+ it('covers invalid extension', function () {
+ assert.throws(() => common.addCookie(res, name, value, { extension: ['bad;extension'] }), RangeError);
+ });
+ it('covers invalid name', function () {
+ name = 'bad:name';
+ assert.throws(() => common.addCookie(res, name, value), RangeError);
+ });
+ it('covers invalid value', function () {
+ value = 'bad;value';
+ assert.throws(() => common.addCookie(res, name, value), RangeError);
+ });
+ it('covers quoted value', function () {
+ value = '"value"';
+ common.addCookie(res, name, value);
+ assert(res.appendHeader.called);
+ });
+ it('covers invalid quoted value', function () {
+ value = '"bad;value"';
+ assert.throws(() => common.addCookie(res, name, value), RangeError);