diff --git a/.github/workflows/lint-pr.yml b/.github/workflows/lint-pr.yml index f025feb..2e42165 100644 --- a/.github/workflows/lint-pr.yml +++ b/.github/workflows/lint-pr.yml @@ -6,6 +6,6 @@ on: jobs: build: - uses: unosquare/bump-npm-version/.github/workflows/lint.yml@master + uses: unosquare/bump-npm-version/.github/workflows/lint-pnpm.yml@master secrets: - github-token: ${{ secrets.GPR_ACCESS_TOKEN }} \ No newline at end of file + github-token: ${{ secrets.GPR_ACCESS_TOKEN }} diff --git a/src/delta.ts b/src/delta.ts index 1f0490c..aa1e7b4 100644 --- a/src/delta.ts +++ b/src/delta.ts @@ -17,7 +17,7 @@ export const calculateDeltaValue = (current?: number, previous?: number) => { export const calculateDeltaPercent = (current?: number, previous?: number) => { if (!current || !previous) return null; - return ((current - previous) / current) * 100; + return ((current - previous) / previous) * 100; }; export const calculateDelta = (current?: number, previous?: number) => { diff --git a/test/delta.spec.ts b/test/delta.spec.ts index 8524644..b9efe35 100644 --- a/test/delta.spec.ts +++ b/test/delta.spec.ts @@ -4,13 +4,13 @@ describe('calculateDelta', () => { it('should return delta, deltaPercent, and deltaString', () => { const [delta, deltaPercent, deltaString] = calculateDelta(10, 5); expect(delta).toBe(5); - expect(deltaPercent).toBe(50); + expect(deltaPercent).toBe(100); expect(deltaString).toBe('increase'); }); it('should return delta, deltaPercent, and deltaString', () => { const [delta, deltaPercent, deltaString] = calculateDelta(5, 10); expect(delta).toBe(-5); - expect(deltaPercent).toBe(-100); + expect(deltaPercent).toBe(-50); expect(deltaString).toBe('decrease'); }); it('should return delta, deltaPercent, and deltaString', () => {