Adds tests
This commit is contained in:
9
api/src/services/contacts/contacts.scenarios.js
Normal file
9
api/src/services/contacts/contacts.scenarios.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
export const standard = {
|
||||||
|
contact: {
|
||||||
|
john: {
|
||||||
|
name: 'John Doe',
|
||||||
|
email: 'john.doe@example.com',
|
||||||
|
message: 'I love RedwoodJS',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
/*
|
|
||||||
import { contacts } from './contacts'
|
import { contacts } from './contacts'
|
||||||
*/
|
|
||||||
|
|
||||||
describe('contacts', () => {
|
describe('contacts', () => {
|
||||||
it('returns true', () => {
|
scenario('returns a list of contacts', async (scenario) => {
|
||||||
expect(true).toBe(true)
|
const list = await contacts()
|
||||||
|
|
||||||
|
expect(list.length).toEqual(Object.keys(scenario.contact).length)
|
||||||
|
expect(list[0].email).toEqual(scenario.contact.john.email)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
18
api/src/services/posts/posts.scenarios.js
Normal file
18
api/src/services/posts/posts.scenarios.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
export const standard = {
|
||||||
|
post: {
|
||||||
|
first: {
|
||||||
|
title: 'First Post',
|
||||||
|
body: 'Lorem ipsum dolar sit amet',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export const withLongBody = {
|
||||||
|
post: {
|
||||||
|
long: {
|
||||||
|
title: 'First Post',
|
||||||
|
body:
|
||||||
|
"I'm baby succulents single-origin coffee coloring book taxidermy sartorial. Irony woke tilde, gentrify you probably haven't heard of them tumblr typewriter enamel pin brunch viral live-edge. Pok pok plaid fingerstache, copper mug pitchfork pickled 3 wolf moon farm-to-table sustainable. Jean shorts freegan salvia tofu dreamcatcher vaporware asymmetrical +1. Pabst gentrify keytar ennui mixtape. Franzen tbh cred austin, health goth intelligentsia flannel pug you probably haven't heard of them 8-bit try-hard tumeric 3 wolf moon cray. Tumeric edison bulb distillery slow-carb subway tile authentic literally kinfolk venmo.\n Food truck pop-up ugh, tacos gluten-free lyft readymade four dollar toast brunch palo santo quinoa. Mixtape twee meh chicharrones lyft. Helvetica succulents brooklyn, farm-to-table +1 quinoa mlkshk vegan you probably haven't heard of them hella bespoke af. Tilde distillery taxidermy artisan, chillwave tofu direct trade raclette polaroid deep v sustainable. Chambray iPhone letterpress, helvetica XOXO wayfarers migas. Hoodie roof party tilde cornhole, heirloom normcore copper mug schlitz meditation YOLO lumbersexual franzen drinking vinegar gluten-free swag.",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -1,9 +1,16 @@
|
|||||||
/*
|
import { posts, post } from './posts'
|
||||||
import { posts } from './posts'
|
|
||||||
*/
|
|
||||||
|
|
||||||
describe('posts', () => {
|
describe('posts', () => {
|
||||||
it('returns true', () => {
|
scenario('returns a list of posts', async (scenario) => {
|
||||||
expect(true).toBe(true)
|
const list = await posts()
|
||||||
|
|
||||||
|
expect(list.length).toEqual(Object.keys(scenario.post).length)
|
||||||
|
expect(list[0].title).toEqual(scenario.post.first.title)
|
||||||
|
})
|
||||||
|
|
||||||
|
scenario('returns a single post by ID', async (scenario) => {
|
||||||
|
const record = await post({ id: scenario.post.first.id })
|
||||||
|
|
||||||
|
expect(record.title).toEqual(scenario.post.first.title)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user