More Complete Tests

This commit is contained in:
Chinmay Pandhare
2017-06-25 11:40:18 +05:30
parent ba4863c201
commit 142cf2c18b
3 changed files with 71 additions and 16 deletions

View File

@@ -141,7 +141,9 @@ ImageSequencer = function ImageSequencer(options) {
if(args.length==1) {
if (objTypeOf(args[0])=="Object") { //removeSteps(JSON)
json_q = args[0];
for (img in args[0]) {
json_q[img] = makeArray(args[0][img]);
}
}
else { //removeSteps(index) => removeSteps([image],[index])
args.splice(0,0,[]);

23
src/modules/FishEye.js Normal file
View File

@@ -0,0 +1,23 @@
/*
* Display only the green channel
*/
module.exports = function FishEye(options) {
options = options || {};
options.title = "Fish Eye";
options.description = "Corrects fish eye or barrel distortion.";
var output;
//function setup() {} // optional
function draw(input,callback) {
}
return {
options: options,
//setup: setup, // optional
draw: draw,
output: output
}
}

View File

@@ -10,20 +10,12 @@ require('../src/ImageSequencer.js');
var sequencer = ImageSequencer({ ui: "none" });
//function read (file) {
// return fs.readFileSync('./test/fixtures/' + file, 'utf8').trim();
//}
//function write (file, data) { /* jshint ignore:line */
// return fs.writeFileSync('./test/fixtures/' + file, data + '\n', 'utf8');
//}
test('Image Sequencer has tests', function (t) {
t.equal(true, true);
t.end();
});
test('loadImages loads a step', function (t){
test('loadImages loads an image and creates a step.', function (t){
sequencer.loadImages('test','examples/red.jpg');
t.equal(sequencer.images.test.steps.length, 1, "It Does!");
t.end();
@@ -65,16 +57,54 @@ test('addSteps("image","name",o) adds a step', function (t) {
t.end();
});
test('removeSteps removes a step', function (t) {
test('removeSteps("image",position) removes a step', function (t) {
sequencer.removeSteps('test',1);
t.equal(sequencer.images.test.steps.length, 6, "It Does!");
t.end();
});
test('insertStep inserts a step', function (t) {
sequencer.insertSteps('test',1,'do-nothing');
t.equal(sequencer.images.test.steps[1].options.name, "do-nothing");
t.equal(sequencer.images.test.steps.length, 7, "It Does!");
test('removeSteps({image: [positions]}) removes steps', function (t) {
sequencer.removeSteps('test',[1,2]);
t.equal(sequencer.images.test.steps.length, 4, "It Does!");
t.end();
});
test('removeSteps(position) removes steps', function (t) {
sequencer.removeSteps([1,2]);
t.equal(sequencer.images.test.steps.length, 2, "It Does!");
t.end();
});
test('insertSteps("image",position,"module",options) inserts a step', function (t) {
sequencer.insertSteps('test',1,'do-nothing',{});
t.equal(sequencer.images.test.steps[1].options.name, "do-nothing");
t.equal(sequencer.images.test.steps.length, 3, "It Does!");
t.end();
});
test('insertSteps("image",position,"module") inserts a step', function (t) {
sequencer.insertSteps('test',1,'do-nothing');
t.equal(sequencer.images.test.steps[1].options.name, "do-nothing");
t.equal(sequencer.images.test.steps.length, 4, "It Does!");
t.end();
});
test('insertSteps(position,"module") inserts a step', function (t) {
sequencer.insertSteps(1,'do-nothing');
t.equal(sequencer.images.test.steps[1].options.name, "do-nothing");
t.equal(sequencer.images.test.steps.length, 5, "It Does!");
t.end();
});
test('insertSteps({image: {index: index, name: "module", o: options} }) inserts a step', function (t) {
sequencer.insertSteps({test: {index:1, name:'do-nothing', o:{} } });
t.equal(sequencer.images.test.steps[1].options.name, "do-nothing");
t.equal(sequencer.images.test.steps.length, 6, "It Does!");
t.end();
});
test('run() runs the sequencer', function (t) {
sequencer.run();
t.equal(typeof(sequencer.images.test.steps[sequencer.images.test.steps.length - 1].output), "object", "It Does!");
t.end();
});