Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/__snapshots__/diffChecker.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`diffChecker coverage decreased over total treshold should match snapshot 1`] = `
exports[`diffChecker coverage decreased over total threshold should match snapshot 1`] = `
Object {
"diff": Object {
"fileA": Object {
Expand Down
4 changes: 0 additions & 4 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ export interface IConfigOptions {
/* Fail coverage check if per-file coverage is lower */
coverageThreshold?: number;
/* Fail coverage check if per-file coverage decrease is lower */
/**
* @deprecated use coverageDecreaseThreshold instead
*/
coverageDecreaseTreshold?: number;
coverageDecreaseThreshold?: number;
}

Expand Down
6 changes: 3 additions & 3 deletions src/diffChecker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ describe('diffChecker', () => {
expect(diffChecker(fileFullCovered, fileNotCovered)).toMatchSnapshot();
});
});
describe('coverage decreased over total treshold', () => {
describe('coverage decreased over total threshold', () => {
let result: IDiffCheckResults;
beforeEach(() => {
// Set coverageDecreaseThreshold to 100% so we only test coverageTreshold.
// Set coverageDecreaseThreshold to 100% so we only test coverageThreshold.
result = diffChecker(
fileFullCovered,
fileHalfCovered,
Expand Down Expand Up @@ -67,7 +67,7 @@ describe('diffChecker', () => {
});
describe('total decreased', () => {
it('should not regress', () => {
// Set coverageTreshold to 0 as we have a new file half covered.
// Set coverageThreshold to 0 as we have a new file half covered.
expect(
diffChecker(
fileFullCovered,
Expand Down
10 changes: 5 additions & 5 deletions src/diffChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const diffChecker = (
const nonZeroTest = (x: number) => x !== 0;
const coverageDecreased = (x: number) =>
x < 0 ? Math.abs(x) >= coverageDecreaseThreshold : false;
const isBelowTreshold = (x: number) => x < coverageThreshold;
const isBelowThreshold = (x: number) => x < coverageThreshold;

diffMap.forEach((v, k) => {
const diffPercentages = getSummaryPercentages(v);
Expand All @@ -40,15 +40,15 @@ export const diffChecker = (
checkCriteria,
coverageDecreased
);
const belowTreshold = checkCoverageForCondition(
const belowThreshold = checkCoverageForCondition(
head[k],
checkCriteria,
isBelowTreshold
isBelowThreshold
);

// Coverage decreased on a file or under treshold, regress.
// Coverage decreased on a file or under threshold, regress.
// Ignore the total field as we check only files.
if ((decreased || belowTreshold) && k !== 'total') {
if ((decreased || belowThreshold) && k !== 'total') {
regression = true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('diff', () => {
const mockedOptions: IConfigOptions = {
checkCriteria: ['lines'],
coverageThreshold: 100,
coverageDecreaseTreshold: 0
coverageDecreaseThreshold: 0
};

coverageDiff.diff(fileNotCovered, fileFullCovered, mockedOptions);
Expand All @@ -76,7 +76,7 @@ describe('diff', () => {
fileFullCovered,
mockedOptions.checkCriteria,
mockedOptions.coverageThreshold,
mockedOptions.coverageDecreaseTreshold
mockedOptions.coverageDecreaseThreshold
);
});
});
Expand Down
12 changes: 3 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,15 @@ export function diff(
head: IJsonSummary,
options = defaultOptions
): ICoverageDiffOutput {
const {
checkCriteria,
coverageThreshold,
coverageDecreaseThreshold,
coverageDecreaseTreshold: deprecatedCoverageDecreaseThreshold
} = options;
const { checkCriteria, coverageThreshold, coverageDecreaseThreshold } =
options;

const { regression, files, totals, diff } = diffChecker(
base,
head,
checkCriteria,
coverageThreshold,
coverageDecreaseThreshold !== undefined
? coverageDecreaseThreshold
: deprecatedCoverageDecreaseThreshold
coverageDecreaseThreshold
);

const results = resultFormatter(files, totals);
Expand Down