53 lines
1.6 KiB
JavaScript
53 lines
1.6 KiB
JavaScript
import { users, user, createUser, updateUser, deleteUser } from './users'
|
|
|
|
// Generated boilerplate tests do not account for all circumstances
|
|
// and can fail without adjustments, e.g. Float and DateTime types.
|
|
// Please refer to the RedwoodJS Testing Docs:
|
|
// https://redwoodjs.com/docs/testing#testing-services
|
|
// https://redwoodjs.com/docs/testing#jest-expect-type-considerations
|
|
|
|
describe('users', () => {
|
|
scenario('returns all users', async (scenario) => {
|
|
const result = await users()
|
|
|
|
expect(result.length).toEqual(Object.keys(scenario.user).length)
|
|
})
|
|
|
|
scenario('returns a single user', async (scenario) => {
|
|
const result = await user({ id: scenario.user.one.id })
|
|
|
|
expect(result).toEqual(scenario.user.one)
|
|
})
|
|
|
|
scenario('creates a user', async () => {
|
|
const result = await createUser({
|
|
input: {
|
|
email: 'String4358842',
|
|
hashedPassword: 'String',
|
|
salt: 'String',
|
|
},
|
|
})
|
|
|
|
expect(result.email).toEqual('String4358842')
|
|
expect(result.hashedPassword).toEqual('String')
|
|
expect(result.salt).toEqual('String')
|
|
})
|
|
|
|
scenario('updates a user', async (scenario) => {
|
|
const original = await user({ id: scenario.user.one.id })
|
|
const result = await updateUser({
|
|
id: original.id,
|
|
input: { email: 'String5861252' },
|
|
})
|
|
|
|
expect(result.email).toEqual('String5861252')
|
|
})
|
|
|
|
scenario('deletes a user', async (scenario) => {
|
|
const original = await deleteUser({ id: scenario.user.one.id })
|
|
const result = await user({ id: original.id })
|
|
|
|
expect(result).toEqual(null)
|
|
})
|
|
})
|