Phase 1 Completion

This commit is contained in:
Chinmay Pandhare
2017-06-14 08:20:01 +05:30
parent 95e066fdc7
commit ec2790652c
13 changed files with 344 additions and 352 deletions

View File

@@ -3,12 +3,12 @@
var fs = require('fs');
var test = require('tape');
// We should only test headless code here.
// http://stackoverflow.com/questions/21358015/error-jquery-requires-a-window-with-a-document#25622933
// We should only test headless code here.
// http://stackoverflow.com/questions/21358015/error-jquery-requires-a-window-with-a-document#25622933
require('../dist/image-sequencer.js');
require('../src/ImageSequencerNode.js');
var sequencer = ImageSequencer({ ui: false });
var sequencer = ImageSequencer({ ui: "none" });
//function read (file) {
// return fs.readFileSync('./test/fixtures/' + file, 'utf8').trim();
@@ -19,38 +19,41 @@ var sequencer = ImageSequencer({ ui: false });
//}
test('Image Sequencer has tests', function (t) {
// read('something.html')
t.equal(true, true);
t.end();
});
test('loadImages loads a step', function (t){
sequencer.loadImages('test','examples/SundarPichai.jpeg');
t.equal(sequencer.images.test.steps.length, 1, "It Does!");
t.end();
});
test('addStep adds a step', function (t) {
t.equal(sequencer.steps.length, 0);
sequencer.addStep('ndvi-red');
t.equal(sequencer.steps.length, 1);
sequencer.addSteps('test','do-nothing');
t.equal(sequencer.images.test.steps[1].options.name, "do-nothing");
t.equal(sequencer.images.test.steps.length, 2, "It Does!")
t.end();
});
test('each module conforms to base API except image-select', function (t) {
Object.keys(sequencer.modules).forEach(function(moduleName, i) {
if (moduleName != "image-select") sequencer.addStep(moduleName);
});
// should already have image-select:
t.equal(sequencer.steps.length, Object.keys(sequencer.modules).length);
sequencer.steps.forEach(function(step, i) {
//t.equal(step.test(step.testInput),step.testOutput);
// or check that it's equal with a diff method?
// we could also test each type of output
t.equal(step.setup === 'undefined', false);
t.equal(step.draw === 'undefined', false);
});
test('removeSteps removes a step', function (t) {
sequencer.removeSteps('test',1);
t.equal(sequencer.images.test.steps.length, 1, "It Does!");
t.end();
});
//test('a blank module does not modify an image, according to diff', function (t) {
//});
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, 2, "It Does!");
t.end();
});
//test('a module modifies an image', function (t) {
//});
test('run creates output of steps', function (t) {
sequencer.run();
var steps = sequencer.images.test.steps
var type = typeof(steps[steps.length-1].output)
t.equal(type,"object");
t.end();
});