Permalink
Browse files

Added grunt-mocha task.

  • Loading branch information...
1 parent d178be6 commit 39226297f09ee55bda4898fc6b03ae1323cfb070 @blueimp committed Nov 11, 2013
Showing with 46 additions and 13 deletions.
  1. +18 −2 Gruntfile.js
  2. +1 −1 bower.json
  3. +3 −2 package.json
  4. +5 −3 test/index.html
  5. +19 −5 test/test.js
View
20 Gruntfile.js
@@ -24,9 +24,24 @@ module.exports = function (grunt) {
'js/load-image-meta.js',
'js/load-image-exif.js',
'js/load-image-exif-map.js',
- 'js/demo.js'
+ 'js/demo.js',
+ 'test/test.js'
]
},
+ mocha: {
+ all: {
+ src: ['test/index.html'],
+ options: {
+ run: true,
+ bail: true,
+ log: true,
+ reporter: 'Spec'
+ },
+ mocha: {
+ ignoreLeaks: false
+ }
+ }
+ },
uglify: {
production: {
src: [
@@ -43,10 +58,11 @@ module.exports = function (grunt) {
});
grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('grunt-mocha');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-bump-build-git');
- grunt.registerTask('test', ['jshint']);
+ grunt.registerTask('test', ['jshint', 'mocha']);
grunt.registerTask('default', ['test', 'uglify']);
};
View
2 bower.json
@@ -1,6 +1,6 @@
{
"name": "blueimp-load-image",
- "version": "1.10.0",
+ "version": "1.11.0",
"title": "JavaScript Load Image",
"description": "JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled and/or cropped HTML img or canvas element. It also provides a method to parse image meta data to extract Exif tags and thumbnails and to restore the complete image header after resizing.",
"keywords": [
View
5 package.json
@@ -1,6 +1,6 @@
{
"name": "blueimp-load-image",
- "version": "1.10.0",
+ "version": "1.11.0",
"title": "JavaScript Load Image",
"description": "JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled and/or cropped HTML img or canvas element. It also provides a method to parse image meta data to extract Exif tags and thumbnails and to restore the complete image header after resizing.",
"keywords": [
@@ -46,6 +46,7 @@
"grunt": "~0.4.1",
"grunt-contrib-uglify": "~0.2.7",
"grunt-contrib-jshint": "~0.7.1",
- "grunt-bump-build-git": "~1.0.0"
+ "grunt-bump-build-git": "~1.0.0",
+ "grunt-mocha": "~0.4.1"
}
}
View
8 test/index.html
@@ -1,7 +1,7 @@
<!DOCTYPE HTML>
<!--
/*
- * JavaScript Load Image Test 1.9.0
+ * JavaScript Load Image Test 1.11.0
* https://github.com/blueimp/JavaScript-Load-Image
*
* Copyright 2011, Sebastian Tschan
@@ -37,8 +37,10 @@
<script src="../js/load-image-exif-map.js"></script>
<script src="test.js"></script>
<script>
-mocha.checkLeaks();
-mocha.run();
+if (!window.PHANTOMJS) {
+ mocha.checkLeaks();
+ mocha.run();
+}
</script>
</body>
</html>
View
24 test/test.js
@@ -1,5 +1,5 @@
/*
- * JavaScript Load Image Test 1.9.0
+ * JavaScript Load Image Test 1.11.0
* https://github.com/blueimp/JavaScript-Load-Image
*
* Copyright 2011, Sebastian Tschan
@@ -41,7 +41,18 @@
'srO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8v' +
'P09fb3+Pn6/9oADAMBAAIRAxEAPwD+/iiiigD/2Q==',
imageUrlJPEG = 'data:image/jpeg;base64,' + b64DataJPEG,
- blobJPEG = canCreateBlob && window.dataURLtoBlob(imageUrlJPEG);
+ blobJPEG = canCreateBlob && window.dataURLtoBlob(imageUrlJPEG),
+ createBlob = function (data, type) {
+ try {
+ return new Blob([data], {type: type});
+ } catch (e) {
+ var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder ||
+ window.MozBlobBuilder || window.MSBlobBuilder,
+ builder = new BlobBuilder();
+ builder.append(data.buffer || data);
+ return builder.getBlob(type);
+ }
+ };
describe('Loading', function () {
@@ -92,8 +103,11 @@
expect(loadImage(blobGIF, function (img) {
loadImage(img.src, function (img2) {
done();
- expect(img2).to.be.a(window.Event);
- expect(img2.type).to.be('error');
+ if (!window.PHANTOMJS) {
+ // revokeObjectUrl doesn't seem to have an effect in PhantomJS
+ expect(img2).to.be.a(window.Event);
+ expect(img2.type).to.be('error');
+ }
});
})).to.be.ok();
});
@@ -397,7 +411,7 @@
loadImage.parseMetaData(blobJPEG, function (data) {
expect(data.imageHead).to.be.ok();
loadImage.parseMetaData(
- new Blob([data.imageHead], {type: 'image/jpeg'}),
+ createBlob(data.imageHead, 'image/jpeg'),
function (data) {
done();
expect(data.exif).to.be.ok();

0 comments on commit 3922629

Please sign in to comment.