/* eslint-env jest */

import tableNames from '../../tables'
import Charity from '../CharityModel'

jest.mock('../../database')

describe('CharityModel', () => {
  it('implements the name property', () => {
    expect(Charity.name).toBeDefined()
  })

  it('implements the hashKey property', () => {
    expect(Charity.hashKey).toBeDefined()
  })

  it('implements the tableName property', () => {
    expect(Charity.tableName).toBe(tableNames['charities'])
  })

  it('auto creates an id', async () => {
    const charity = await Charity.create({ name: 'something' })
    expect(charity.id).toBeDefined()
    expect(charity.name).toEqual('something')
  })

  // TODO: test getting charities
})

@@ -16,16 +16,44 @@
 est */%0A%0A
+import uuid from 'uuid/v4'%0A%0A
 import t
@@ -679,16 +679,222 @@
 )%0A  %7D)%0A%0A
+  it('create with existing id', async () =%3E %7B%0A    const someId = uuid()%0A    const charity = await Charity.create(%7B%0A      id: someId,%0A      name: 'something'%0A    %7D)%0A    expect(charity.id).toBe(someId)%0A  %7D)%0A%0A
   // TOD

Test using an existing ID.