Skip to content

Commit

Permalink
Add http2 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sogaani committed Jul 30, 2018
1 parent 831e9cb commit e4afd79
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ node_js:
- "4.8"
- "5.12"
- "6.12"
- "8.11"
- "10.7"
sudo: false
cache:
directories:
Expand All @@ -25,5 +27,9 @@ script:
- "test ! -z $(npm -ps ls istanbul) || npm test"
- "test -z $(npm -ps ls istanbul) || npm run-script test-ci"
- "test -z $(npm -ps ls eslint) || npm run-script lint"
# Run test script with http2
- "test $(echo $TRAVIS_NODE_VERSION | cut -d. -f1) -ge 8 || npm install https://github.com/sogaani/express.git#initial-support-http2 https://github.com/sogaani/supertest.git#http2"
- "test $(echo $TRAVIS_NODE_VERSION | cut -d. -f1) -ge 8 || npm test-http2"
- "test $(echo $TRAVIS_NODE_VERSION | cut -d. -f1) -ge 8 || npm run-script test-http2-ci"
after_script:
- "test -e ./coverage/lcov.info && npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
"scripts": {
"lint": "eslint .",
"test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/",
"test-http2": "EXPOSE_HTTP2=1 mocha --require test/support/env --reporter spec --bail --check-leaks test/",
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/",
"test-http2-ci": "EXPOSE_HTTP2=1 istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/"
}
}
6 changes: 5 additions & 1 deletion test/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ var assert = require( "assert" )
, cookies = require( "../" ).express
, request = require('supertest')

if(process.env.EXPOSE_HTTP2){
http = require( "http2" )
}

describe('Express', function () {
var server
var header
Expand Down Expand Up @@ -65,7 +69,7 @@ describe('Express', function () {
)
})

server = require('http').createServer(app).listen()
server = http.createServer(app).listen()
})

it('should set cookies', function (done) {
Expand Down
4 changes: 4 additions & 0 deletions test/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ var assert = require( "assert" )
, Cookies = require( "../" )
, request = require('supertest')

if(process.env.EXPOSE_HTTP2){
http = require( "http2" )
}

describe('HTTP', function () {
var server
var header
Expand Down
4 changes: 4 additions & 0 deletions test/restify.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
if(Number(process.version.split('.')[0].slice(1)) >= 8){
process.EventEmitter = require('events')
}
var assert = require('assert')
, restify = require('restify')
, keys = require('keygrip')(['a', 'b'])
, http = require('http')
, Cookies = require('../')
, request = require('supertest')

if(!process.env.EXPOSE_HTTP2)
describe('Restify', function () {
var header
var server
Expand Down
4 changes: 4 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ var Cookies = require('..')
var http = require('http')
var request = require('supertest')

if(process.env.EXPOSE_HTTP2){
http = require( "http2" )
}

describe('new Cookies(req, res, [options])', function () {
it('should create new cookies instance', function (done) {
request(createServer(function (req, res, cookies) {
Expand Down

0 comments on commit e4afd79

Please sign in to comment.