Skip to content

Commit

Permalink
feat: add tests for getAssetAddress (#1957)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint committed Mar 16, 2023
1 parent 896e084 commit 8cca2ad
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
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
File renamed without changes.
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);
});
});

3 comments on commit 8cca2ad

@hop-deploy
Copy link

@hop-deploy hop-deploy bot commented on 8cca2ad Mar 16, 2023

Choose a reason for hiding this comment

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

Deployment Status Build Logs Updated At
lenster ❌ Failed View Logs 2023-03-16T03:57:53.484Z

@vercel
Copy link

@vercel vercel bot commented on 8cca2ad Mar 16, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

web – ./apps/web

lenster.xyz
web-lenster.vercel.app
web-git-main-lenster.vercel.app
lenster.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 8cca2ad Mar 16, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

prerender – ./apps/prerender

prerender-git-main-lenster.vercel.app
prerender.lenster.xyz
prerender-lenster.vercel.app

Please sign in to comment.