Skip to content

Commit

Permalink
feat: impl unit test for get timestamp utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Ando committed Jun 5, 2024
1 parent 6bbf7b3 commit b0095cf
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/utils_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from '../deps.ts'
import { isValidHttpUrl } from '../src/utils.ts'
import { isValidHttpUrl, getTimestamp } from '../src/utils.ts'

Deno.test('isValidHttpUrl should return true for valid HTTP URLs', () => {
assert.assertEquals(isValidHttpUrl({ url: 'http://example.com' }), true)
Expand All @@ -16,3 +16,20 @@ Deno.test('isValidHttpUrl should return false for invalid URLs', () => {
Deno.test('isValidHttpUrl should handle empty', () => {
assert.assertEquals(isValidHttpUrl({ url: '' }), false)
})

Deno.test(
'getTimestamp should return "log" timestamp format for default type',
() => {
const timestamp = getTimestamp({ type: 'log'});
assert.assert(timestamp.match(/^\d{4}-\d{2}-\d{2}$/));
}
);

Deno.test(
'getTimestamp should return "pdf" timestamp format for type "pdf"',
() => {
const timestamp = getTimestamp({ type: "pdf" });
assert.assert(timestamp.match(/^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}$/));
}
);

0 comments on commit b0095cf

Please sign in to comment.