-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
43 lines (33 loc) · 1.15 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
if (!global.Promise) {
global.Promise = require('q');
}
var chai = require('chai')
, chaiHttp = require('chai-http');
chai.use(chaiHttp);
const Muneem = require("muneem");
const bridge = require("./bridge");
const cookieParser = require("cookie-parser");
describe ('Express bridge', () => {
it('should parse cookies using express cookie-parser middleware.', (done) => {
const app = Muneem();
app.use( bridge, cookieParser() );
app.get("/test", (req, res) =>{
expect( req.cookies ).toEqual({
cookieName: "cookieValue",
otherName: "otherValue"
});
res.write("I'm glad to response you back.");
})
app.start();
chai.request("http://localhost:3002")
.get('/test')
.set('Cookie', 'cookieName=cookieValue;otherName=otherValue')
.then(res => {
expect(res.status).toBe(200);
expect(res.text).toBe("I'm glad to response you back.");
done();
}).catch( err => {
done.fail("not expected " + err);
});
});
});