Skip to content

Commit

Permalink
fix(test): fixed up preferred encoding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleytodd committed Aug 31, 2024
1 parent 251627c commit f0146d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Negotiator.prototype.encoding = function encoding(available, opts) {
};

Negotiator.prototype.encodings = function encodings(available, options) {
opts = options || {};
var opts = options || {};
return preferredEncodings(this.request.headers['accept-encoding'], available, opts.preferred);
};

Expand Down
16 changes: 6 additions & 10 deletions test/encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,12 @@ describe('negotiator.encoding(array)', function () {
it('should return most client-preferred encoding', function () {
assert.strictEqual(this.negotiator.encoding(['gzip']), 'gzip')
assert.strictEqual(this.negotiator.encoding(['compress', 'identity']), 'identity')
assert.strictEqual(this.negotiator.encoding(['gzip', 'deflate'], ['deflate']), 'gzip')
assert.strictEqual(this.negotiator.encoding(['deflate', 'gzip'], ['deflate']), 'gzip')
})

it('should return developer-preferred encodings', function () {
assert.strictEqual(this.negotiator.encoding(['gzip', 'deflate'], ['gzip']), 'gzip')
assert.strictEqual(this.negotiator.encoding(['deflate', 'gzip'], ['gzip']), 'gzip')
assert.strictEqual(this.negotiator.encoding(['gzip'], ['gzip']), 'gzip')
assert.strictEqual(this.negotiator.encoding(['gzip', 'deflate'], { preferred: ['gzip'] }), 'gzip')
assert.strictEqual(this.negotiator.encoding(['deflate', 'gzip'], { preferred: ['gzip'] }), 'gzip')
assert.strictEqual(this.negotiator.encoding(['gzip'], { preferred: ['gzip'] }), 'gzip')
})
})
})
Expand Down Expand Up @@ -439,14 +437,12 @@ describe('negotiator.encodings(array)', function () {
it('should return client-preferred encodings', function () {
assert.deepEqual(this.negotiator.encodings(['gzip']), ['gzip'])
assert.deepEqual(this.negotiator.encodings(['identity', 'gzip', 'compress']), ['gzip', 'identity', 'compress'])
assert.deepEqual(this.negotiator.encodings(['gzip', 'deflate'], ['deflate']), ['gzip', 'deflate'])
assert.deepEqual(this.negotiator.encodings(['deflate', 'gzip'], ['deflate']), ['gzip', 'deflate'])
})

it('should return developer-preferred encodings', function () {
assert.deepEqual(this.negotiator.encodings(['gzip', 'deflate'], ['gzip']), ['gzip', 'deflate'])
assert.deepEqual(this.negotiator.encodings(['deflate', 'gzip'], ['gzip']), ['gzip', 'deflate'])
assert.deepEqual(this.negotiator.encodings(['gzip'], ['gzip']), ['gzip'])
assert.deepEqual(this.negotiator.encodings(['gzip', 'deflate'], { preferred: ['gzip'] }), ['gzip', 'deflate'])
assert.deepEqual(this.negotiator.encodings(['deflate', 'gzip'], { preferred: ['gzip'] }), ['gzip', 'deflate'])
assert.deepEqual(this.negotiator.encodings(['gzip'], { preferred: ['gzip'] }), ['gzip'])
})
})
})
Expand Down

0 comments on commit f0146d0

Please sign in to comment.