Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tests for getAssetAddress #1957

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
} from '@heroicons/react/outline';
import { CheckCircleIcon } from '@heroicons/react/solid';
import { formatTime } from '@lib/formatTime';
import getAssetAddress from '@lib/getAssetAddress';
import getCoingeckoPrice from '@lib/getCoingeckoPrice';
import getSignature from '@lib/getSignature';
import getTokenImage from '@lib/getTokenImage';
Expand Down Expand Up @@ -53,6 +52,7 @@ import { useAppStore } from 'src/store/app';
import { PUBLICATION } from 'src/tracking';
import formatAddress from 'utils/formatAddress';
import formatHandle from 'utils/formatHandle';
import getAssetAddress from 'utils/getAssetAddress';
import { useAccount, useBalance, useContractRead, useContractWrite, useSignTypedData } from 'wagmi';

import Splits from './Splits';
Expand Down
41 changes: 41 additions & 0 deletions tests/scripts/utils/getAssetAddress.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { expect, test } from '@playwright/test';
import { MAINNET_DEFAULT_TOKEN } from 'data/contracts';
import getAssetAddress from 'utils/getAssetAddress';

test.describe('getAssetAddress', async () => {
test('should return MAINNET_DEFAULT_TOKEN for WMATIC', async () => {
const symbol = 'WMATIC';
const result = getAssetAddress(symbol);
await expect(result).toEqual(MAINNET_DEFAULT_TOKEN);
});

test("should return '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619' for WETH", async () => {
const symbol = 'WETH';
const result = getAssetAddress(symbol);
await expect(result).toEqual('0x7ceb23fd6bc0add59e62ac25578270cff1b9f619');
});

test("should return '0x2791bca1f2de4661ed88a30c99a7a9449aa84174' for USDC", async () => {
const symbol = 'USDC';
const result = getAssetAddress(symbol);
await expect(result).toEqual('0x2791bca1f2de4661ed88a30c99a7a9449aa84174');
});

test("should return '0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063' for DAI", async () => {
const symbol = 'DAI';
const result = getAssetAddress(symbol);
await expect(result).toEqual('0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063');
});

test("should return '0xD838290e877E0188a4A44700463419ED96c16107' for NCT", async () => {
const symbol = 'NCT';
const result = getAssetAddress(symbol);
await expect(result).toEqual('0xD838290e877E0188a4A44700463419ED96c16107');
});

test('should return MAINNET_DEFAULT_TOKEN for any other symbol', async () => {
const symbol = 'FOO';
const result = getAssetAddress(symbol);
await expect(result).toEqual(MAINNET_DEFAULT_TOKEN);
});
});