-
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.
Merge pull request #11 from cfaloon/snapshot-tests
We have snapshots!
- Loading branch information
Showing
2 changed files
with
1,616 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,50 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import App from './App'; | ||
import renderer from 'react-test-renderer'; | ||
|
||
it('renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
ReactDOM.render(<App />, div); | ||
}); | ||
|
||
// SNAPSHOT TESTS follow link for more details | ||
// https://facebook.github.io/jest/docs/en/snapshot-testing.html#snapshot-testing-with-jest | ||
it('enters numbers to display', () => { | ||
const app = renderer.create(<App />); | ||
expect(app.toJSON()).toMatchSnapshot(); | ||
|
||
app.getInstance().handleReceiveInput('4'); | ||
expect(app.toJSON()).toMatchSnapshot(); | ||
|
||
app.getInstance().handleReceiveInput('64'); | ||
expect(app.toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('clears screen', () => { | ||
const app = renderer.create(<App />); | ||
expect(app.toJSON()).toMatchSnapshot(); | ||
|
||
app.getInstance().handleReceiveInput('4'); | ||
expect(app.toJSON()).toMatchSnapshot(); | ||
|
||
app.getInstance().handleReceiveInput('0'); | ||
expect(app.toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('performs addition', () => { | ||
const app = renderer.create(<App />); | ||
expect(app.toJSON()).toMatchSnapshot(); | ||
|
||
app.getInstance().handleReceiveInput('4'); | ||
expect(app.toJSON()).toMatchSnapshot(); | ||
|
||
app.getInstance().handleReceiveOperator('+'); | ||
expect(app.toJSON()).toMatchSnapshot(); | ||
|
||
app.getInstance().handleReceiveInput('7'); | ||
expect(app.toJSON()).toMatchSnapshot(); | ||
|
||
app.getInstance().handleReceiveOperator('='); | ||
expect(app.toJSON()).toMatchSnapshot(); | ||
}); |
Oops, something went wrong.