Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deuch13 committed May 15, 2024
1 parent 1e378b5 commit 6960147
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14,432 deletions.
21 changes: 5 additions & 16 deletions explorer/src/lib/components/__tests__/BlocksCard.spec.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { afterAll, afterEach, describe, expect, it, vi } from "vitest";
import { cleanup, fireEvent, render } from "@testing-library/svelte";
import { cleanup, render } from "@testing-library/svelte";
import { apiBlocks } from "$lib/mock-data";
import { transformBlock } from "$lib/chain-info";
import { BlocksCard } from "..";
import { mapWith } from "lamb";
import { compose, mapWith, take } from "lamb";

global.ResizeObserver = vi.fn().mockImplementation(() => ({
disconnect: vi.fn(),
observe: vi.fn(),
unobserve: vi.fn(),
}));

const transformBlocks = mapWith(transformBlock);
const data = transformBlocks(apiBlocks.data.blocks);
const getTenBlocks = compose(mapWith(transformBlock), take(10));
const data = getTenBlocks(apiBlocks.data.blocks);

describe("Blocks Card", () => {
vi.useFakeTimers();
Expand Down Expand Up @@ -61,18 +61,7 @@ describe("Blocks Card", () => {
props: { ...baseProps, blocks, loading },
});

const button = getByRole("button");

const showMoreIncrement = 15;

const clicks = Math.ceil(data.length / showMoreIncrement) - 1;

//eslint-disable-next-line
for (const _ of Array.from({ length: clicks })) {
await fireEvent.click(button);
}

expect(button).toBeDisabled();
expect(getByRole("button")).toBeDisabled();

expect(container.firstChild).toMatchSnapshot();
});
Expand Down
21 changes: 5 additions & 16 deletions explorer/src/lib/components/__tests__/TransactionsCard.spec.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { afterAll, afterEach, describe, expect, it, vi } from "vitest";
import { cleanup, fireEvent, render } from "@testing-library/svelte";
import { cleanup, render } from "@testing-library/svelte";
import { apiTransactions } from "$lib/mock-data";
import { transformTransaction } from "$lib/chain-info";
import { TransactionsCard } from "..";
import { mapWith } from "lamb";
import { compose, mapWith, take } from "lamb";

global.ResizeObserver = vi.fn().mockImplementation(() => ({
disconnect: vi.fn(),
observe: vi.fn(),
unobserve: vi.fn(),
}));

const transformTransactions = mapWith(transformTransaction);
const data = transformTransactions(apiTransactions.data);
const getTenTransactions = compose(mapWith(transformTransaction), take(10));
const data = getTenTransactions(apiTransactions.data);

describe("Transactions Card", () => {
vi.useFakeTimers();
Expand Down Expand Up @@ -61,18 +61,7 @@ describe("Transactions Card", () => {
props: { ...baseProps, loading, txs },
});

const button = getByRole("button");

const showMoreIncrement = 15;

const clicks = Math.ceil(data.length / showMoreIncrement) - 1;

//eslint-disable-next-line
for (const _ of Array.from({ length: clicks })) {
await fireEvent.click(button);
}

expect(button).toBeDisabled();
expect(getByRole("button")).toBeDisabled();

expect(container.firstChild).toMatchSnapshot();
});
Expand Down
Loading

0 comments on commit 6960147

Please sign in to comment.