Skip to content

Commit

Permalink
update provider test
Browse files Browse the repository at this point in the history
  • Loading branch information
claireolmstead committed Jan 17, 2024
1 parent 6da4528 commit 0a92bcc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { screen } from '@testing-library/svelte';

// Helper function to get text that is broken up into multiple elements (->stackExchange)
export const getByTextContent = (text: string) => {
console.log('TEXT', text);
// Passing custom matcher function to `getByText`
return screen.getByText((_content, element) => {
const hasText = (element) => element.textContent === text;
Expand Down
20 changes: 10 additions & 10 deletions test/unit-and-integration/provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '../../src/lib/stores';
import Provider from '$components/Provider.svelte';
import { ActionForms } from '../../src/lib/storeTypes';
import { getByTextContent } from "../helpers";
import { getByTextContent } from '../helpers';

const mocks = vi.hoisted(() => {
class TestCodec {
Expand Down Expand Up @@ -124,9 +124,9 @@ describe('Provider.svelte', () => {
render(Provider);

await waitFor(() => {
expect(getByTextContent('Transferable: 1.0000 micro FLARP')).toBeInTheDocument();
expect(getByTextContent('Locked: 50.0000 nano FLARP')).toBeInTheDocument();
expect(getByTextContent('Total Balance: 1.5000 micro FLARP')).toBeInTheDocument();
expect(getByTextContent('Transferable 1.0000 micro FLARP')).toBeInTheDocument();
expect(getByTextContent('Locked 50.0000 nano FLARP')).toBeInTheDocument();
expect(getByTextContent('Total Balance 1.5000 micro FLARP')).toBeInTheDocument();
});
});
});
Expand All @@ -150,12 +150,12 @@ describe('Provider.svelte', () => {
await dotApi.update((val) => (val = { ...val, api: createdApi }));
render(Provider);

expect(getByTextContent('Transferable: 0')).toBeInTheDocument();
expect(getByTextContent('Transferable 0')).toBeInTheDocument();
await waitFor(() => {
// these values are from the mocks
expect(getByTextContent('Total Balance: 1.5000 micro FLARP')).toBeInTheDocument();
expect(getByTextContent('Transferable: 1.0000 micro FLARP')).toBeInTheDocument();
expect(getByTextContent('Locked: 50.0000 nano FLARP')).toBeInTheDocument();
expect(getByTextContent('Total Balance 1.5000 micro FLARP')).toBeInTheDocument();
expect(getByTextContent('Transferable 1.0000 micro FLARP')).toBeInTheDocument();
expect(getByTextContent('Locked 50.0000 nano FLARP')).toBeInTheDocument();
});
});
});
Expand All @@ -167,8 +167,8 @@ describe('Provider.svelte', () => {

it('Shows Provider Id and name', () => {
render(Provider);
expect(getByTextContent('Id: 11')).toBeInTheDocument();
expect(getByTextContent('Name: Bobbay')).toBeInTheDocument();
expect(getByTextContent('Id 11')).toBeInTheDocument();
expect(getByTextContent('Name Bobbay')).toBeInTheDocument();
});
});
});
Expand Down

0 comments on commit 0a92bcc

Please sign in to comment.