JSFiddle - React, Tailwind, and code Playground

by liormb

HTML

<script src="https://npmcdn.com/redux/dist/redux.js"></script>
<script src="https://wzrd.in/standalone/expect@latest"></script>

Babel + JSX

const counter = (state = 0, action) => {
	switch (action.type) {
		case 'INCREMENT':
			return ++state;
		case 'DECREMENT':
			return --state;
		default:
			return state;
	}
}

expect(
	counter(0, { type: 'INCREMENT' })
).toEqual(1);

expect(
	counter(1, { type: 'INCREMENT' })
).toEqual(2);

expect(
	counter(2, { type: 'DECREMENT' })
).toEqual(1);

expect(
	counter(undefined, {})
).toEqual(0);