Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
import { beforeAll, describe, expect, it } from 'vitest'
import type { Client } from '../src'
import { createTestClient } from './helpers'
describe('wishlists', () => {
let client: Client
beforeAll(() => {
client = createTestClient()
})
const opts = { token: 'user-jwt' }
it('lists wishlists', async () => {
const result = await client.wishlists.list(undefined, opts)
expect(result.data).toHaveLength(1)
})
it('gets a wishlist', async () => {
const result = await client.wishlists.get('wl_1', undefined, opts)
expect(result.name).toBe('My Wishlist')
})
it('creates a wishlist', async () => {
const result = await client.wishlists.create({ name: 'My Wishlist' }, opts)
expect(result.name).toBe('My Wishlist')
})
it('updates a wishlist', async () => {
const result = await client.wishlists.update('wl_1', { name: 'Updated Wishlist' }, opts)
expect(result.name).toBe('Updated Wishlist')
})
it('deletes a wishlist', async () => {
await expect(client.wishlists.delete('wl_1', opts)).resolves.toBeUndefined()
})
describe('items', () => {
it('adds an item', async () => {
const result = await client.wishlists.items.create(
'wl_1',
{ variant_id: 'var_1', quantity: 1 },
opts,
)
expect(result.variant_id).toBe('var_1')
})
it('updates an item', async () => {
const result = await client.wishlists.items.update('wl_1', 'wi_1', { quantity: 3 }, opts)
expect(result.quantity).toBe(3)
})
it('removes an item', async () => {
await expect(client.wishlists.items.delete('wl_1', 'wi_1', opts)).resolves.toBeUndefined()
})
})
})