Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("Render view with application.render", function (done) {
request.get("/applicationRender")
.expect(200)
.end(function (err, res) {
done();
})
})
});
it("should render a 404 page for an invalid route", function(done){
request.get('/not-found-route')
.expect(404)
.end(function (err, res) {
var doc = cheerio.load(res.text);
expect(doc("body").html()).toContain("The Page you were looking for isn't here!");
done();
});
});
});
it('Logout with req.logout', function (done) {
request.get("/logout")
.expect(302, done);
})
});
it('should allow request when origin defined as function and no origin is supplied', function(done) {
var sockets = io({ origins: function(origin,callback){
if (origin == '*') {
return callback(null, true);
}
return callback(null, false);
} }).listen('54021');
request.get('http://localhost:54021/socket.io/default/')
.query({ transport: 'polling' })
.end(function (err, res) {
expect(res.status).to.be(200);
done();
});
});
it('returns a random module metadata', function(done) {
request.get('/' + randomModule)
.expect(200, done);
});
});
it('should return a user', function (done) {
request
.get('/api/v1/users/trudesk')
.set('accesstoken', tdapikey)
.set('Accept', 'application/json')
.expect(function (res) {
if (res.body.user.username !== 'trudesk') throw new Error('Invalid User')
})
.expect(200, done)
})
it('should allow request when origin defined as function and different is supplied', function(done) {
var sockets = io({ origins: function(origin,callback){
if (origin == 'http://foo.example') {
return callback(null, true);
}
return callback(null, false);
} }).listen('54017');
request.get('http://localhost:54017/socket.io/default/')
.set('origin', 'http://herp.derp')
.query({ transport: 'polling' })
.end(function (err, res) {
expect(res.status).to.be(400);
done();
});
});
it('404 response on non-existing tarball', function(done) {
request.get('/multiparty/-/multiparty-2.222.0.tgz')
.expect(404, done);
});
});
it('respond with json', function(done) {
request.get('/')
.set('Accept', 'application/json')
.expect(200)
.expect(/registry/, done);
});
});
it('should disallow request when origin defined and none specified', function(done) {
var sockets = io({ origins: 'http://foo.example:*' }).listen('54013');
request.get('http://localhost:54013/socket.io/default/')
.query({ transport: 'polling' })
.end(function (err, res) {
expect(res.status).to.be(400);
done();
});
});