diff --git a/package.json b/package.json index aa9f09f..81bdee4 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "lint": "prettier --check . && eslint .", "lint:prettier": "prettier --check .", "lint:eslint": "eslint .", - "format": "prettier --write ." + "format": "prettier --write .", + "prepush": "prettier --write . && prettier --check . && eslint . && vitest run" }, "devDependencies": { "@fortawesome/fontawesome-svg-core": "^6.5.2", diff --git a/src/index.test.js b/src/index.test.js deleted file mode 100644 index e07cbbd..0000000 --- a/src/index.test.js +++ /dev/null @@ -1,7 +0,0 @@ -import { describe, it, expect } from 'vitest'; - -describe('sum test', () => { - it('adds 1 + 2 to equal 3', () => { - expect(1 + 2).toBe(3); - }); -}); diff --git a/src/tests/lib/formatters.test.js b/src/tests/lib/formatters.test.js new file mode 100644 index 0000000..1b3f39f --- /dev/null +++ b/src/tests/lib/formatters.test.js @@ -0,0 +1,16 @@ +import { describe, it, expect } from 'vitest'; +import { convertUnixToTime } from '$lib/formatters'; + +describe('convertUnixToTime', () => { + it('returns a blank string when its input is null', () => { + expect(convertUnixToTime(null)).toBe(''); + }); + + it('returns a blank string when its input is an empty string', () => { + expect(convertUnixToTime('')).toBe(''); + }); + + it('converts a Unix timestamp to a locale-specific formatted time', () => { + expect(convertUnixToTime(1727442050)).toBe('01:00 PM'); + }); +});