Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OKendigelyan committed Oct 31, 2024
1 parent 5fac208 commit c12f939
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ beforeEach(() => {
isFirstLoad: false,
isLoading: false,
loadMore: jest.fn(),
triggerRef: { current: null },
});
store.dispatch(networksActions.setCurrent(MAINNET));
addTestAccount(store, selectedAccount);
Expand Down Expand Up @@ -300,6 +301,7 @@ describe("<AccountDrawerDisplay />", () => {
isFirstLoad: false,
isLoading: false,
loadMore: jest.fn(),
triggerRef: { current: null },
});
multisigsFixture.forEach(account => addTestAccount(store, account));
});
Expand Down
17 changes: 17 additions & 0 deletions apps/desktop/src/setupTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ import {

MockDate.set("2023-03-27T14:15:09.760Z");

const mockIntersectionObserver = class MockIntersectionObserver {
callback: jest.Mock;
options: jest.Mock;
observe: jest.Mock;
unobserve: jest.Mock;
disconnect: jest.Mock;

constructor(callback: jest.Mock, options: jest.Mock) {
this.callback = callback;
this.options = options;
this.observe = jest.fn();
this.unobserve = jest.fn();
this.disconnect = jest.fn();
}
};

jest.mock("./env", () => ({ IS_DEV: false }));

beforeEach(() => {
Expand All @@ -32,6 +48,7 @@ beforeEach(() => {
crypto: { value: webcrypto, writable: true },
TextDecoder: { value: TextDecoder, writable: true },
TextEncoder: { value: TextEncoder, writable: true },
IntersectionObserver: { value: mockIntersectionObserver, writable: true, configurable: true },
scrollTo: { value: jest.fn(), writable: true },

// taken from https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
Expand Down
21 changes: 16 additions & 5 deletions apps/web/src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,21 @@ import { mockToast } from "@umami/state";
import { mockLocalStorage } from "@umami/test-utils";
import { setupJestCanvasMock } from "jest-canvas-mock";

const intersectionObserverMock = () => ({
observe: jest.fn(),
unobserve: jest.fn(),
});
const mockIntersectionObserver = class MockIntersectionObserver {
callback: jest.Mock;
options: jest.Mock;
observe: jest.Mock;
unobserve: jest.Mock;
disconnect: jest.Mock;

constructor(callback: jest.Mock, options: jest.Mock) {
this.callback = callback;
this.options = options;
this.observe = jest.fn();
this.unobserve = jest.fn();
this.disconnect = jest.fn();
}
};

jest.mock("./env", () => ({ IS_DEV: false }));

Expand All @@ -23,7 +34,7 @@ Object.defineProperties(global, {
crypto: { value: webcrypto, writable: true },
TextDecoder: { value: TextDecoder, writable: true },
TextEncoder: { value: TextEncoder, writable: true },
IntersectionObserver: { value: intersectionObserverMock, writable: true, configurable: true },
IntersectionObserver: { value: mockIntersectionObserver, writable: true, configurable: true },
});

jest.mock("./utils/persistor", () => ({
Expand Down

1 comment on commit c12f939

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Title Lines Statements Branches Functions
apps/desktop Coverage: 84%
83.87% (1763/2102) 79.33% (837/1055) 78.42% (447/570)
apps/web Coverage: 84%
83.87% (1763/2102) 79.33% (837/1055) 78.42% (447/570)
packages/components Coverage: 97%
97.84% (182/186) 96.51% (83/86) 87.03% (47/54)
packages/core Coverage: 81%
82.22% (222/270) 71.73% (99/138) 81.96% (50/61)
packages/crypto Coverage: 100%
100% (43/43) 90.9% (10/11) 100% (7/7)
packages/data-polling Coverage: 97%
95.27% (141/148) 87.5% (21/24) 92.85% (39/42)
packages/multisig Coverage: 98%
98.47% (129/131) 85.71% (18/21) 100% (35/35)
packages/social-auth Coverage: 100%
100% (21/21) 100% (11/11) 100% (3/3)
packages/state Coverage: 85%
84.71% (798/942) 81.33% (170/209) 78.77% (297/377)
packages/tezos Coverage: 86%
85.57% (89/104) 89.47% (17/19) 82.75% (24/29)
packages/tzkt Coverage: 86%
84.05% (58/69) 81.25% (13/16) 76.92% (30/39)

Please sign in to comment.