Skip to content

Commit

Permalink
tests: fix buffer comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanong committed Feb 27, 2016
1 parent 201c130 commit 079469a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -12,6 +12,7 @@
"index.js"
],
"devDependencies": {
"buffer-equal": "^1.0.0",
"istanbul": "^0.4.2",
"koa": "^1.0.0",
"mocha": "^2.0.0",
Expand Down
13 changes: 9 additions & 4 deletions test/index.js
@@ -1,3 +1,4 @@
var bufferEqual = require('buffer-equal');
var request = require('supertest');
var join = require('path').join;
var assert = require('assert');
Expand All @@ -14,8 +15,8 @@ describe('favicon()', function(){
app.use(favicon(path));

app.use(function *(next){
assert(this.body == null);
assert(this.get('Content-Type') == null);
assert(!this.body);
assert(!this.get('Content-Type'));
this.body = 'hello';
});

Expand Down Expand Up @@ -50,9 +51,13 @@ describe('favicon()', function(){

request(app.listen())
.get('/favicon.ico')
.expect(200)
.expect('Content-Type', 'image/x-icon')
.expect(body.toString(), done);
.expect(200, function(err, res){
if (err) return done(err);

assert(bufferEqual(body, res.body));
done();
});
});

it('should set cache-control headers', function(done){
Expand Down

0 comments on commit 079469a

Please sign in to comment.