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
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,17 @@ jobs:
- run: yarn lint
- run: yarn build
- run: yarn jest

- name: Code Coverage Summary Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage/cobertura-coverage.xml
format: markdown
output: both

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### dependabot: \#49 Bump cross-spawn from 7.0.3 to 7.0.6

### Added

- Code coverage with 100% threshold

## [1.2.0] - 2025-01-13

### Added
Expand Down
10 changes: 10 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,14 @@ module.exports = {
testEnvironment: "node",
resetMocks: false,
setupFiles: ["jest-localstorage-mock"],
collectCoverage: true,
coverageReporters: ["text", "html", "cobertura"],
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
};
9 changes: 9 additions & 0 deletions src/lib/localStorage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ describe("localStorage tests", () => {
jest.clearAllMocks();
});

test("localStorage not supported", () => {
const { localStorage } = global;
delete (global as Partial<typeof global>).localStorage;
expect(() => {
getLocalStorageItem("test");
}).toThrow("localStorage not supported");
global.localStorage = localStorage;
});

test("getLocalStorageItem not existing", () => {
expect(getLocalStorageItem("test")).toBeUndefined();
});
Expand Down
5 changes: 5 additions & 0 deletions src/lib/object.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ describe("object tests", () => {
});

test.each([
// Invalid objects
[null as unknown as object, null],
[undefined as unknown as object, undefined],

// Valid objects
[{}, {}],
[{ hello: "world" }, { hello: "world" }],
[{ hello: null }, {}],
Expand Down
2 changes: 1 addition & 1 deletion src/lib/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function isNullOrEmpty(value?: string): boolean {
* @returns true if the value parameter is null/undefined, Empty, or if value consists exclusively of white-space characters
*/
export function isNullOrWhitespace(value?: string): boolean {
return isNullOrEmpty(value) || (value ?? "").trim().length === 0;
return isNullOrEmpty(value) || (value as string).trim().length === 0;
}

/**
Expand Down