diff --git a/api/src/services/contacts/contacts.scenarios.js b/api/src/services/contacts/contacts.scenarios.js new file mode 100644 index 0000000..264fecc --- /dev/null +++ b/api/src/services/contacts/contacts.scenarios.js @@ -0,0 +1,9 @@ +export const standard = { + contact: { + john: { + name: 'John Doe', + email: 'john.doe@example.com', + message: 'I love RedwoodJS', + }, + }, +} diff --git a/api/src/services/contacts/contacts.test.js b/api/src/services/contacts/contacts.test.js index fbbbc1e..8708b0c 100644 --- a/api/src/services/contacts/contacts.test.js +++ b/api/src/services/contacts/contacts.test.js @@ -1,9 +1,10 @@ -/* import { contacts } from './contacts' -*/ describe('contacts', () => { - it('returns true', () => { - expect(true).toBe(true) + scenario('returns a list of contacts', async (scenario) => { + const list = await contacts() + + expect(list.length).toEqual(Object.keys(scenario.contact).length) + expect(list[0].email).toEqual(scenario.contact.john.email) }) }) diff --git a/api/src/services/posts/posts.scenarios.js b/api/src/services/posts/posts.scenarios.js new file mode 100644 index 0000000..e53e228 --- /dev/null +++ b/api/src/services/posts/posts.scenarios.js @@ -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.", + }, + }, +} diff --git a/api/src/services/posts/posts.test.js b/api/src/services/posts/posts.test.js index f23483a..8074b9e 100644 --- a/api/src/services/posts/posts.test.js +++ b/api/src/services/posts/posts.test.js @@ -1,9 +1,16 @@ -/* -import { posts } from './posts' -*/ +import { posts, post } from './posts' describe('posts', () => { - it('returns true', () => { - expect(true).toBe(true) + scenario('returns a list of posts', async (scenario) => { + 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) }) })