Skip to content

Commit

Permalink
ignore ETAG query test as well, reuse skip util (#5639)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonchurch committed May 4, 2024
1 parent 8417c60 commit b44191e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
18 changes: 2 additions & 16 deletions test/app.router.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ var express = require('../')
, assert = require('assert')
, methods = require('methods');

var shouldSkipQuery = require('./support/utils').shouldSkipQuery

describe('app.router', function(){
it('should restore req.params after leaving router', function(done){
var app = express();
Expand Down Expand Up @@ -35,22 +37,6 @@ describe('app.router', function(){
})

describe('methods', function(){
function getMajorVersion(versionString) {
return versionString.split('.')[0];
}

function shouldSkipQuery(versionString) {
// Temporarily skipping this test on 21 and 22
// update this implementation to run on those release lines on supported versions once they exist
// upstream tracking https://github.com/nodejs/node/pull/51719
// express tracking issue: https://github.com/expressjs/express/issues/5615
var majorsToSkip = {
"21": true,
"22": true
}
return majorsToSkip[getMajorVersion(versionString)]
}

methods.concat('del').forEach(function(method){
if (method === 'connect') return;
if (method === 'query' && shouldSkipQuery(process.versions.node)) return
Expand Down
3 changes: 3 additions & 0 deletions test/res.send.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ var methods = require('methods');
var request = require('supertest');
var utils = require('./support/utils');

var shouldSkipQuery = require('./support/utils').shouldSkipQuery

describe('res', function(){
describe('.send()', function(){
it('should set body to ""', function(done){
Expand Down Expand Up @@ -407,6 +409,7 @@ describe('res', function(){

methods.forEach(function (method) {
if (method === 'connect') return;
if (method === 'query' && shouldSkipQuery(process.versions.node)) return

it('should send ETag in response to ' + method.toUpperCase() + ' request', function (done) {
var app = express();
Expand Down
18 changes: 18 additions & 0 deletions test/support/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ exports.shouldHaveBody = shouldHaveBody
exports.shouldHaveHeader = shouldHaveHeader
exports.shouldNotHaveBody = shouldNotHaveBody
exports.shouldNotHaveHeader = shouldNotHaveHeader;
exports.shouldSkipQuery = shouldSkipQuery

/**
* Assert that a supertest response has a specific body.
Expand Down Expand Up @@ -70,3 +71,20 @@ function shouldNotHaveHeader(header) {
assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header);
};
}

function getMajorVersion(versionString) {
return versionString.split('.')[0];
}

function shouldSkipQuery(versionString) {
// Temporarily skipping this test on 21 and 22
// update this implementation to run on those release lines on supported versions once they exist
// upstream tracking https://github.com/nodejs/node/pull/51719
// express tracking issue: https://github.com/expressjs/express/issues/5615
var majorsToSkip = {
"21": true,
"22": true
}
return majorsToSkip[getMajorVersion(versionString)]
}

0 comments on commit b44191e

Please sign in to comment.