dvb.pins(0, 0, 0, 0).then((data) => { assert.isArray(data); assert.isEmpty(data); }));
dvb.findPOI("zzz").then((data) => { assert.isEmpty(data); }));
dvb.route("0", "0").then((data) => { assert.isObject(data); assert.isUndefined(data.origin); assert.isUndefined(data.destination); assert.isEmpty(data.trips); }));
dvb.findStop("qqq").then((data) => { assert.isEmpty(data); }));
it('chain block', function () { TestFunctionRunner.clearLog(); let job = new Job(); let aBlock = job.createBlock('a'); let bBlock = job.createBlock('b'); let cBlock = job.createBlock('c'); aBlock._load({ '#is': '', 'obj1': {'#is': '', 'v': 1}, 'obj2': {'#is': '', 'v': 2}, 'obj3': {'v': 3} }); bBlock._load({ '#is': 'foreach', '~input': '##.a', 'src': { '#is': { '#is': '', 'test': {'#is': 'test-runner', '~#-log': '##.#input.v'}, 'add': {'#is': 'add', '~0': '##.#input.v', '1': 1}, '#output': {'#is': 'output', '~v': '##.add.output'} } } }); cBlock._load({ '#is': 'foreach', '~input': '##.b.output', 'src': { '#is': { '#is': '', 'multiply': {'#is': 'multiply', '~0': '##.#input.v', '1': 2}, '#output': {'#is': 'output', '~v': '##.multiply.output'} } } }); Root.run(); assert.lengthOf(TestFunctionRunner.popLogs(), 3, 'worker run 3 times'); assert.equal(bBlock.queryValue('output.obj1.v'), 2, 'basic ForEach chain'); assert.equal(cBlock.queryValue('output.obj2.v'), 6, 'basic ForEach chain'); assert.equal(cBlock.queryValue('output.obj3.v'), 8, 'basic ForEach chain on child Object'); bBlock.updateValue('src', { '#is': '', 'test': {'#is': 'test-runner', '~#-log': '##.#input.v'}, 'subtract': {'#is': 'subtract', '~0': '##.#input.v', '1': 5}, '#output': {'#is': 'output', '~v': '##.subtract.output'} }); Root.run(); assert.lengthOf(TestFunctionRunner.popLogs(), 3, 'worker run 3 times'); assert.equal(cBlock.queryValue('output.obj2.v'), -6, 'ForEach chain src changed'); assert.equal(cBlock.queryValue('output.obj3.v'), -4, 'ForEach chain src changed on child Object'); aBlock.deleteValue('obj2'); let obj4 = aBlock.createBlock('obj4'); obj4.setValue('v', 4); aBlock.updateValue('obj5', {'v': 5}); Root.run(); assert.lengthOf(TestFunctionRunner.popLogs(), 2, 'worker run twice on 2 change items'); assert.isUndefined(cBlock.queryValue('output.obj2'), 'remove object'); assert.equal(cBlock.queryValue('output.obj4.v'), -2, 'add watch child'); assert.equal(cBlock.queryValue('output.obj5.v'), 0, 'add watch child Object'); job.updateValue('b', null); aBlock.updateValue('obj6', {'v': 6}); Root.run(); assert.isUndefined(cBlock.queryValue('output'), 'output is removed when input is empty'); assert.isEmpty(TestFunctionRunner.logs, 'worker should not run after destroyed'); });