2018-10-03 00:06:16 +02:00
|
|
|
const should = require('should');
|
|
|
|
const sinon = require('sinon');
|
|
|
|
const Promise = require('bluebird');
|
2020-03-30 16:26:47 +01:00
|
|
|
const sequence = require('../../../../core/server/lib/promise/sequence');
|
2018-10-03 00:06:16 +02:00
|
|
|
|
|
|
|
describe('Unit: lib/promise/sequence', function () {
|
|
|
|
afterEach(function () {
|
2019-01-21 17:53:44 +01:00
|
|
|
sinon.restore();
|
2018-10-03 00:06:16 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
it('mixed tasks: promise and none promise', function () {
|
|
|
|
const tasks = [
|
|
|
|
function a() {
|
|
|
|
return Promise.resolve('hello');
|
|
|
|
},
|
|
|
|
function b() {
|
|
|
|
return 'from';
|
|
|
|
},
|
|
|
|
function c() {
|
|
|
|
return Promise.resolve('chio');
|
2019-07-05 13:40:43 +02:00
|
|
|
}
|
2018-10-03 00:06:16 +02:00
|
|
|
];
|
|
|
|
return sequence(tasks)
|
|
|
|
.then(function (result) {
|
|
|
|
result.should.eql(['hello','from', 'chio']);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|