diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-03-22 16:29:31 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-03-22 16:29:31 -0400 |
| commit | a6af043686e4375d7944e91cae3d5b63c59edab0 (patch) | |
| tree | f814d412b14a2a47f56c933ce38f458055f2f83b /backend | |
| parent | 93495ce146c4e81ecfab3a0bca99460e75a759da (diff) | |
Migrate to render props
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/__tests__/user.test.js | 30 | ||||
| -rw-r--r-- | backend/package.json | 2 |
2 files changed, 24 insertions, 8 deletions
diff --git a/backend/__tests__/user.test.js b/backend/__tests__/user.test.js index bedca3f..f73ed79 100644 --- a/backend/__tests__/user.test.js +++ b/backend/__tests__/user.test.js @@ -1,9 +1,8 @@ -const { request } = require('graphql-request'); -const createServer = require('../src/createServer'); - import { SIGNUP_MUTATION } from '../../frontend/queries/index'; +import { print } from 'graphql/language/printer'; -console.log(SIGNUP_MUTATION); +const { request } = require('graphql-request'); +const createServer = require('../src/createServer'); let server; const port = 2342; @@ -18,9 +17,26 @@ afterAll(async () => { }); describe('User C.R.U.D. Operations', () => { - it('Creates a user', () => { - const query = ` + const email = `wes${Date.now()}@gmail.com`; - `; + it('Creates a user', async () => { + const { signup } = await request(endpoint, print(SIGNUP_MUTATION), { + name: 'Wes Bos', + email, + password: 'test', + }); + expect(signup.token).toBeTruthy(); + expect(signup.user.name).toBe('Wes Bos'); + expect(signup.user.email).toBe(email); }); + + it('throws an error with a duplicate signup', async () => + request(endpoint, print(SIGNUP_MUTATION), { + name: 'wes bos', + email, + password: 'test', + }).catch(err => { + expect(err.message).toContain('A unique constraint would be violated on User.'); + console.log(err.message); + })); }); diff --git a/backend/package.json b/backend/package.json index 645e930..4a1a0ae 100644 --- a/backend/package.json +++ b/backend/package.json @@ -36,4 +36,4 @@ "env" ] } -} +}
\ No newline at end of file |
