4b1a1da652
closes #553 Update test: application -> use() should throw if not a function Fix lint Use arrow function Refactor test using arrow function Remove non mandatory brackets fix for merge Fix: missing refactor after merge Use arrow function for old generator
42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
|
|
'use strict';
|
|
|
|
const context = require('../helpers/context');
|
|
|
|
describe('ctx.acceptsEncodings()', () => {
|
|
describe('with no arguments', () => {
|
|
describe('when Accept-Encoding is populated', () => {
|
|
it('should return accepted types', () => {
|
|
const ctx = context();
|
|
ctx.req.headers['accept-encoding'] = 'gzip, compress;q=0.2';
|
|
ctx.acceptsEncodings().should.eql(['gzip', 'compress', 'identity']);
|
|
ctx.acceptsEncodings('gzip', 'compress').should.equal('gzip');
|
|
});
|
|
});
|
|
|
|
describe('when Accept-Encoding is not populated', () => {
|
|
it('should return identity', () => {
|
|
const ctx = context();
|
|
ctx.acceptsEncodings().should.eql(['identity']);
|
|
ctx.acceptsEncodings('gzip', 'deflate', 'identity').should.equal('identity');
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('with multiple arguments', () => {
|
|
it('should return the best fit', () => {
|
|
const ctx = context();
|
|
ctx.req.headers['accept-encoding'] = 'gzip, compress;q=0.2';
|
|
ctx.acceptsEncodings('compress', 'gzip').should.eql('gzip');
|
|
ctx.acceptsEncodings('gzip', 'compress').should.eql('gzip');
|
|
});
|
|
});
|
|
|
|
describe('with an array', () => {
|
|
it('should return the best fit', () => {
|
|
const ctx = context();
|
|
ctx.req.headers['accept-encoding'] = 'gzip, compress;q=0.2';
|
|
ctx.acceptsEncodings(['compress', 'gzip']).should.eql('gzip');
|
|
});
|
|
});
|
|
});
|