Permalink
Browse files

test for proper content-type

  • Loading branch information...
zackdever committed Aug 25, 2012
1 parent ed62904 commit 85f73c4866ff2be80f764a99d16ddb87584ee909
Showing with 13 additions and 0 deletions.
  1. +13 −0 test/retina_image_path.test.js
@@ -97,6 +97,17 @@ describe('RetinaImagePath', function() {
it('should callback with false when remote at2x image does not exist', function(done) {
XMLHttpRequest.status = 404; // simulate a failing request
+ XMLHttpRequest.contentType = 'image/png'; // simulate a proper content type
+ path = new RetinaImagePath("/images/some_image.png");
+ path.check_2x_variant(function(hasVariant) {
+ hasVariant.should.equal(false);
+ done();
+ });
+ });
+
+ it('should callback with false when content-type is not an image type', function(done) {
+ XMLHttpRequest.status = 200; // simulate a an image request that comes back OK
+ XMLHttpRequest.contentType = 'text/html'; // but is actually an improperly coded 404 page
path = new RetinaImagePath("/images/some_image.png");
path.check_2x_variant(function(hasVariant) {
hasVariant.should.equal(false);
@@ -106,6 +117,7 @@ describe('RetinaImagePath', function() {
it('should callback with true when remote at2x image exists', function(done) {
XMLHttpRequest.status = 200; // simulate a proper request
+ XMLHttpRequest.contentType = 'image/png'; // simulate a proper content type
path = new RetinaImagePath("/images/some_image.png");
path.check_2x_variant(function(hasVariant) {
hasVariant.should.equal(true);
@@ -115,6 +127,7 @@ describe('RetinaImagePath', function() {
it('should add path to cache when at2x image exists', function(done) {
XMLHttpRequest.status = 200; // simulate a proper request
+ XMLHttpRequest.contentType = 'image/png'; // simulate a proper content type
path = new RetinaImagePath("/images/some_image.png");
path.check_2x_variant(function(hasVariant) {
RetinaImagePath.confirmed_paths.should.include(path.at_2x_path);

0 comments on commit 85f73c4

Please sign in to comment.