How to use the cookies.prototype function in cookies

To help you get started, we’ve selected a few cookies examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pencilblue / pencilblue / test / include / http / middleware / index.spec.js View on Github external
it('should set the cookie when the flag setSessionCookie is set on the request object', function(done) {
            req.setSessionCookie = true;
            req.session = { uid: 'abc123' };
            sandbox.stub(this.pb.SessionHandler, 'getSessionCookie')
                .withArgs(req.session).returns();
            sandbox.stub(this.pb.log, 'error');
            sandbox.stub(Cookies.prototype, 'set')
                .withArgs(this.pb.SessionHandler.COOKIE_NAME, req.session.uid, sinon.match.any);
            var self = this;
            this.pb.Middleware.writeSessionCookie(req, res, function(err) {
                should(err).eql(undefined);
                self.pb.SessionHandler.getSessionCookie.calledOnce.should.eql(true);
                self.pb.log.error.called.should.eql(false);
                done();
            });
        });
    });