import { describe, expect, it, vi } from 'vitest'

describe('inventory default-location seed', () => {
  it('inserts the default MAIN location for a tenant', async () => {
    const values = vi.fn().mockResolvedValue(undefined)
    const db = {
      insert: vi.fn(() => ({
        values,
      })),
    }

    const { stockLocations } = await import('../../src/schema/stock-locations')
    const { seedDefaultStockLocation } = await import('../../src/seed/inventory-default-location')

    await seedDefaultStockLocation(db as never, 'tenant-1')

    expect(db.insert).toHaveBeenCalledWith(stockLocations)
    expect(values).toHaveBeenCalledWith(
      expect.objectContaining({
        tenantId: 'tenant-1',
        name: 'Main',
        code: 'MAIN',
        isDefault: true,
        isActive: true,
      }),
    )
  })
})
