-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tech - React Test Library - Test Complete App
- Loading branch information
1 parent
850911c
commit 5b770ee
Showing
3 changed files
with
44 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
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,42 @@ | ||
import { describe, it } from "mocha"; | ||
import { expect } from "chai"; | ||
|
||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
import { render, fireEvent, cleanup } from "react-testing-library"; | ||
import { Provider, connect } from "react-redux"; | ||
import { createStore, applyMiddleware, compose } from "redux"; | ||
import createSagaMiddleware from "redux-saga"; | ||
const sagaMiddleware = createSagaMiddleware(); | ||
|
||
import reducers from "../../../src/client/reducers/combined"; | ||
import AppContainer from "../../../src/client/containers/App"; | ||
import rootSaga from "../../../src/client/sagas/combined"; | ||
|
||
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; | ||
|
||
|
||
function renderWithRedux(ui, store) { | ||
return { | ||
...render(<Provider store={store}>{ui}</Provider>), | ||
store | ||
}; | ||
} | ||
|
||
describe.only("actions", () => { | ||
it("should trigger the ADD action", () => { | ||
const store = createStore( | ||
reducers, | ||
{ | ||
calc: { number: 0 } | ||
}, | ||
composeEnhancers(applyMiddleware(sagaMiddleware)) | ||
); | ||
store.subscribe(()=> console.log(store.getState())); | ||
sagaMiddleware.run(rootSaga); | ||
const { getByTestId, getByText, getByValue } = renderWithRedux(<AppContainer />, store); | ||
fireEvent.click(getByText("-")); | ||
fireEvent.click(getByText("+")); | ||
expect(getByTestId("number").value).to.equal("0"); | ||
}); | ||
}); |