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.3 KB
Raw Blame
import { describe, expect, it } from 'vitest'
import { filterPaymentMethodProviderTypes } from './payment-method'

describe('filterPaymentMethodProviderTypes', () => {
  it('removes custom payment source from the provider picker list', () => {
    const types = [
      {
        type: 'stripe',
        label: 'Stripe',
        schema: { type: 'object' as const, properties: {}, additionalProperties: false as const },
      },
      {
        type: 'custom_payment_source_method',
        label: 'Custom Payment Source Method',
        schema: { type: 'object' as const, properties: {}, additionalProperties: false as const },
      },
      {
        type: 'check',
        label: 'Check',
        schema: { type: 'object' as const, properties: {}, additionalProperties: false as const },
      },
    ]

    expect(filterPaymentMethodProviderTypes(types).map((t) => t.type)).toEqual(['stripe', 'check'])
  })

  it('removes providers this store already has installed', () => {
    const schema = { type: 'object' as const, properties: {}, additionalProperties: false as const }
    const types = [
      { type: 'stripe', label: 'Stripe', schema, installed: true },
      { type: 'check', label: 'Check', schema, installed: false },
    ]

    expect(filterPaymentMethodProviderTypes(types).map((t) => t.type)).toEqual(['check'])
  })
})