mirror of
https://github.com/luxfi/explore.git
synced 2026-07-27 05:54:15 +00:00
* first part of transition * second part of transition * remove jest * bump up node version and playwright version * update all screenshots because of the new playwright version * fix tests * one more screenshot update
59 lines
1.3 KiB
TypeScript
59 lines
1.3 KiB
TypeScript
import type { ApiData } from './types';
|
|
|
|
import type { Route } from 'nextjs-routes';
|
|
|
|
import { describe, it, expect } from 'vitest';
|
|
|
|
import generate from './generate';
|
|
|
|
interface TestCase<Pathname extends Route['pathname']> {
|
|
title: string;
|
|
route: {
|
|
pathname: Pathname;
|
|
query?: Route['query'];
|
|
};
|
|
apiData?: ApiData<Pathname>;
|
|
}
|
|
|
|
const TEST_CASES = [
|
|
{
|
|
title: 'static route',
|
|
route: {
|
|
pathname: '/txs',
|
|
},
|
|
} as TestCase<'/txs'>,
|
|
{
|
|
title: 'dynamic route',
|
|
route: {
|
|
pathname: '/tx/[hash]',
|
|
query: { hash: '0x12345' },
|
|
},
|
|
} as TestCase<'/tx/[hash]'>,
|
|
{
|
|
title: 'dynamic route with API data',
|
|
route: {
|
|
pathname: '/token/[hash]',
|
|
query: { hash: '0x12345' },
|
|
},
|
|
apiData: {
|
|
symbol_or_name: 'USDT',
|
|
address_hash: '0x12345',
|
|
description: 'USDT is a stablecoin',
|
|
projectName: 'Tether',
|
|
icon_url: 'https://example.com/usdt.png',
|
|
exchange_rate: '1.00',
|
|
name: 'USDT',
|
|
symbol: 'USDT',
|
|
},
|
|
} as TestCase<'/token/[hash]'>,
|
|
];
|
|
|
|
describe('generates correct metadata for:', () => {
|
|
TEST_CASES.forEach((testCase) => {
|
|
it(`${ testCase.title }`, () => {
|
|
const result = generate(testCase.route, testCase.apiData);
|
|
expect(result).toMatchSnapshot();
|
|
});
|
|
});
|
|
});
|