Skip to content

Commit 7e4c305

Browse files
committed
Pass twitter handle through to profile
1 parent 5e16d1d commit 7e4c305

File tree

7 files changed

+21
-12
lines changed

7 files changed

+21
-12
lines changed

components/User/components/Profile.test.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('<Profile />', () => {
66
let profile
77

88
beforeEach(() => {
9-
profile = shallow(<Profile name='Luke' biography='My bio' />)
9+
profile = shallow(<Profile name='Luke' biography='My bio' twitter='@Cool' />)
1010
})
1111

1212
it('should display name', () => {
@@ -16,4 +16,8 @@ describe('<Profile />', () => {
1616
it('should display biography', () => {
1717
expect(profile).toIncludeText('My bio')
1818
})
19+
20+
it('should display twitter', () => {
21+
expect(profile).toIncludeText('@Cool')
22+
})
1923
})
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import * as React from 'react'
22

3-
export default ({ name, biography }) =>
3+
export default ({ name, biography, twitter }) =>
44
<div>
55
<p>{name}</p>
66
<p>{biography}</p>
7+
<p>Follow on twitter: {twitter}</p>
78
</div>

lib/user/FakeUserGateway.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export async function findById (id: string) : Promise<User> {
44
return {
55
name: 'Mr Luke Fake',
66
7-
biography: 'Coool'
7+
biography: 'Coool',
8+
twitter: '@Cool'
89
}
910
}

lib/user/LoadUserProfile.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import UserGateway from './UserGateway'
2+
import User from './User'
23

34
type Request = {
45
userId: string
56
}
67

78
type Response = {
8-
user: {
9-
name: string,
10-
biography: string
11-
}
9+
user: User
1210
}
1311

14-
export default async function LoadUserProfile (gateway: UserGateway, req: Request) : Promise<Response> {
12+
export default async function LoadUserProfile (gateway: UserGateway, req: Request): Promise<Response> {
1513
const user = await gateway.findById(req.userId)
1614
return { user }
1715
}

lib/user/User.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export default interface User {
22
name: string
33
email: string
44
biography: string
5+
twitter: string
56
}

pages/users/profile.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import { Profile } from '../../components/User'
44

55
export default app.page(class extends React.Component {
66
props: {
7-
user: { name: string, biography: string }
7+
user: {
8+
name: string,
9+
biography: string,
10+
twitter: string
11+
}
812
}
913

1014
render () {

pages/users/profile.test.tsx renamed to test/acceptance/users/viewingProfile.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as React from 'react'
22
import { mountPage } from 'republic/test-next'
3-
import mockExecute from '../../test/support/mockExecute'
4-
import UserProfile from './profile'
3+
import mockExecute from '../../support/mockExecute'
4+
import UserProfile from '../../../pages/users/profile'
55

6-
describe('UserProfile', () => {
6+
describe('Viewing profile', () => {
77
const userId = 'uniq-guid'
88
const fakeUser = { basicInfo: { name: 'Luke', email: '[email protected]' } }
99

0 commit comments

Comments
 (0)