From 0d5bc45d18922629a6333dba1d823a49c5b9e8f1 Mon Sep 17 00:00:00 2001 From: Alissa Crane Date: Wed, 7 Aug 2024 13:09:45 -0700 Subject: [PATCH 1/6] add test yml file --- .github/workflows/test.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..c124f2b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,29 @@ +name: Kit Test +on: + push: + branches: ['main'] + pull_request: + branches: ['main'] +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Kit Install dependencies + run: npm install && npm install --prefix ./framegear + + - name: Kit Test + # When fails, please check your tests + run: npm run test:coverage From 3b7ddac8949747d0793252de3d6046cde0b922fd Mon Sep 17 00:00:00 2001 From: Alissa Crane Date: Wed, 7 Aug 2024 13:29:34 -0700 Subject: [PATCH 2/6] update yml file --- .github/workflows/test.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c124f2b..7a4bddc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,15 +15,12 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' + - name: Setup Bun + uses: oven-sh/setup-bun@v2 - - name: Kit Install dependencies - run: npm install && npm install --prefix ./framegear + - name: Template Install dependencies + run: bun install - name: Kit Test # When fails, please check your tests - run: npm run test:coverage + run: bun run test:coverage From 368a8d97441b38e012eb4835f5eabbdd04271ad1 Mon Sep 17 00:00:00 2001 From: Alissa Crane Date: Thu, 8 Aug 2024 12:42:27 -0700 Subject: [PATCH 3/6] add wallet test --- src/components/WalletWrapper.test.tsx | 38 ++++++++++++++++++++++++--- tsconfig.json | 2 +- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/components/WalletWrapper.test.tsx b/src/components/WalletWrapper.test.tsx index 3644aba..99cd0ab 100644 --- a/src/components/WalletWrapper.test.tsx +++ b/src/components/WalletWrapper.test.tsx @@ -1,10 +1,42 @@ -import { render } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import { describe, expect, it } from 'vitest'; import WalletWrapper from './WalletWrapper'; +import { http, WagmiProvider, createConfig } from 'wagmi'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { base } from 'wagmi/chains'; +import { mock } from 'wagmi/connectors'; + +const config = createConfig({ + chains: [base], + connectors: [ + mock({ + accounts: [ + '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', + '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', + '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC', + ], + }), + ], + transports: { + [base.id]: http(), + }, +}); +const queryClient = new QueryClient(); + +const renderWithProviders = (Component: React.ComponentType) => { + return render( + + + + + , + ); +}; describe('WalletWrapper', () => { it('should renders', () => { - render(); - expect(true).toBeTruthy(); + renderWithProviders(WalletWrapper); + const wallet = screen.getByTestId('ockConnectWallet_Container'); + expect(wallet).toBeInTheDocument(); }); }); diff --git a/tsconfig.json b/tsconfig.json index 672fd3a..697ba86 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "preserve", + "jsx": "react-jsx", "incremental": true, "plugins": [ { From 2ef7f2c058b11d467840cc72f9e15a3f4ec3a521 Mon Sep 17 00:00:00 2001 From: Alissa Crane Date: Thu, 8 Aug 2024 13:07:27 -0700 Subject: [PATCH 4/6] add transaction wrapper test --- src/components/TransactionWrapper.test.tsx | 42 ++++++++++++++++++++++ src/components/TransactionWrapper.tsx | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/components/TransactionWrapper.test.tsx diff --git a/src/components/TransactionWrapper.test.tsx b/src/components/TransactionWrapper.test.tsx new file mode 100644 index 0000000..b74e2bf --- /dev/null +++ b/src/components/TransactionWrapper.test.tsx @@ -0,0 +1,42 @@ +import { render, screen } from '@testing-library/react'; +import { describe, expect, it } from 'vitest'; +import TransactionWrapper from './TransactionWrapper'; +import { http, WagmiProvider, createConfig } from 'wagmi'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { base } from 'wagmi/chains'; +import { mock } from 'wagmi/connectors'; + +const config = createConfig({ + chains: [base], + connectors: [ + mock({ + accounts: [ + '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', + '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', + '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC', + ], + }), + ], + transports: { + [base.id]: http(), + }, +}); +const queryClient = new QueryClient(); + +const renderWithProviders = (component: JSX.Element) => { + return render( + + + {component} + + , + ); +}; + +describe('TransactionWrapper', () => { + it('should renders', () => { + renderWithProviders(); + const transaction = screen.getByText('Collect'); + expect(transaction).toBeInTheDocument(); + }); +}); diff --git a/src/components/TransactionWrapper.tsx b/src/components/TransactionWrapper.tsx index 61e0d4b..00e9551 100644 --- a/src/components/TransactionWrapper.tsx +++ b/src/components/TransactionWrapper.tsx @@ -19,7 +19,7 @@ import { mintReferral, quantity, tokenId, -} from 'src/constants'; +} from '../constants'; import type { Address, ContractFunctionParameters } from 'viem'; import { parseEther } from 'viem'; From b33f553c90038eae293315b3f605c569cab40aa4 Mon Sep 17 00:00:00 2001 From: Alissa Crane Date: Thu, 8 Aug 2024 13:12:30 -0700 Subject: [PATCH 5/6] fix imports --- src/components/TransactionWrapper.test.tsx | 6 +++--- src/components/WalletWrapper.test.tsx | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/TransactionWrapper.test.tsx b/src/components/TransactionWrapper.test.tsx index b74e2bf..18e1399 100644 --- a/src/components/TransactionWrapper.test.tsx +++ b/src/components/TransactionWrapper.test.tsx @@ -1,10 +1,10 @@ +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { render, screen } from '@testing-library/react'; import { describe, expect, it } from 'vitest'; -import TransactionWrapper from './TransactionWrapper'; import { http, WagmiProvider, createConfig } from 'wagmi'; -import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { base } from 'wagmi/chains'; import { mock } from 'wagmi/connectors'; +import TransactionWrapper from './TransactionWrapper'; const config = createConfig({ chains: [base], @@ -35,7 +35,7 @@ const renderWithProviders = (component: JSX.Element) => { describe('TransactionWrapper', () => { it('should renders', () => { - renderWithProviders(); + renderWithProviders(); const transaction = screen.getByText('Collect'); expect(transaction).toBeInTheDocument(); }); diff --git a/src/components/WalletWrapper.test.tsx b/src/components/WalletWrapper.test.tsx index 99cd0ab..2f51658 100644 --- a/src/components/WalletWrapper.test.tsx +++ b/src/components/WalletWrapper.test.tsx @@ -1,10 +1,10 @@ +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { render, screen } from '@testing-library/react'; import { describe, expect, it } from 'vitest'; -import WalletWrapper from './WalletWrapper'; import { http, WagmiProvider, createConfig } from 'wagmi'; -import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { base } from 'wagmi/chains'; import { mock } from 'wagmi/connectors'; +import WalletWrapper from './WalletWrapper'; const config = createConfig({ chains: [base], From 79300655f841b8733a5dc5ebc12a2c10ef7cc54a Mon Sep 17 00:00:00 2001 From: Alissa Crane Date: Thu, 8 Aug 2024 13:25:12 -0700 Subject: [PATCH 6/6] fix imports --- src/components/TransactionWrapper.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/TransactionWrapper.tsx b/src/components/TransactionWrapper.tsx index 00e9551..a83e848 100644 --- a/src/components/TransactionWrapper.tsx +++ b/src/components/TransactionWrapper.tsx @@ -10,6 +10,8 @@ import type { TransactionError, TransactionResponse, } from '@coinbase/onchainkit/transaction'; +import type { Address, ContractFunctionParameters } from 'viem'; +import { parseEther } from 'viem'; import { BASE_SEPOLIA_CHAIN_ID, collectionAddress, @@ -20,8 +22,6 @@ import { quantity, tokenId, } from '../constants'; -import type { Address, ContractFunctionParameters } from 'viem'; -import { parseEther } from 'viem'; type TransactionWrapperParams = { address: Address;