feat: extend Product with featured/featuredOrder
This commit is contained in:
@@ -20,6 +20,8 @@ const ROW = {
|
||||
image: 'products/edge-control.jpg',
|
||||
description: 'Tenue longue durée.',
|
||||
in_stock: true,
|
||||
featured: true,
|
||||
featured_order: 0,
|
||||
}
|
||||
|
||||
import { fetchProducts, getProductsByCategory, type Product } from './products'
|
||||
@@ -49,6 +51,8 @@ describe('fetchProducts', () => {
|
||||
image: 'https://cdn.example/products/edge-control.jpg',
|
||||
description: 'Tenue longue durée.',
|
||||
inStock: true,
|
||||
featured: true,
|
||||
featuredOrder: 0,
|
||||
},
|
||||
])
|
||||
})
|
||||
@@ -61,8 +65,8 @@ describe('fetchProducts', () => {
|
||||
|
||||
describe('getProductsByCategory', () => {
|
||||
const products: Product[] = [
|
||||
{ id: 'a', name: 'A', category: 'hair-care', price: 1, image: '', description: '', inStock: true },
|
||||
{ id: 'b', name: 'B', category: 'tools', price: 1, image: '', description: '', inStock: true },
|
||||
{ id: 'a', name: 'A', category: 'hair-care', price: 1, image: '', description: '', inStock: true, featured: false, featuredOrder: null },
|
||||
{ id: 'b', name: 'B', category: 'tools', price: 1, image: '', description: '', inStock: true, featured: false, featuredOrder: null },
|
||||
]
|
||||
|
||||
it('returns all products for "all"', () => {
|
||||
|
||||
@@ -9,6 +9,8 @@ export interface Product {
|
||||
image: string
|
||||
description: string
|
||||
inStock: boolean
|
||||
featured: boolean
|
||||
featuredOrder: number | null
|
||||
}
|
||||
|
||||
interface ProductRow {
|
||||
@@ -19,6 +21,8 @@ interface ProductRow {
|
||||
image: string
|
||||
description: string
|
||||
in_stock: boolean
|
||||
featured: boolean
|
||||
featured_order: number | null
|
||||
}
|
||||
|
||||
export async function fetchProducts(): Promise<Product[]> {
|
||||
@@ -32,6 +36,8 @@ export async function fetchProducts(): Promise<Product[]> {
|
||||
image: resolveImageUrl(row.image),
|
||||
description: row.description,
|
||||
inStock: row.in_stock,
|
||||
featured: row.featured,
|
||||
featuredOrder: row.featured_order,
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user