Skip to content

Commit

Permalink
Use an env var to toggle gzip tests
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Jun 4, 2020
1 parent 8e0e3f4 commit 424d1d9
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions test/functional_test.js
Expand Up @@ -43,19 +43,21 @@ if (ENV.BCDN_HEADERS === 'debug') {
expectedHeaders['x-hw'] = '';
}

/*
const compressedExtensions = [
'css',
'eot',
'js',
'map',
'otf',
'svg',
'ttf',
'woff',
'woff2'
];
*/
let compressedExtensions;

if (ENV.BCDN_GZIP_TESTS === 'true') {
compressedExtensions = new Set([
'css',
'eot',
'js',
'map',
'otf',
'svg',
'ttf',
'woff',
'woff2'
]);
}

const CONTENT_TYPE_MAP = {
css: 'text/css; charset=utf-8',
Expand Down Expand Up @@ -107,8 +109,6 @@ function assertSRI(uri, actualSri, done) {
const s3include = new Set(['content-type']);

function assertHeaders(uri) {
// const ext = helpers.getExtension(uri);

Object.keys(expectedHeaders).forEach((header) => {
// Ignore header name case as per the specs
header = header.toLowerCase();
Expand Down Expand Up @@ -138,19 +138,20 @@ function assertHeaders(uri) {
}
});

/*
if (compressedExtensions.includes(ext)) {
it('has content-encoding: gzip', (done) => {
assert.equal(responses[uri].headers['content-encoding'], 'gzip');
done();
});
} else {
it('does NOT have content-encoding set', (done) => {
assert.equal(responses[uri].headers['content-encoding'], undefined);
done();
});
if (ENV.BCDN_GZIP_TESTS === 'true') {
const ext = helpers.getExtension(uri);
if (compressedExtensions.has(ext)) {
it('has content-encoding: gzip', (done) => {
assert.equal(responses[uri].headers['content-encoding'], 'gzip');
done();
});
} else {
it('does NOT have content-encoding set', (done) => {
assert.equal(responses[uri].headers['content-encoding'], undefined);
done();
});
}
}
*/
}

function assertContentType(uri, currentType, cb) {
Expand Down

0 comments on commit 424d1d9

Please sign in to comment.