Fixed tests

This commit is contained in:
Christoph Oberhofer
2016-05-09 08:51:22 +02:00
committed by Christoph Oberhofer
parent 12a39e28e5
commit f8bc6a705c
4 changed files with 112 additions and 31 deletions
+16 -19
View File
@@ -8,35 +8,32 @@ import Config from './config/config';
import {merge, pick, omitBy, isEmpty, omit} from 'lodash';
// scanner map
// Keep record of already created scanners for reuse?!
// TODO: Keep record of already created scanners for reuse?!
function fromImage(config, imageSrc, imageConfig) {
config =
merge({
inputStream: {
type: "ImageStream",
sequence: false,
size: 800,
src: imageSrc
},
numOfWorkers: (ENV.development && config.debug) ? 0 : 1,
locator: {
halfSample: false
}
function fromImage(config, imageSrc, inputConfig={}) {
const staticImageConfig = {
inputStream: {
type: "ImageStream",
sequence: false,
size: 800,
src: imageSrc
},
omit(config, 'inputStream'),
numOfWorkers: (ENV.development && config.debug) ? 0 : 1
};
config = merge(
config,
staticImageConfig,
{numOfWorkers: typeof config.numOfWorkers === 'number' && config.numOfWorkers > 0 ? 1 : 0},
{inputStream: omitBy(pick(config.inputStream, ['size', 'src']), isEmpty)},
{inputStream: imageConfig});
{inputStream: inputConfig});
console.log(config);
const scanner = createScanner();
return {
addEventListener: (eventType, cb) => {
scanner.decodeSingle(config, cb);
},
removeEventListener(cb) {
console.log("Remove listener");
scanner.stop();
},
toPromise() {
return new Promise((resolve, reject) => {