implement basic toString() (#272)

* implement basic toString()

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* refactor

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* remove load-image from string

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* more refactor

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* doing es5 way

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* final refactor

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* refactor

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* remove if else from map

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* fix function call

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* add sequencer.steps

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* add tests for toString and stepToString

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* fix toString final

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* fix build failing

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* refactored and fix tests

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* refactor tests

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
This commit is contained in:
Varun Gupta
2018-06-01 22:15:22 +05:30
committed by Jeffrey Warren
parent be810fb9c4
commit ac183205f0
7 changed files with 90 additions and 33 deletions

View File

@@ -13,12 +13,12 @@ function copy(g, a) {
var b = {};
var i = 0;
for (var v in a)
if (g) {
if (v != "sequencer") b[v] = a[v];
}
else {
if (v != "sequencer" && v != "global1" && v != "global2" && !global1.hasOwnProperty(v)) i++;
}
if (g) {
if (v != "sequencer") b[v] = a[v];
}
else {
if (v != "sequencer" && v != "global1" && v != "global2" && !global1.hasOwnProperty(v)) i++;
}
if (g) return b;
else return i;
}
@@ -50,29 +50,29 @@ test('modulesInfo() returns info for each module', function (t) {
});
if (!sequencer.options.inBrowser)
test('loadImage loads an image from URL and creates a step. (NodeJS)', function (t) {
require('dns').resolve('www.github.com', function (err) {
if (err) {
console.log("Test aborted due to no internet");
t.end();
}
else {
sequencer.loadImage('URL', 'https://ccpandhare.github.io/image-sequencer/examples/images/red.jpg', function () {
t.equal(sequencer.images.URL.steps.length, 1, "Initial Step Created");
t.equal(typeof (sequencer.images.URL.steps[0].output.src), "string", "Initial output exists");
t.end();
});
}
test('loadImage loads an image from URL and creates a step. (NodeJS)', function (t) {
require('dns').resolve('www.github.com', function (err) {
if (err) {
console.log("Test aborted due to no internet");
t.end();
}
else {
sequencer.loadImage('URL', 'https://ccpandhare.github.io/image-sequencer/examples/images/red.jpg', function () {
t.equal(sequencer.images.URL.steps.length, 1, "Initial Step Created");
t.equal(typeof (sequencer.images.URL.steps[0].output.src), "string", "Initial output exists");
t.end();
});
});
}
});
});
if (!sequencer.options.inBrowser)
test('loadImages loads an image from PATH and creates a step. (NodeJS)', function (t) {
sequencer.loadImages('examples/images/red.jpg');
t.equal(sequencer.images.image1.steps.length, 1, "Initial Step Created");
t.equal(typeof (sequencer.images.image1.steps[0].output.src), "string", "Initial output exists");
t.end();
});
test('loadImages loads an image from PATH and creates a step. (NodeJS)', function (t) {
sequencer.loadImages('examples/images/red.jpg');
t.equal(sequencer.images.image1.steps.length, 1, "Initial Step Created");
t.equal(typeof (sequencer.images.image1.steps[0].output.src), "string", "Initial output exists");
t.end();
});
test('loadImage works too.', function (t) {
sequencer.loadImage('test2', red);
@@ -164,6 +164,7 @@ test('insertSteps({image: {index: index, name: "module", o: options} }) inserts
t.end();
});
test('run() runs the sequencer and returns output to callback', function (t) {
sequencer.run('test', function (out) {
t.equal(typeof (sequencer.images.test.steps[sequencer.images.test.steps.length - 1].output), "object", "Output is Generated");