forked from pattern-lab/patternlab-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttps.js
More file actions
48 lines (45 loc) · 1.23 KB
/
https.js
File metadata and controls
48 lines (45 loc) · 1.23 KB
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
47
48
var request = require('supertest');
var path = require('path');
// accept self-signed certificates
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
function tests(liveServer) {
it('should reply with a correct index file', function(done) {
request(liveServer)
.get('/index.html')
.expect('Content-Type', 'text/html; charset=UTF-8')
.expect(/Hello world/i)
.expect(200, done);
});
it('should support head request', function(done) {
request(liveServer)
.head('/index.html')
.expect('Content-Type', 'text/html; charset=UTF-8')
.expect(200, done);
});
}
describe('https tests with external module', function() {
var opts = {
root: path.join(__dirname, 'data'),
port: 0,
open: false,
https: path.join(__dirname, 'conf/https.conf.js'),
};
var liveServer = require('..').start(opts);
tests(liveServer);
after(function() {
liveServer.close();
});
});
describe('https tests with object', function() {
var opts = {
root: path.join(__dirname, 'data'),
port: 0,
open: false,
https: require(path.join(__dirname, 'conf/https.conf.js')),
};
var liveServer = require('..').start(opts);
tests(liveServer);
after(function() {
liveServer.close();
});
});