From da40211525fa21efb68f4333558c5d17ffe8be99 Mon Sep 17 00:00:00 2001 From: Riccardo Rigutini <47950599+richardrigutins@users.noreply.github.com> Date: Fri, 10 Nov 2023 17:46:56 +0000 Subject: [PATCH] Add max-parallelism to test workflow and add more tests for isPositiveInteger function --- .github/workflows/test-workflow.yml | 21 +++++++++++++++++++++ __tests__/utils.test.ts | 16 ++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/.github/workflows/test-workflow.yml b/.github/workflows/test-workflow.yml index 08a1d0e..60c93de 100644 --- a/.github/workflows/test-workflow.yml +++ b/.github/workflows/test-workflow.yml @@ -38,6 +38,7 @@ jobs: files: '**/*.txt' replacement-text: '1.0.2' exclude: '**/*.check.txt' + max-parallelism: '1' - name: Replace in Files - replace using special characters uses: ./ @@ -91,6 +92,26 @@ jobs: encoding: 'invalid' exclude: '**/*.check.txt' + - name: Replace in Files - error on invalid max-parallelism (invalid number) + uses: ./ + continue-on-error: true + with: + search-text: 'foo' + files: '**/*.txt' + replacement-text: 'bar' + exclude: '**/*.check.txt' + max-parallelism: '-1' + + - name: Replace in Files - error on invalid max-parallelism (invalid string) + uses: ./ + continue-on-error: true + with: + search-text: 'foo' + files: '**/*.txt' + replacement-text: 'bar' + exclude: '**/*.check.txt' + max-parallelism: 'invalid' + - name: Verify changes run: | echo " > Actual - test1.txt" diff --git a/__tests__/utils.test.ts b/__tests__/utils.test.ts index 5f9f0db..cb956eb 100644 --- a/__tests__/utils.test.ts +++ b/__tests__/utils.test.ts @@ -29,6 +29,22 @@ describe('isPositiveInteger', () => { it('should return false for non-numeric strings', () => { expect(isPositiveInteger('abc')).toBe(false); }); + + it('should return false for empty strings', () => { + expect(isPositiveInteger('')).toBe(false); + }); + + it('should return false for whitespace strings', () => { + expect(isPositiveInteger(' ')).toBe(false); + }); + + it('should return false for null', () => { + expect(isPositiveInteger(null as any)).toBe(false); + }); + + it('should return false for undefined', () => { + expect(isPositiveInteger(undefined as any)).toBe(false); + }); }); describe('isValidEncoding', () => {