Skip to content

Commit

Permalink
Adds our first 'real' unit tests
Browse files Browse the repository at this point in the history
Fixes #141
  • Loading branch information
aaronbrethorst committed Nov 25, 2024
1 parent f28ab06 commit 13267ef
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 0 additions & 7 deletions src/index.test.js

This file was deleted.

16 changes: 16 additions & 0 deletions src/tests/lib/formatters.test.js
Original file line number Diff line number Diff line change
@@ -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');
});
});

0 comments on commit 13267ef

Please sign in to comment.