Skip to content

Commit

Permalink
refactor(core): fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vetalcore committed Nov 26, 2024
1 parent 38eb384 commit 51a0f58
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('Testing AssetActivityItem component', () => {
const { findByTestId } = render(<AssetActivityItem {...props} />);

const activityAmount = await findByTestId(assetsAmountTestId);
const tickerText = `-${props.amount}, ${props.assets[0].val} ${props.assets[0].info.ticker}`;
const tickerText = `-${props.amount}, ${props.assets?.[0].val} ${props.assets?.[0].info?.ticker}`;
const activityAssetTickerText = await within(activityAmount).findByText(tickerText);

expect(activityAssetTickerText).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ describe('Password', () => {
(input as HTMLInputElement).value = 'admin123';
expect(input).toHaveProperty('type', 'password');
act(() => {
fireEvent.click(queryByTestId('password-input-show-icon'));
const icon = queryByTestId('password-input-show-icon');
icon && fireEvent.click(icon);
});
expect(input).toHaveProperty('type', 'text');
expect(input).toHaveValue('admin123');
Expand All @@ -36,11 +37,13 @@ describe('Password', () => {
(input as HTMLInputElement).value = 'admin123';
expect(input).toHaveProperty('type', 'password');
act(() => {
fireEvent.click(queryByTestId('password-input-show-icon'));
const icon = queryByTestId('password-input-show-icon');
icon && fireEvent.click(icon);
});
expect(input).toHaveProperty('type', 'text');
act(() => {
fireEvent.click(queryByTestId('password-input-hide-icon'));
const icon = queryByTestId('password-input-hide-icon');
icon && fireEvent.click(icon);
});
expect(input).toHaveProperty('type', 'password');
});
Expand Down
26 changes: 26 additions & 0 deletions packages/core/test/__mocks__/set-env-vars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
process.env.CARDANO_SERVICES_URL_PREVIEW = 'https://preview-prod.com';
process.env.CARDANO_SERVICES_URL_PREPROD = 'https://preprod-prod.com';
process.env.CARDANO_SERVICES_URL_MAINNET = 'https://mainnet-url.com';
process.env.CARDANO_SERVICES_URL_SANCHONET = 'https://sanchonet-url.com';
process.env.BLOCKFROST_URL_MAINNET = 'https://cardano-mainnet.blockfrost.io';
process.env.BLOCKFROST_URL_PREPROD = 'https://cardano-preprod.blockfrost.io';
process.env.BLOCKFROST_URL_PREVIEW = 'https://cardano-preview.blockfrost.io';
process.env.BLOCKFROST_URL_SANCHONET = 'https://cardano-sanchonet.blockfrost.io';
process.env.BLOCKFROST_PROJECT_ID_MAINNET = 'mainnetprojectid';
process.env.BLOCKFROST_PROJECT_ID_PREPROD = 'preprodprojectid';
process.env.BLOCKFROST_PROJECT_ID_PREVIEW = 'previewprojectid';
process.env.BLOCKFROST_PROJECT_ID_SANCHONET = 'sanchonet...TODO';
process.env.AVAILABLE_CHAINS = 'Preprod,Preview,Mainnet,Sanchonet';
process.env.CEXPLORER_URL_MAINNET = 'https://cexplorer.io';
process.env.CEXPLORER_URL_PREVIEW = 'https://preview.cexplorer.io';
process.env.CEXPLORER_URL_PREPROD = 'https://preprod.cexplorer.io';
process.env.CEXPLORER_URL_SANCHONET = 'https://sanchonet.cexplorer.io';
process.env.USE_HIDE_MY_BALANCE = 'true';
process.env.USE_POSTHOG_ANALYTICS = 'true';
process.env.USE_POSTHOG_ANALYTICS_FOR_OPTED_OUT = 'false';
process.env.POSTHOG_HOST = 'https://e.lw.iog.io';
process.env.POSTHOG_DEV_TOKEN = 'test-token';
process.env.MIN_NUMBER_OF_COSIGNERS = '2';
process.env.TWITTER_URL = 'TWITTER_URL';
process.env.YOUTUBE_URL = 'YOUTUBE_URL';
process.env.DISCORD_URL = 'DISCORD_URL';
1 change: 1 addition & 0 deletions packages/core/test/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ module.exports = createJestConfig({
roots: ['<rootDir>/src'],
testTimeout: 60000,
testEnvironment: 'jsdom',
setupFiles: ['<rootDir>/test/__mocks__/set-env-vars.js'],
setupFilesAfterEnv: ['./test/jest.setup.js', 'jest-canvas-mock']
});

0 comments on commit 51a0f58

Please sign in to comment.