Skip to content

Commit

Permalink
Merge pull request #11 from cfaloon/snapshot-tests
Browse files Browse the repository at this point in the history
We have snapshots!
  • Loading branch information
cfaloon committed Dec 21, 2017
2 parents 6ac2e03 + 441c827 commit ea7771f
Show file tree
Hide file tree
Showing 2 changed files with 1,616 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/App.test.js
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();
});
Loading

0 comments on commit ea7771f

Please sign in to comment.