Added headless browser testing

This commit is contained in:
Chinmay Pandhare
2017-07-11 18:25:33 +05:30
parent 70409d3979
commit 4c306d9e03
3 changed files with 8 additions and 10 deletions

View File

@@ -4,7 +4,7 @@
"description": "A modular JavaScript image manipulation library modeled on a storyboard.", "description": "A modular JavaScript image manipulation library modeled on a storyboard.",
"main": "dist/image-sequencer.js", "main": "dist/image-sequencer.js",
"scripts": { "scripts": {
"test": "tape test/*.js" "test": "tape test/*.js; browserify test/image-sequencer.js test/chain.js | tape-run"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@@ -39,7 +39,8 @@
"matchdep": "^0.3.0", "matchdep": "^0.3.0",
"plotly.js": "~1.21.2", "plotly.js": "~1.21.2",
"save-pixels": "~2.3.4", "save-pixels": "~2.3.4",
"tape": ">=4.7.0" "tape": ">=4.7.0",
"tape-run": "^3.0.0"
}, },
"homepage": "https://github.com/publiclab/image-sequencer" "homepage": "https://github.com/publiclab/image-sequencer"
} }

View File

@@ -9,20 +9,17 @@ require('../src/ImageSequencer.js');
var sequencer = ImageSequencer({ ui: "none" }); var sequencer = ImageSequencer({ ui: "none" });
var image = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAQABADASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAABgj/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABykX//Z"; var image = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAQABADASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAABgj/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABykX//Z";
sequencer.loadImages({images:{ sequencer.loadImages(image);
test1: image,
test2: image
}, callback:function(){}});
sequencer.addSteps("test1", ['do-nothing-pix','invert','invert']); sequencer.addSteps(['do-nothing-pix','invert','invert']);
sequencer.run(); sequencer.run();
test("Inverted image isn't identical", function (t) { test("Inverted image isn't identical", function (t) {
t.notEqual(sequencer.images.test1.steps[1].output.src, sequencer.images.test1.steps[2].output.src); t.notEqual(sequencer.images.image1.steps[1].output.src, sequencer.images.image1.steps[2].output.src);
t.end(); t.end();
}); });
test("Twice inverted image is identical to original image", function (t) { test("Twice inverted image is identical to original image", function (t) {
t.equal(sequencer.images.test1.steps[1].output.src, sequencer.images.test1.steps[3].output.src); t.equal(sequencer.images.image1.steps[1].output.src, sequencer.images.image1.steps[3].output.src);
t.end(); t.end();
}); });

View File

@@ -131,7 +131,7 @@ test('run() runs the sequencer and returns output to callback', function (t) {
}); });
test('replaceImage returns false in NodeJS', function (t) { test('replaceImage returns false in NodeJS', function (t) {
var returnvalue = sequencer.replaceImage("#selector","test"); var returnvalue = (sequencer.options.inBrowser)?false:sequencer.replaceImage("#selector","test");
t.equal(returnvalue,false); t.equal(returnvalue,false);
t.end(); t.end();
}); });