Skip to content

Commit

Permalink
tests: use strict equality
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Jul 25, 2018
1 parent cea5980 commit a6f5766
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 157 deletions.
74 changes: 37 additions & 37 deletions test/charset.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,148 +154,148 @@ describe('negotiator.charset(array)', function () {
describe('negotiator.charsets()', function () {
whenAcceptCharset(undefined, function () {
it('should return *', function () {
assert.deepEqual(this.negotiator.charsets(), ['*'])
assert.deepStrictEqual(this.negotiator.charsets(), ['*'])
})
})

whenAcceptCharset('*', function () {
it('should return *', function () {
assert.deepEqual(this.negotiator.charsets(), ['*'])
assert.deepStrictEqual(this.negotiator.charsets(), ['*'])
})
})

whenAcceptCharset('*, UTF-8', function () {
it('should return client-preferred charsets', function () {
assert.deepEqual(this.negotiator.charsets(), ['*', 'UTF-8'])
assert.deepStrictEqual(this.negotiator.charsets(), ['*', 'UTF-8'])
})
})

whenAcceptCharset('*, UTF-8;q=0', function () {
it('should exclude UTF-8', function () {
assert.deepEqual(this.negotiator.charsets(), ['*'])
assert.deepStrictEqual(this.negotiator.charsets(), ['*'])
})
})

whenAcceptCharset('UTF-8;q=0', function () {
it('should return empty list', function () {
assert.deepEqual(this.negotiator.charsets(), [])
assert.deepStrictEqual(this.negotiator.charsets(), [])
})
})

whenAcceptCharset('ISO-8859-1', function () {
it('should return client-preferred charsets', function () {
assert.deepEqual(this.negotiator.charsets(), ['ISO-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(), ['ISO-8859-1'])
})
})

whenAcceptCharset('UTF-8, ISO-8859-1', function () {
it('should return client-preferred charsets', function () {
assert.deepEqual(this.negotiator.charsets(), ['UTF-8', 'ISO-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(), ['UTF-8', 'ISO-8859-1'])
})
})

whenAcceptCharset('UTF-8;q=0.8, ISO-8859-1', function () {
it('should return client-preferred charsets', function () {
assert.deepEqual(this.negotiator.charsets(), ['ISO-8859-1', 'UTF-8'])
assert.deepStrictEqual(this.negotiator.charsets(), ['ISO-8859-1', 'UTF-8'])
})
})

whenAcceptCharset('UTF-8;q=0.9, ISO-8859-1;q=0.8, UTF-8;q=0.7', function () {
it.skip('should use highest perferred order on duplicate', function () {
assert.deepEqual(this.negotiator.charsets(), ['UTF-8', 'ISO-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(), ['UTF-8', 'ISO-8859-1'])
})
})
})

describe('negotiator.charsets(array)', function () {
whenAcceptCharset(undefined, function () {
it('should return empty list for empty list', function () {
assert.deepEqual(this.negotiator.charsets([]), [])
assert.deepStrictEqual(this.negotiator.charsets([]), [])
})

it('should return original list', function () {
assert.deepEqual(this.negotiator.charsets(['UTF-8']), ['UTF-8'])
assert.deepEqual(this.negotiator.charsets(['UTF-8', 'ISO-8859-1']), ['UTF-8', 'ISO-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(['UTF-8']), ['UTF-8'])
assert.deepStrictEqual(this.negotiator.charsets(['UTF-8', 'ISO-8859-1']), ['UTF-8', 'ISO-8859-1'])
})
})

whenAcceptCharset('*', function () {
it('should return empty list for empty list', function () {
assert.deepEqual(this.negotiator.charsets([]), [])
assert.deepStrictEqual(this.negotiator.charsets([]), [])
})

it('should return original list', function () {
assert.deepEqual(this.negotiator.charsets(['UTF-8']), ['UTF-8'])
assert.deepEqual(this.negotiator.charsets(['UTF-8', 'ISO-8859-1']), ['UTF-8', 'ISO-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(['UTF-8']), ['UTF-8'])
assert.deepStrictEqual(this.negotiator.charsets(['UTF-8', 'ISO-8859-1']), ['UTF-8', 'ISO-8859-1'])
})
})

whenAcceptCharset('*, UTF-8', function () {
it('should return matching charsets', function () {
assert.deepEqual(this.negotiator.charsets(['UTF-8']), ['UTF-8'])
assert.deepEqual(this.negotiator.charsets(['UTF-8', 'ISO-8859-1']), ['UTF-8', 'ISO-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(['UTF-8']), ['UTF-8'])
assert.deepStrictEqual(this.negotiator.charsets(['UTF-8', 'ISO-8859-1']), ['UTF-8', 'ISO-8859-1'])
})
})

whenAcceptCharset('*, UTF-8;q=0', function () {
it('should exclude UTF-8', function () {
assert.deepEqual(this.negotiator.charsets(['UTF-8']), [])
assert.deepEqual(this.negotiator.charsets(['UTF-8', 'ISO-8859-1']), ['ISO-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(['UTF-8']), [])
assert.deepStrictEqual(this.negotiator.charsets(['UTF-8', 'ISO-8859-1']), ['ISO-8859-1'])
})
})

whenAcceptCharset('UTF-8;q=0', function () {
it('should always return empty list', function () {
assert.deepEqual(this.negotiator.charsets(['ISO-8859-1']), [])
assert.deepEqual(this.negotiator.charsets(['UTF-8', 'KOI8-R', 'ISO-8859-1']), [])
assert.deepEqual(this.negotiator.charsets(['KOI8-R']), [])
assert.deepStrictEqual(this.negotiator.charsets(['ISO-8859-1']), [])
assert.deepStrictEqual(this.negotiator.charsets(['UTF-8', 'KOI8-R', 'ISO-8859-1']), [])
assert.deepStrictEqual(this.negotiator.charsets(['KOI8-R']), [])
})
})

whenAcceptCharset('ISO-8859-1', function () {
it('should return matching charsets', function () {
assert.deepEqual(this.negotiator.charsets(['ISO-8859-1']), ['ISO-8859-1'])
assert.deepEqual(this.negotiator.charsets(['UTF-8', 'ISO-8859-1']), ['ISO-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(['ISO-8859-1']), ['ISO-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(['UTF-8', 'ISO-8859-1']), ['ISO-8859-1'])
})

it('should be case insensitive, returning provided casing', function () {
assert.deepEqual(this.negotiator.charsets(['iso-8859-1']), ['iso-8859-1'])
assert.deepEqual(this.negotiator.charsets(['iso-8859-1', 'ISO-8859-1']), ['iso-8859-1', 'ISO-8859-1'])
assert.deepEqual(this.negotiator.charsets(['ISO-8859-1', 'iso-8859-1']), ['ISO-8859-1', 'iso-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(['iso-8859-1']), ['iso-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(['iso-8859-1', 'ISO-8859-1']), ['iso-8859-1', 'ISO-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(['ISO-8859-1', 'iso-8859-1']), ['ISO-8859-1', 'iso-8859-1'])
})

it('should return empty list when no matching charsets', function () {
assert.deepEqual(this.negotiator.charsets(['utf-8']), [])
assert.deepStrictEqual(this.negotiator.charsets(['utf-8']), [])
})
})

whenAcceptCharset('UTF-8, ISO-8859-1', function () {
it('should return matching charsets', function () {
assert.deepEqual(this.negotiator.charsets(['ISO-8859-1']), ['ISO-8859-1'])
assert.deepEqual(this.negotiator.charsets(['UTF-8', 'KOI8-R', 'ISO-8859-1']), ['UTF-8', 'ISO-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(['ISO-8859-1']), ['ISO-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(['UTF-8', 'KOI8-R', 'ISO-8859-1']), ['UTF-8', 'ISO-8859-1'])
})

it('should return empty list when no matching charsets', function () {
assert.deepEqual(this.negotiator.charsets(['KOI8-R']), [])
assert.deepStrictEqual(this.negotiator.charsets(['KOI8-R']), [])
})
})

whenAcceptCharset('UTF-8;q=0.8, ISO-8859-1', function () {
it('should return matching charsets in client-preferred order', function () {
assert.deepEqual(this.negotiator.charsets(['ISO-8859-1']), ['ISO-8859-1'])
assert.deepEqual(this.negotiator.charsets(['UTF-8', 'KOI8-R', 'ISO-8859-1']), ['ISO-8859-1', 'UTF-8'])
assert.deepStrictEqual(this.negotiator.charsets(['ISO-8859-1']), ['ISO-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(['UTF-8', 'KOI8-R', 'ISO-8859-1']), ['ISO-8859-1', 'UTF-8'])
})

it('should return empty list when no matching charsets', function () {
assert.deepEqual(this.negotiator.charsets(['KOI8-R']), [])
assert.deepStrictEqual(this.negotiator.charsets(['KOI8-R']), [])
})
})

whenAcceptCharset('UTF-8;q=0.9, ISO-8859-1;q=0.8, UTF-8;q=0.7', function () {
it('should use highest perferred order on duplicate', function () {
assert.deepEqual(this.negotiator.charsets(['ISO-8859-1']), ['ISO-8859-1'])
assert.deepEqual(this.negotiator.charsets(['UTF-8', 'ISO-8859-1']), ['UTF-8', 'ISO-8859-1'])
assert.deepEqual(this.negotiator.charsets(['ISO-8859-1', 'UTF-8']), ['UTF-8', 'ISO-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(['ISO-8859-1']), ['ISO-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(['UTF-8', 'ISO-8859-1']), ['UTF-8', 'ISO-8859-1'])
assert.deepStrictEqual(this.negotiator.charsets(['ISO-8859-1', 'UTF-8']), ['UTF-8', 'ISO-8859-1'])
})
})
})
Expand Down

0 comments on commit a6f5766

Please sign in to comment.