Skip to content

Instantly share code, notes, and snippets.

View kilkelly's full-sized avatar
💻
_

Frank Kilkelly kilkelly

💻
_
View GitHub Profile
@kilkelly
kilkelly / testEntireState.js
Created April 9, 2017 13:29
Test the entire state in our Redux store
// testEntireState.js
var tape = require('tape')
var redux = require('redux')
var reducer = require('./reducer')
// ---------------------------------------------------
// Tape test starts here...
tape('Increment counter along with a status message', function (test) {
@kilkelly
kilkelly / testValueInState.js
Created April 9, 2017 13:24
Test a specific value in our Redux store
// testValueInState.js
var tape = require('tape')
var redux = require('redux')
var reducer = require('./reducer')
// ---------------------------------------------------
// Tape test starts here...
tape('Increment counter', function (test) {
@kilkelly
kilkelly / reducer.js
Created April 8, 2017 19:28
Reducer that handles our actions
// reducer.js
module.exports = function reducer (state, action) {
switch (action.type) {
// action that increments a counter
case 'INCREMENT': {
// clone a fresh copy of our current state, as reducers never mutate existing state
var newState = Object.assign({}, state)
// increment the counter in state