Skip to content

Commit

Permalink
Update snapshots.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterp committed Apr 7, 2020
1 parent eaecb81 commit cc7b342
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -994,3 +994,91 @@ export default PostsPage
",
}
`;
exports[`generate sdl files 1`] = `
Array [
"/path/to/project/api/src/graphql/posts.sdl.js",
]
`;
exports[`generate sdl files 2`] = `
Object {
"/path/to/project/api/src/graphql/posts.sdl.js": "export const schema = gql\`
type Post {
id: Int!
title: String!
slug: String!
author: String!
body: String!
image: String
tags: Tag
postedAt: DateTime
}
type Query {
posts: [Post]
post(id: Int!): Post
}
input PostInput {
title: String
slug: String
author: String
body: String
image: String
postedAt: DateTime
}
type Mutation {
createPost(input: PostInput!): Post
updatePost(id: Int!, input: PostInput!): Post
deletePost(id: Int!): Post
}
\`
",
}
`;
exports[`generate services files 1`] = `
Object {
"/path/to/project/api/src/services/users/users.js": "import { db } from 'src/lib/db'
export const users = () => {
return db.user.findMany()
}
export const user = ({ id }) => {
return db.user.findOne({
where: { id },
})
}
export const createUser = ({ input }) => {
return db.user.create({
data: input,
})
}
export const updateUser = ({ id, input }) => {
return db.user.update({
data: input,
where: { id },
})
}
export const deleteUser = ({ id }) => {
return db.user.delete({
where: { id },
})
}
",
"/path/to/project/api/src/services/users/users.test.js": "import { users } from './users'
describe('users', () => {
it('returns true', () => {
expect(true).toBe(true)
})
})
",
}
`;
90 changes: 3 additions & 87 deletions packages/cli/src/commands/generate/__tests__/generate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,100 +81,16 @@ describe('generate', () => {
describe('sdl', () => {
it('files', async (done) => {
const files = await sdl.files({ name: 'Post', crud: true })

expect(Object.keys(files)).toMatchInlineSnapshot(`
Array [
"/path/to/project/api/src/graphql/posts.sdl.js",
]
`)

expect(files).toMatchInlineSnapshot(`
Object {
"/path/to/project/api/src/graphql/posts.sdl.js": "export const schema = gql\`
type Post {
id: Int!
title: String!
slug: String!
author: String!
body: String!
image: String
tags: Tag
postedAt: DateTime
}
type Query {
posts: [Post]
post(id: Int!): Post
}
input PostInput {
title: String
slug: String
author: String
body: String
image: String
postedAt: DateTime
}
type Mutation {
createPost(input: PostInput!): Post
updatePost(id: Int!, input: PostInput!): Post
deletePost(id: Int!): Post
}
\`
",
}
`)
expect(Object.keys(files)).toMatchSnapshot()
expect(files).toMatchSnapshot()
done()
})
})

describe('services', () => {
it('files', async (done) => {
const files = await service.files({ name: 'User', crud: true })
expect(files).toMatchInlineSnapshot(`
Object {
"/path/to/project/api/src/services/users/users.js": "import { db } from 'src/lib/db'
export const users = () => {
return db.user.findMany()
}
export const user = ({ id }) => {
return db.user.findOne({
where: { id },
})
}
export const createUser = ({ input }) => {
return db.user.create({
data: input,
})
}
export const updateUser = ({ id, input }) => {
return db.user.update({
data: input,
where: { id },
})
}
export const deleteUser = ({ id }) => {
return db.user.delete({
where: { id },
})
}
",
"/path/to/project/api/src/services/users/users.test.js": "import { users } from './users'
describe('users', () => {
it('returns true', () => {
expect(true).toBe(true)
})
})
",
}
`)
expect(files).toMatchSnapshot()
done()
})
})
Expand Down

0 comments on commit cc7b342

Please sign in to comment.