Convreted TreeProcessor to async/await
This commit is contained in:
@@ -8518,10 +8518,8 @@ getJasmineRequireObj().Runner = function(j$) {
|
||||
});
|
||||
|
||||
this.currentlyExecutingSuites_.push(this.topSuite_);
|
||||
await processor.execute();
|
||||
|
||||
return new Promise(resolve => {
|
||||
processor.execute(() => {
|
||||
(async () => {
|
||||
if (this.topSuite_.hadBeforeAllFailure) {
|
||||
await this.reportChildrenOfBeforeAllFailure_(this.topSuite_);
|
||||
}
|
||||
@@ -8566,10 +8564,7 @@ getJasmineRequireObj().Runner = function(j$) {
|
||||
};
|
||||
this.topSuite_.reportedDone = true;
|
||||
await this.reporter_.jasmineDone(jasmineDoneInfo);
|
||||
resolve(jasmineDoneInfo);
|
||||
})();
|
||||
});
|
||||
});
|
||||
return jasmineDoneInfo;
|
||||
}
|
||||
|
||||
reportSuiteDone_(suite, result, next) {
|
||||
@@ -10190,7 +10185,7 @@ getJasmineRequireObj().TreeProcessor = function() {
|
||||
return stats;
|
||||
};
|
||||
|
||||
this.execute = function(done) {
|
||||
this.execute = async function() {
|
||||
if (!processed) {
|
||||
this.processTree();
|
||||
}
|
||||
@@ -10201,17 +10196,19 @@ getJasmineRequireObj().TreeProcessor = function() {
|
||||
|
||||
const childFns = wrapChildren(tree, 0);
|
||||
|
||||
await new Promise(function(resolve) {
|
||||
queueRunnerFactory({
|
||||
queueableFns: childFns,
|
||||
userContext: tree.sharedUserContext(),
|
||||
onException: function() {
|
||||
tree.handleException.apply(tree, arguments);
|
||||
},
|
||||
onComplete: done,
|
||||
onComplete: resolve,
|
||||
onMultipleDone: tree.onMultipleDone
|
||||
? tree.onMultipleDone.bind(tree)
|
||||
: null
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function runnableIndex(id) {
|
||||
|
||||
@@ -274,7 +274,7 @@ describe('TreeProcessor', function() {
|
||||
expect(result.valid).toBe(true);
|
||||
});
|
||||
|
||||
it('runs a single leaf', function() {
|
||||
it('runs a single leaf', async function() {
|
||||
const leaf = new Leaf(),
|
||||
node = new Node({ children: [leaf], userContext: { root: 'context' } }),
|
||||
queueRunner = jasmine.createSpy('queueRunner'),
|
||||
@@ -282,25 +282,27 @@ describe('TreeProcessor', function() {
|
||||
tree: node,
|
||||
runnableIds: [leaf.id],
|
||||
queueRunnerFactory: queueRunner
|
||||
}),
|
||||
treeComplete = jasmine.createSpy('treeComplete');
|
||||
});
|
||||
|
||||
processor.execute(treeComplete);
|
||||
const promise = processor.execute();
|
||||
|
||||
expect(queueRunner).toHaveBeenCalledWith({
|
||||
onComplete: treeComplete,
|
||||
onComplete: jasmine.any(Function),
|
||||
onException: jasmine.any(Function),
|
||||
userContext: { root: 'context' },
|
||||
queueableFns: [{ fn: jasmine.any(Function) }],
|
||||
onMultipleDone: null
|
||||
});
|
||||
|
||||
queueRunner.calls.mostRecent().args[0].queueableFns[0].fn('foo');
|
||||
|
||||
const queueRunnerArgs = queueRunner.calls.mostRecent().args[0];
|
||||
queueRunnerArgs.queueableFns[0].fn('foo');
|
||||
expect(leaf.execute).toHaveBeenCalledWith(queueRunner, 'foo', false, false);
|
||||
|
||||
queueRunnerArgs.onComplete();
|
||||
await expectAsync(promise).toBeResolvedTo(undefined);
|
||||
});
|
||||
|
||||
it('runs a node with no children', function() {
|
||||
it('runs a node with no children', async function() {
|
||||
const node = new Node({ userContext: { node: 'context' } }),
|
||||
root = new Node({ children: [node], userContext: { root: 'context' } }),
|
||||
nodeStart = jasmine.createSpy('nodeStart'),
|
||||
@@ -313,21 +315,20 @@ describe('TreeProcessor', function() {
|
||||
nodeComplete: nodeComplete,
|
||||
queueRunnerFactory: queueRunner
|
||||
}),
|
||||
treeComplete = jasmine.createSpy('treeComplete'),
|
||||
nodeDone = jasmine.createSpy('nodeDone');
|
||||
|
||||
processor.execute(treeComplete);
|
||||
const promise = processor.execute();
|
||||
|
||||
expect(queueRunner).toHaveBeenCalledWith({
|
||||
onComplete: treeComplete,
|
||||
onComplete: jasmine.any(Function),
|
||||
onException: jasmine.any(Function),
|
||||
userContext: { root: 'context' },
|
||||
queueableFns: [{ fn: jasmine.any(Function) }],
|
||||
onMultipleDone: null
|
||||
});
|
||||
|
||||
queueRunner.calls.mostRecent().args[0].queueableFns[0].fn(nodeDone);
|
||||
|
||||
const queueRunnerArgs = queueRunner.calls.mostRecent().args[0];
|
||||
queueRunnerArgs.queueableFns[0].fn(nodeDone);
|
||||
expect(queueRunner).toHaveBeenCalledWith({
|
||||
onComplete: jasmine.any(Function),
|
||||
onMultipleDone: null,
|
||||
@@ -348,6 +349,9 @@ describe('TreeProcessor', function() {
|
||||
{ my: 'result' },
|
||||
jasmine.any(Function)
|
||||
);
|
||||
|
||||
queueRunnerArgs.onComplete();
|
||||
await expectAsync(promise).toBeResolvedTo(undefined);
|
||||
});
|
||||
|
||||
it('runs a node with children', function() {
|
||||
|
||||
@@ -136,10 +136,8 @@ getJasmineRequireObj().Runner = function(j$) {
|
||||
});
|
||||
|
||||
this.currentlyExecutingSuites_.push(this.topSuite_);
|
||||
await processor.execute();
|
||||
|
||||
return new Promise(resolve => {
|
||||
processor.execute(() => {
|
||||
(async () => {
|
||||
if (this.topSuite_.hadBeforeAllFailure) {
|
||||
await this.reportChildrenOfBeforeAllFailure_(this.topSuite_);
|
||||
}
|
||||
@@ -184,10 +182,7 @@ getJasmineRequireObj().Runner = function(j$) {
|
||||
};
|
||||
this.topSuite_.reportedDone = true;
|
||||
await this.reporter_.jasmineDone(jasmineDoneInfo);
|
||||
resolve(jasmineDoneInfo);
|
||||
})();
|
||||
});
|
||||
});
|
||||
return jasmineDoneInfo;
|
||||
}
|
||||
|
||||
reportSuiteDone_(suite, result, next) {
|
||||
|
||||
@@ -27,7 +27,7 @@ getJasmineRequireObj().TreeProcessor = function() {
|
||||
return stats;
|
||||
};
|
||||
|
||||
this.execute = function(done) {
|
||||
this.execute = async function() {
|
||||
if (!processed) {
|
||||
this.processTree();
|
||||
}
|
||||
@@ -38,17 +38,19 @@ getJasmineRequireObj().TreeProcessor = function() {
|
||||
|
||||
const childFns = wrapChildren(tree, 0);
|
||||
|
||||
await new Promise(function(resolve) {
|
||||
queueRunnerFactory({
|
||||
queueableFns: childFns,
|
||||
userContext: tree.sharedUserContext(),
|
||||
onException: function() {
|
||||
tree.handleException.apply(tree, arguments);
|
||||
},
|
||||
onComplete: done,
|
||||
onComplete: resolve,
|
||||
onMultipleDone: tree.onMultipleDone
|
||||
? tree.onMultipleDone.bind(tree)
|
||||
: null
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function runnableIndex(id) {
|
||||
|
||||
Reference in New Issue
Block a user