From e4e985cfce71b358d1213badc9e1b54c6c7104e1 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Wed, 20 Jul 2022 22:54:31 +0800 Subject: [PATCH] add more test --- packages/api/test/resolvers/user.test.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/api/test/resolvers/user.test.ts b/packages/api/test/resolvers/user.test.ts index 7115ca7ed..ebcef7128 100644 --- a/packages/api/test/resolvers/user.test.ts +++ b/packages/api/test/resolvers/user.test.ts @@ -360,20 +360,30 @@ describe('User API', () => { }) context('when inputs are valid and user not exists', () => { - before(() => { + beforeEach(() => { password = correctPassword username = 'Some_username' email = `${username}@fake.com` }) - after(async () => { + afterEach(async () => { await deleteTestUser(username) }) it('responds with 200', async () => { - const res = await graphqlRequest(query).expect(200) + return graphqlRequest(query).expect(200) + }) + + it('returns the user', async () => { + const res = await graphqlRequest(query).send() + expect(res.body.data.signup.me.profile.username).to.eql(username) + }) + + it('creates user with correct username', async () => { + const res = await graphqlRequest(query).send() + const user = await getUser(res.body.data.signup.me.id) - expect(user).to.exist + expect(user?.profile?.username).to.eql(username) }) })