Skip to content

Commit

Permalink
lint: apply standard 11 style
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Mar 29, 2018
1 parent 06e69b1 commit 3a93328
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 87 deletions.
10 changes: 5 additions & 5 deletions package.json
Expand Up @@ -18,12 +18,12 @@
"safe-buffer": "5.1.1"
},
"devDependencies": {
"eslint": "3.19.0",
"eslint-config-standard": "10.2.1",
"eslint-plugin-import": "2.8.0",
"eslint": "4.19.1",
"eslint-config-standard": "11.0.0",
"eslint-plugin-import": "2.9.0",
"eslint-plugin-markdown": "1.0.0-beta.6",
"eslint-plugin-node": "5.2.1",
"eslint-plugin-promise": "3.6.0",
"eslint-plugin-node": "6.0.1",
"eslint-plugin-promise": "3.7.0",
"eslint-plugin-standard": "3.0.1",
"istanbul": "0.4.5",
"mocha": "2.5.3",
Expand Down
164 changes: 82 additions & 82 deletions test/test.js
Expand Up @@ -42,65 +42,65 @@ describe('favicon()', function () {
it('should be in cache-control', function (done) {
var server = createServer(null, {maxAge: 5000})
request(server)
.get('/favicon.ico')
.expect('Cache-Control', 'public, max-age=5')
.expect(200, done)
.get('/favicon.ico')
.expect('Cache-Control', 'public, max-age=5')
.expect(200, done)
})

it('should have a default', function (done) {
var server = createServer()
request(server)
.get('/favicon.ico')
.expect('Cache-Control', /public, max-age=[0-9]+/)
.expect(200, done)
.get('/favicon.ico')
.expect('Cache-Control', /public, max-age=[0-9]+/)
.expect(200, done)
})

it('should accept 0', function (done) {
var server = createServer(null, {maxAge: 0})
request(server)
.get('/favicon.ico')
.expect('Cache-Control', 'public, max-age=0')
.expect(200, done)
.get('/favicon.ico')
.expect('Cache-Control', 'public, max-age=0')
.expect(200, done)
})

it('should accept string', function (done) {
var server = createServer(null, {maxAge: '30d'})
request(server)
.get('/favicon.ico')
.expect('Cache-Control', 'public, max-age=2592000')
.expect(200, done)
.get('/favicon.ico')
.expect('Cache-Control', 'public, max-age=2592000')
.expect(200, done)
})

it('should be valid delta-seconds', function (done) {
var server = createServer(null, {maxAge: 1234})
request(server)
.get('/favicon.ico')
.expect('Cache-Control', 'public, max-age=1')
.expect(200, done)
.get('/favicon.ico')
.expect('Cache-Control', 'public, max-age=1')
.expect(200, done)
})

it('should floor at 0', function (done) {
var server = createServer(null, {maxAge: -4000})
request(server)
.get('/favicon.ico')
.expect('Cache-Control', 'public, max-age=0')
.expect(200, done)
.get('/favicon.ico')
.expect('Cache-Control', 'public, max-age=0')
.expect(200, done)
})

it('should ceil at 1 year', function (done) {
var server = createServer(null, {maxAge: 900000000000})
request(server)
.get('/favicon.ico')
.expect('Cache-Control', 'public, max-age=31536000')
.expect(200, done)
.get('/favicon.ico')
.expect('Cache-Control', 'public, max-age=31536000')
.expect(200, done)
})

it('should accept Inifnity', function (done) {
var server = createServer(null, {maxAge: Infinity})
request(server)
.get('/favicon.ico')
.expect('Cache-Control', 'public, max-age=31536000')
.expect(200, done)
.get('/favicon.ico')
.expect('Cache-Control', 'public, max-age=31536000')
.expect(200, done)
})
})
})
Expand All @@ -112,76 +112,76 @@ describe('favicon()', function () {

it('should serve icon', function (done) {
request(this.server)
.get('/favicon.ico')
.expect('Content-Type', 'image/x-icon')
.expect(200, done)
.get('/favicon.ico')
.expect('Content-Type', 'image/x-icon')
.expect(200, done)
})

it('should include cache-control', function (done) {
request(this.server)
.get('/favicon.ico')
.expect('Cache-Control', /public/)
.expect(200, done)
.get('/favicon.ico')
.expect('Cache-Control', /public/)
.expect(200, done)
})

it('should include strong etag', function (done) {
request(this.server)
.get('/favicon.ico')
.expect('ETag', /^"[^"]+"$/)
.expect(200, done)
.get('/favicon.ico')
.expect('ETag', /^"[^"]+"$/)
.expect(200, done)
})

it('should deny POST', function (done) {
request(this.server)
.post('/favicon.ico')
.expect('Allow', 'GET, HEAD, OPTIONS')
.expect(405, done)
.post('/favicon.ico')
.expect('Allow', 'GET, HEAD, OPTIONS')
.expect(405, done)
})

it('should understand OPTIONS', function (done) {
request(this.server)
.options('/favicon.ico')
.expect('Allow', 'GET, HEAD, OPTIONS')
.expect(200, done)
.options('/favicon.ico')
.expect('Allow', 'GET, HEAD, OPTIONS')
.expect(200, done)
})

it('should 304 when If-None-Match matches', function (done) {
var server = this.server
request(server)
.get('/favicon.ico')
.expect(200, function (err, res) {
if (err) return done(err)
request(server)
.get('/favicon.ico')
.set('If-None-Match', res.headers.etag)
.expect(304, done)
})
.expect(200, function (err, res) {
if (err) return done(err)
request(server)
.get('/favicon.ico')
.set('If-None-Match', res.headers.etag)
.expect(304, done)
})
})

it('should 304 when If-None-Match matches weakly', function (done) {
var server = this.server
request(server)
.get('/favicon.ico')
.expect(200, function (err, res) {
if (err) return done(err)
request(server)
.get('/favicon.ico')
.set('If-None-Match', 'W/' + res.headers.etag)
.expect(304, done)
})
.expect(200, function (err, res) {
if (err) return done(err)
request(server)
.get('/favicon.ico')
.set('If-None-Match', 'W/' + res.headers.etag)
.expect(304, done)
})
})

it('should ignore non-favicon requests', function (done) {
request(this.server)
.get('/')
.expect(404, 'oops', done)
.get('/')
.expect(404, 'oops', done)
})

it('should work with query string', function (done) {
request(this.server)
.get('/favicon.ico?v=1')
.expect('Content-Type', 'image/x-icon')
.expect(200, done)
.get('/favicon.ico?v=1')
.expect('Content-Type', 'image/x-icon')
.expect(200, done)
})

describe('missing req.url', function () {
Expand Down Expand Up @@ -209,23 +209,23 @@ describe('favicon()', function () {
var server = createServer(icon.path)

request(server)
.get('/favicon.ico')
.expect(200, icon.data, done)
.get('/favicon.ico')
.expect(200, icon.data, done)
})

it('should cache for second request', function (done) {
var icon = this.icon
var server = createServer(icon.path)

request(server)
.get('/favicon.ico')
.expect(200, icon.data, function (err) {
if (err) return done(err)
icon.unlinkSync()
request(server)
.get('/favicon.ico')
.expect(200, icon.data, done)
})
.expect(200, icon.data, function (err) {
if (err) return done(err)
icon.unlinkSync()
request(server)
.get('/favicon.ico')
.expect(200, icon.data, done)
})
})
})

Expand All @@ -246,8 +246,8 @@ describe('favicon()', function () {

icon.unlinkSync()
request(server)
.get('/favicon.ico')
.expect(500, /ENOENT/, done)
.get('/favicon.ico')
.expect(500, /ENOENT/, done)
})

it('should retry reading file after error', function (done) {
Expand All @@ -256,14 +256,14 @@ describe('favicon()', function () {

icon.unlinkSync()
request(server)
.get('/favicon.ico')
.expect(500, /ENOENT/, function (err) {
if (err) return done(err)
icon.writeSync()
request(server)
.get('/favicon.ico')
.expect(200, icon.data, done)
})
.expect(500, /ENOENT/, function (err) {
if (err) return done(err)
icon.writeSync()
request(server)
.get('/favicon.ico')
.expect(200, icon.data, done)
})
})
})

Expand All @@ -273,9 +273,9 @@ describe('favicon()', function () {
var server = createServer(buffer)

request(server)
.get('/favicon.ico')
.expect('Content-Length', '20')
.expect(200, buffer, done)
.get('/favicon.ico')
.expect('Content-Length', '20')
.expect(200, buffer, done)
})

it('should be copied', function (done) {
Expand All @@ -287,9 +287,9 @@ describe('favicon()', function () {
assert.equal(buffer.toString(), '????????????????????')

request(server)
.get('/favicon.ico')
.expect('Content-Length', '20')
.expect(200, Buffer.from('####################'), done)
.get('/favicon.ico')
.expect('Content-Length', '20')
.expect(200, Buffer.from('####################'), done)
})
})
})
Expand Down

0 comments on commit 3a93328

Please sign in to comment.