Files
jasmine/spec/core/CompleteOnFirstErrorSkipPolicySpec.js
Steve Gravrock 5eaeeb0b6c 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
2021-10-06 08:55:01 -07:00

46 lines
1.2 KiB
JavaScript

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;
}