Skip to content

Commit

Permalink
Test for PNG too
Browse files Browse the repository at this point in the history
  • Loading branch information
basicallydan committed Dec 4, 2015
1 parent f78ec62 commit 31aa017
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions tests/media.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ describe('Interfake File Response Tests', function() {
}
});

// Testing the fluent interface
describe('#get()', function() {
describe('#image()', function() {
it('should respond with the same image', function(done) {
it('should respond with a jpg image', function(done) {
interfake.get('/image').image('./tests/assets/10x10-imagejpg.jpg');
interfake.listen(3000);

Expand All @@ -44,7 +43,29 @@ describe('Interfake File Response Tests', function() {
fs.readFile('./tests/assets/10x10-imagejpg.jpg', function(err, correctData) {
if (err) throw err;
assert.equal(correctData, body);
fs.readFile('./tests/assets/20x20-image-redjpg.jpg', function(err, incorrectData) {
fs.readFile('./tests/assets/20x20-image-redpng.png', function(err, incorrectData) {
if (err) throw err;
assert.notEqual(incorrectData, body);
done();
});
});
});
});

it('should respond with a png image', function(done) {
interfake.get('/image').image('./tests/assets/20x20-image-redpng.png');
interfake.listen(3000);

request({
url: 'http://localhost:3000/image',
json: true
}, function(error, response, body) {
assert.equal(response.statusCode, 200);
assert.equal(response.headers['content-type'], 'image/png');
fs.readFile('./tests/assets/20x20-image-redpng.png', function(err, correctData) {
if (err) throw err;
assert.equal(correctData, body);
fs.readFile('./tests/assets/10x10-imagejpg.jpg', function(err, incorrectData) {
if (err) throw err;
assert.notEqual(incorrectData, body);
done();
Expand Down

0 comments on commit 31aa017

Please sign in to comment.