-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tomazy
committed
Aug 27, 2018
1 parent
136c546
commit e1245ae
Showing
6 changed files
with
82 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as React from 'react' | ||
|
||
export type OnBegin = () => void | ||
|
||
interface Props { | ||
numQuestions: number | ||
onBegin: OnBegin | ||
} | ||
|
||
export const WelcomePage = ({ numQuestions, onBegin }: Props) => ( | ||
<div> | ||
<h1>Welcome to the Trivia Challenge!</h1> | ||
|
||
<p> | ||
You will be presented with {numQuestions} <strong>True</strong> or <strong>False</strong> questions. | ||
</p> | ||
|
||
<p> | ||
Can you score 100%? | ||
</p> | ||
|
||
<div> | ||
<button onClick={() => onBegin()}>Begin</button> | ||
</div> | ||
</div> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { mount, shallow } from 'enzyme' | ||
import 'jest-enzyme' | ||
import * as React from 'react' | ||
|
||
import { OnBegin, WelcomePage } from '../../pages/WelcomePage' | ||
|
||
describe('<WelcomePage />', () => { | ||
let onBeginMock: OnBegin | ||
|
||
beforeEach(() => { | ||
onBeginMock = jest.fn() | ||
}) | ||
|
||
it('renders the number of questions', () => { | ||
const numQuestions = 1234567 | ||
const page = shallow( | ||
<WelcomePage | ||
numQuestions={numQuestions} | ||
onBegin={onBeginMock} | ||
/> | ||
) | ||
expect(page).toIncludeText(String(numQuestions)) | ||
}) | ||
|
||
it('handles the button click', () => { | ||
const page = mount( | ||
<WelcomePage | ||
numQuestions={5} | ||
onBegin={onBeginMock} | ||
/> | ||
) | ||
page.find('button').simulate('click') | ||
expect(onBeginMock).toHaveBeenCalled() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters