Skip to content

Commit d6f1ac1

Browse files
committed
Return email from API
1 parent 3e02a06 commit d6f1ac1

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

api/swagger.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ definitions:
3333
User:
3434
required:
3535
- name
36+
- email
3637
properties:
3738
name:
3839
type: string
3940
example: "Mr Bob Example"
41+
email:
42+
type: string
43+
example: "[email protected]"
4044
Error:
4145
required:
4246
- message

lib/user/FakeUserGateway.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import User from './User'
22

33
export async function findById (id: string) : Promise<User> {
4-
return new User('Luke (fake!)', 'luke@cool.com')
4+
return new User('Mr Luke Fake', 'luke@example.com')
55
}

lib/user/HTTPUserGateway.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ const API_ORIGIN = process.env.API_ORIGIN
66
describe('HTTPUserGateway', () => {
77
describe('when finding by id', () => {
88
test('user has name', async () => {
9-
nock(API_ORIGIN).get('/api/users/guid').reply(200, { name: 'Jim' })
9+
nock(API_ORIGIN).get('/api/users/guid').reply(200, { name: 'Jim', email: '[email protected]' })
1010
const user = await HTTPUserGateway.findById('guid')
1111
expect(user.name).toBe('Jim')
12+
expect(user.email).toBe('[email protected]')
1213
})
1314
})
1415
})

lib/user/HTTPUserGateway.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ const API_ORIGIN = process.env.API_ORIGIN
55

66
export async function findById (id: string) : Promise<User> {
77
const res = await fetch(`${API_ORIGIN}/api/users/${id}`)
8-
const { name } = await res.json()
9-
return new User(name, '[email protected]')
8+
const { name, email } = await res.json()
9+
return new User(name, email)
1010
}

lib/user/LoadUserProfile.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('LoadUserProfile', () => {
55
describe('when loading profile by id', () => {
66
test('user has name', async () => {
77
const { user } = await LoadUserProfile(FakeUserGateway, { id: 'guid' })
8-
expect(user.name).toBe('Luke (fake!)')
8+
expect(user.name).toBe('Mr Luke Fake')
99
})
1010
})
1111
})

0 commit comments

Comments
 (0)