mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
fix product schema and add fields (#3177)
This commit is contained in:
@@ -26,12 +26,14 @@ exports[`generates correct metadata for: > dynamic route with API data 1`] = `
|
||||
"name": "Tether",
|
||||
},
|
||||
"description": "USDT is a stablecoin",
|
||||
"logo": "https://example.com/usdt.png",
|
||||
"image": "https://example.com/usdt.png",
|
||||
"name": "USDT",
|
||||
"offers": {
|
||||
"@type": "Offer",
|
||||
"availability": "InStock",
|
||||
"price": "1.00",
|
||||
"priceCurrency": "USD",
|
||||
"priceValidUntil": "2024-01-02T00:00:00.000Z",
|
||||
},
|
||||
"productID": "0x12345",
|
||||
"url": "http://localhost:3000/token/0x12345",
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { ApiData } from './types';
|
||||
|
||||
import type { Route } from 'nextjs-routes';
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
|
||||
import generate from './generate';
|
||||
|
||||
@@ -49,6 +49,16 @@ const TEST_CASES = [
|
||||
];
|
||||
|
||||
describe('generates correct metadata for:', () => {
|
||||
beforeEach(() => {
|
||||
// Mock date to a fixed value: 2024-01-01T00:00:00.000Z
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date('2024-01-01T00:00:00.000Z'));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
TEST_CASES.forEach((testCase) => {
|
||||
it(`${ testCase.title }`, () => {
|
||||
const result = generate(testCase.route, testCase.apiData);
|
||||
|
||||
@@ -41,7 +41,7 @@ export default function generateProductSchema<Pathname extends Route['pathname']
|
||||
'@type': 'Product',
|
||||
name: tokenData.name || tokenData.symbol || undefined,
|
||||
description: tokenData.description || undefined,
|
||||
logo: tokenData.icon_url || undefined,
|
||||
image: tokenData.icon_url || undefined,
|
||||
url: tokenUrl,
|
||||
productID: tokenData.address_hash,
|
||||
};
|
||||
@@ -60,6 +60,8 @@ export default function generateProductSchema<Pathname extends Route['pathname']
|
||||
'@type': 'Offer',
|
||||
price: tokenData.exchange_rate,
|
||||
priceCurrency: 'USD',
|
||||
priceValidUntil: new Date(Date.now() + 1000 * 60 * 60 * 24).toISOString(),
|
||||
availability: 'InStock',
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -19,13 +19,15 @@ export interface ProductSchema {
|
||||
'@type': 'Product';
|
||||
name?: string;
|
||||
description?: string;
|
||||
logo?: string;
|
||||
image?: string;
|
||||
url?: string;
|
||||
productID?: string;
|
||||
offers?: {
|
||||
'@type': 'Offer';
|
||||
price?: string;
|
||||
priceCurrency?: string;
|
||||
priceValidUntil?: string;
|
||||
availability?: string;
|
||||
};
|
||||
brand?: {
|
||||
'@type': 'Brand';
|
||||
|
||||
Reference in New Issue
Block a user