forked from mkschreder/node-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
46 lines (41 loc) · 1.08 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
44
45
46
/* eslint-env mocha */
var request = require('supertest');
var assert = require('chai').assert;
var express = require('express');
var php = require('../main');
var app = express();
app.use('/', php.cgi(__dirname + '/php'));
describe('GET /', function() {
it('should respond with /index.php', function(done) {
request(app)
.get('/')
.set('Accept', 'application/json')
.expect('Content-Type', /json/)
.expect(200)
.end(function(err, res) {
if (err) {
done(err);
} else {
assert.match(res.body.$_SERVER.SCRIPT_FILENAME, /index.php$/);
}
done();
});
});
});
describe('Get /index.php', function() {
it('should return a valid $_SERVER variable', function(done) {
request(app)
.get('/index.php')
.set('Accept', 'application/json')
.expect('Content-Type', /json/)
.expect(200)
.end(function(err, res) {
if (err) {
done(err);
} else {
assert.match(res.body.$_SERVER.REMOTE_ADDR, /127.0.0.1|::1/);
}
done();
});
});
});