Skip to content

Commit

Permalink
frontend: fix Amount component test
Browse files Browse the repository at this point in the history
  • Loading branch information
shonsirsha committed Oct 15, 2024
1 parent 052e50a commit d29fd5a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion frontends/web/src/components/amount/amount.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { useContext } from 'react';
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { Mock, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
import { render } from '@testing-library/react';
import { Amount } from './amount';
import { CoinUnit, ConversionUnit } from '@/api/account';
Expand Down Expand Up @@ -52,6 +52,20 @@ const validateSpacing = (values: string[], elements: Element[]) => {

describe('Amount formatting', () => {

beforeAll(() => {
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: (query: string) => ({
matches: false,
media: query,
onchange: null,
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
}),
});
});

beforeEach(() => {
(useContext as Mock).mockReturnValue({
hideAmounts: false,
Expand Down

0 comments on commit d29fd5a

Please sign in to comment.