import {
  artikels,
  artikel,
  createArtikel,
  updateArtikel,
  deleteArtikel,
} from './artikels'

// Generated boilerplate tests do not account for all circumstances
// and can fail without adjustments, e.g. Float.
//           Please refer to the RedwoodJS Testing Docs:
//       https://redwoodjs.com/docs/testing#testing-services
// https://redwoodjs.com/docs/testing#jest-expect-type-considerations

describe('artikels', () => {
  scenario('returns all artikels', async (scenario) => {
    const result = await artikels()

    expect(result.length).toEqual(Object.keys(scenario.artikel).length)
  })

  scenario('returns a single artikel', async (scenario) => {
    const result = await artikel({ id: scenario.artikel.one.id })

    expect(result).toEqual(scenario.artikel.one)
  })

  scenario('creates a artikel', async () => {
    const result = await createArtikel({
      input: { name: 'String6975650' },
    })

    expect(result.name).toEqual('String6975650')
  })

  scenario('updates a artikel', async (scenario) => {
    const original = await artikel({ id: scenario.artikel.one.id })
    const result = await updateArtikel({
      id: original.id,
      input: { name: 'String5200162' },
    })

    expect(result.name).toEqual('String5200162')
  })

  scenario('deletes a artikel', async (scenario) => {
    const original = await deleteArtikel({
      id: scenario.artikel.one.id,
    })
    const result = await artikel({ id: original.id })

    expect(result).toEqual(null)
  })
})
