Skip to content

armgit / spree

Public Imported from GitHub
0

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.

1.1 KB
Raw Blame
import { describe, expect, it } from 'vitest'
import { client } from './helpers'

describe('markets', () => {
  it('lists markets', async () => {
    const result = await client().markets.list()

    expect(result.data.length).toBeGreaterThan(0)
    const market = result.data[0]
    expect(market.id).toMatch(/^mkt_/)
    expect(market).toHaveProperty('name')
    expect(market).toHaveProperty('currency')
  })

  it('resolves market by country', async () => {
    const market = await client().markets.resolve('US')
    expect(market.id).toMatch(/^mkt_/)
  })
})

describe('countries', () => {
  it('lists countries', async () => {
    const result = await client().countries.list()

    expect(result.data.length).toBeGreaterThan(0)
    const country = result.data[0]
    expect(country).toHaveProperty('iso')
    expect(country).toHaveProperty('name')
  })

  it('gets a country with states', async () => {
    const country = await client().countries.get('US', { expand: ['states'] })

    expect(country.iso).toBe('US')
    expect(country.name).toBe('United States')
  })
})