ignore ETAG query test as well, reuse skip util (#5639)

This commit is contained in:
Jon Church 2024-05-04 18:01:42 -04:00 committed by GitHub
parent 8417c60fcf
commit b44191eb3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 16 deletions

View File

@ -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();
@ -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

View File

@ -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){
@ -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();

View File

@ -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.
@ -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)]
}