Skip to content

Commit fc4f264

Browse files
committed
refactor: dates tests in .ts format
1 parent 0632d2b commit fc4f264

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed
Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expect, describe, it, vitest } from 'vitest';
1+
import { expect, describe, it, vitest } from "vitest";
22

33
import {
44
getDateTimeFromTimestamp,
@@ -9,13 +9,7 @@ import {
99
describe("Dates utility functions", () => {
1010
const mockWarn = vitest.fn();
1111

12-
global.console = {
13-
log: console.log,
14-
warn: mockWarn,
15-
error: console.error,
16-
info: console.info,
17-
debug: console.debug,
18-
};
12+
global.console = Object.assign({}, console, { warn: mockWarn });
1913

2014
it("formats timestamp to date and time", () => {
2115
const TIMESTAMP = "2020-07-09 18:20:14";
@@ -27,7 +21,7 @@ describe("Dates utility functions", () => {
2721
});
2822

2923
it("returns empty string for a wrong input type", () => {
30-
const TIMESTAMP = 123456789;
24+
const TIMESTAMP = 123456789 as unknown as string;
3125
const EXPECTED_RESULT = "";
3226

3327
const actualResult = getDateTimeFromTimestamp(TIMESTAMP);
@@ -45,7 +39,7 @@ describe("Dates utility functions", () => {
4539
});
4640

4741
it("returns empty string for a wrong input type (date only)", () => {
48-
const TIMESTAMP = 123456789;
42+
const TIMESTAMP = 123456789 as unknown as string;
4943
const EXPECTED_RESULT = "";
5044

5145
const actualResult = getDateFromTimestamp(TIMESTAMP);
@@ -54,7 +48,7 @@ describe("Dates utility functions", () => {
5448
});
5549

5650
it("returns empty string for a wrong input type (time only)", () => {
57-
const TIMESTAMP = 123456789;
51+
const TIMESTAMP = 123456789 as unknown as string;
5852
const EXPECTED_RESULT = "";
5953

6054
const actualResult = getTimeFromTimestamp(TIMESTAMP);

0 commit comments

Comments
 (0)