Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
euZebe committed Apr 13, 2018
1 parent 48ee24f commit 042e730
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/store/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {

export const getTableOfCellsSelector = state => state.cellsTable.present;
export const getHoneyCombSelector = state => state.hexaCells.present;
export const getPastHoneyCombSelector = state => state.hexaCells.past;
export const getFutureHoneyCombSelector = state => state.hexaCells.future;
export const honeyCombAsSingleArraySelector = createSelector(
getHoneyCombSelector,
arrayOfRows => [].concat.apply([], arrayOfRows),
Expand Down
35 changes: 21 additions & 14 deletions src/store/reducers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import { RECTANGLE, HEXAGON } from '../model/shapes';
describe('getTableOfCellsSelector', () => {
test('should select cells in a table according to their position', () => {
const state = {
cellsTable: [
[ALIVE, DEAD],
[DEAD, DEAD],
[ALIVE, ALIVE],
],
cellsTable: {
past:[],
present: [
[ALIVE, DEAD],
[DEAD, DEAD],
[ALIVE, ALIVE],
],
},
shape: {
shape: RECTANGLE.value,
height: 3,
Expand All @@ -23,12 +26,14 @@ describe('getTableOfCellsSelector', () => {

test('should return an empty array if hexagon is current', () => {
const state = {
cellsTable: [],
hexaCells: [
[ALIVE, DEAD],
[DEAD, DEAD],
[ALIVE, ALIVE],
],
cellsTable: {present:[]},
hexaCells: {
present: [
[ALIVE, DEAD],
[DEAD, DEAD],
[ALIVE, ALIVE],
],
},
shape: {
shape: HEXAGON.value,
height: 3,
Expand All @@ -42,12 +47,14 @@ describe('getTableOfCellsSelector', () => {
describe('getHoneyCombSelector', () => {
test('should select cells in a table according to their position', () => {
const state = {
hexaCells: [
hexaCells: {present:[
[ALIVE, DEAD],
[DEAD, DEAD],
[ALIVE, ALIVE],
],
cellsTable: [],
],},
cellsTable: {
present: []
},
shape: {
shape: HEXAGON.value,
rows: 3,
Expand Down
9 changes: 6 additions & 3 deletions src/ui/BoardContainer.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { connect } from 'react-redux';
import { ActionCreators as UndoActionCreators } from 'redux-undo'
import Board from './Board';
import {getHoneyCombSelector, getShapeSelector, getTableOfCellsSelector} from '../store/reducers';
import {
getFutureHoneyCombSelector, getHoneyCombSelector, getPastHoneyCombSelector, getShapeSelector,
getTableOfCellsSelector
} from '../store/reducers';
import { toggleStatus } from '../store/cell-duck';

const mapStateToProps = (state) => ({
tableOfCells: getTableOfCellsSelector(state),
honeyComb: getHoneyCombSelector(state),
shape: getShapeSelector,
canRedo: true,
canUndo: true,
canRedo: getFutureHoneyCombSelector(state).length,
canUndo: getPastHoneyCombSelector(state).length,

});

Expand Down

0 comments on commit 042e730

Please sign in to comment.