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
import { createStore } from 'redux'; | |
// reducer is the reducer we defined earlier | |
const store = createStore(reducer); |
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
store.dispatch( | |
{ | |
type: 'CHARACTER_TYPED', | |
char: 'x' | |
} | |
); |
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
const state = store.getState(); | |
// Logs 'x' | |
console.log(state); |
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
const unsubscribe = store.subscribe( () => console.log( store.getState() ) ); |
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
// Logs 'x' | |
store.dispatch(insertCharacter('x')); | |
// Logs 'xy' | |
store.dispatch(insertCharacter('y')); | |
// `removeCharacter` is an action creator wrapping the `BACKSPACE` action | |
// Logs 'x' | |
store.dispatch(removeCharacter()); | |
// Logs '' | |
store.dispatch(removeCharacter()); |
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
unsubscribe(); | |
// Nothing is logged | |
store.dispatch(insertCharacter('z')); |
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
sudo npm install -g sloc |
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
sloc src/ |
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
/* | |
* Step 1 | |
*/ | |
npm install --save-dev jsdom | |
/* | |
* Step 2 (http://airbnb.io/enzyme/docs/guides/jsdom.html) | |
* | |
* test-browser-env.js |
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
// Add the plugin to the CodeceptJS config | |
... | |
plugins: { | |
logPageSource: { | |
require: "./logPageSource", | |
enabled: true | |
} | |
} |