Moved fn skipping policy out of QueueRunner

This should allow us to more easily support complex skipping strategies
like skipping nested cleanup fns when the corresponding befores were
skipped, or skipping specs and suites when a beforeAll fails.

* #1533
This commit is contained in:
Steve Gravrock
2021-09-29 12:14:07 -07:00
parent 457a2727ba
commit 5eaeeb0b6c
8 changed files with 228 additions and 57 deletions

View File

@@ -0,0 +1,45 @@
describe('CompleteOnFirstErrorSkipPolicy', function() {
describe('#skipTo', function() {
describe('When errored is false', function() {
it('returns the next index', function() {
const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy(
arrayOfArbitraryFns(4),
4
);
expect(policy.skipTo(1, false)).toEqual(2);
});
});
describe('When errored is true', function() {
it('returns the first cleanup fn when called with a non cleanup fn', function() {
const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy(
arrayOfArbitraryFns(4),
2
);
expect(policy.skipTo(0, true)).toEqual(2);
expect(policy.skipTo(1, true)).toEqual(2);
});
it('returns the next index when called with a cleanup fn', function() {
const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy(
arrayOfArbitraryFns(4),
1
);
expect(policy.skipTo(1, true)).toEqual(2);
expect(policy.skipTo(2, true)).toEqual(3);
});
});
});
});
function arrayOfArbitraryFns(n) {
const result = [];
for (let i = 0; i < n; i++) {
result.push({ fn: () => {} });
}
return result;
}