import { test } from '@japa/runner'
import { Trash } from '../../../../src/mocking/lib/Trash.js'
import { ProjectKind } from '../../../../src/models/kinds.js'
import type { TrashEntry } from '../../../../src/models/TrashEntry.js'

test.group('Trash', (group) => {
  let trash: Trash

  group.each.setup(() => {
    trash = new Trash()
  })

  test('trashEntry() returns a valid object', ({ assert }) => {
    const result = trash.trashEntry()
    assert.typeOf(result, 'object')
    assert.property(result, 'key')
    assert.property(result, 'refKey')
    assert.property(result, 'kind')
    assert.property(result, 'info')
    assert.property(result, 'capabilities')
  })

  test('trashEntry(init) allows overriding properties', ({ assert }) => {
    const init: Partial<TrashEntry> = {
      key: 'custom-key',
      kind: ProjectKind,
    }
    const result = trash.trashEntry(init)
    assert.equal(result.key, 'custom-key')
    assert.equal(result.kind, ProjectKind)
  })

  test('trashEntries() returns a list', ({ assert }) => {
    const result = trash.trashEntries(5)
    assert.isArray(result)
    assert.lengthOf(result, 5)
  })

  test('trashEntries(size, init) allows overriding properties', ({ assert }) => {
    const init: Partial<TrashEntry> = {
      kind: ProjectKind,
    }
    const result = trash.trashEntries(3, init)
    assert.lengthOf(result, 3)
    result.forEach((item) => {
      assert.equal(item.kind, ProjectKind)
    })
  })
})
