forked from muhammaddadu/clout-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from clout-stack/task/add-test-for-redirects
add tests for redirects
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const should = require('should'); | ||
const testLib = require('./lib'); | ||
const request = testLib.request; | ||
|
||
describe('e2e User Auth Tests', function () { | ||
let clout; | ||
|
||
before(() => { | ||
process.env.PORT = 8420; | ||
process.env.NODE_ENV = 'test'; | ||
clout = testLib.createInstance(); | ||
}); | ||
|
||
it('start server', (done) => { | ||
clout.start(); | ||
clout.on('started', () => { | ||
let server = clout.server['http']; | ||
if (server) { | ||
let port = server.address().port; | ||
serverAddress = `http://localhost:${port}`; | ||
} | ||
done(); | ||
}); | ||
}); | ||
|
||
describe('/redirect', () => { | ||
it('should give 302 /redirect/google', async () => { | ||
const response = await request({ uri: `/redirect/google`, followRedirect: false }); | ||
should(response.statusCode).be.equal(302); | ||
should(response.headers.location).be.equal('https://google.com'); | ||
}); | ||
}); | ||
|
||
after('stop server', (done) => { | ||
clout.on('stopped', () => done()); | ||
clout.stop(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
path: '/redirect/google', | ||
method: 'get', | ||
description: ` | ||
Controller Example to demonstrate redirections | ||
`, | ||
fn: (req, resp) => { | ||
return resp.redirect('https://google.com'); | ||
} | ||
}; |