Skip to content

Commit

Permalink
Fix Datepicker unit test (#553)
Browse files Browse the repository at this point in the history
* fix Datepicker unit test by mocking the Date
  • Loading branch information
duranb authored Apr 3, 2023
1 parent 6575772 commit 8b4df36
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/ui/DatePicker/DatePicker.svelte.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { cleanup, fireEvent, render } from '@testing-library/svelte';
import { afterEach, describe, expect, it } from 'vitest';
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest';
import DatePicker from './DatePicker.svelte';

describe('DatePicker DatePicker Component', () => {
beforeAll(() => {
const date = new Date(2020, 1, 1, 1);
vi.useFakeTimers();
vi.setSystemTime(date);
});

afterAll(() => {
vi.setSystemTime(vi.getRealSystemTime());
vi.useRealTimers();
});

afterEach(() => {
cleanup();
});
Expand Down

0 comments on commit 8b4df36

Please sign in to comment.