Permalink
Browse files

* allow cache hours to be a string

* add test for cache hours set with a string
  • Loading branch information...
1 parent 3d38766 commit ad7d7aa363fe0d94ec5e54db2aea2540ed804589 @b1tr0t b1tr0t committed Jan 7, 2013
Showing with 17 additions and 2 deletions.
  1. +2 −2 api/resizeImages.js
  2. +15 −0 tests/index.html
View
@@ -26,8 +26,8 @@ var $ = Mobify.$
bits.push(projectId);
}
- if (options.cacheHours && typeof(options.cacheHours) === 'number') {
- bits.push('c' + options.cacheHours)
+ if (options.cacheHours && !isNaN(parseInt(options.cacheHours)) ) {
+ bits.push('c' + parseInt(options.cacheHours))
}
if (options.format) {
View
@@ -448,6 +448,21 @@ <h2 id="qunit-userAgent"></h2>
equal(got, vow);
});
+
+ test('Mobify.getImageURL cached string', function() {
+ expect(2);
+
+ var got = Mobify.getImageURL('http://test/image.jpg')
+ , vow = '//ir0.mobify.com/http://test/image.jpg';
+
+ equal(got, vow);
+
+ got = Mobify.getImageURL('http://test/image.jpg', {maxWidth: 320,cacheHours:'8'});
+ vow = '//ir0.mobify.com/c8/320/http://test/image.jpg';
+
+ equal(got, vow);
+ });
+
test('Mobify.getImageURL - projectName set on Mobify.conf.data', function() {
expect(1);

0 comments on commit ad7d7aa

Please sign in to comment.