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 counters = (...) => {
	switch (action.type) {
		case 'ADD_COUNTER':
			return [...state, 0];
		default:
			return [];
	}
};

expect(
	counters(undefined, {})
).toEqual([]);

expect(
	counters([], { type: 'ADD_COUNTER' })
).toEqual([0]);

expect(
	counters([0], { type: 'ADD_COUNTER '})
).toEqual([0, 0]);

expect(
	counters([0, 0, 0], {
  	type: 'INCREMENT',
    index: 1
  })
).toEqual([0, 1, 0]);

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);

console.log('All tests pass');