Skip to content

Instantly share code, notes, and snippets.

@Zmoki
Forked from anonymous/index.html
Created January 27, 2016 23:07
Show Gist options
  • Select an option

  • Save Zmoki/bb861d8d209fdce3a5da to your computer and use it in GitHub Desktop.

Select an option

Save Zmoki/bb861d8d209fdce3a5da to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/bijeso
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://wzrd.in/standalone/expect@latest"></script>
<script src="https://wzrd.in/standalone/deep-freeze@latest"></script>
</head>
<body>
<script id="jsbin-javascript">
const filter = (state, action) => {
switch (action.type) {
case 'SET_FILTER_DAY':
state.day = action.day;
return Object.assign({}, state, {
day: action.day
});
break;
default:
return state;
}
};
const testFilter = () => {
const filterBefore = {
time: {
from: [0, 0],
to: [23, 59]
},
day: 1,
games: []
};
const filterAfter = {
time: {
from: [0, 0],
to: [23, 59]
},
day: 2,
games: []
};
deepFreeze(filterBefore);
expect(
filter(filterBefore, {
type: 'SET_FILTER_DAY',
day: 2
})
).toEqual(filterAfter);
};
testFilter();
console.log('All good!');
</script>
<script id="jsbin-source-javascript" type="text/javascript">const filter = (state, action) => {
switch (action.type) {
case 'SET_FILTER_DAY':
state.day = action.day;
return Object.assign({}, state, {
day: action.day
});
break;
default:
return state;
}
};
const testFilter = () => {
const filterBefore = {
time: {
from: [0, 0],
to: [23, 59]
},
day: 1,
games: []
};
const filterAfter = {
time: {
from: [0, 0],
to: [23, 59]
},
day: 2,
games: []
};
deepFreeze(filterBefore);
expect(
filter(filterBefore, {
type: 'SET_FILTER_DAY',
day: 2
})
).toEqual(filterAfter);
};
testFilter();
console.log('All good!');</script></body>
</html>
const filter = (state, action) => {
switch (action.type) {
case 'SET_FILTER_DAY':
state.day = action.day;
return Object.assign({}, state, {
day: action.day
});
break;
default:
return state;
}
};
const testFilter = () => {
const filterBefore = {
time: {
from: [0, 0],
to: [23, 59]
},
day: 1,
games: []
};
const filterAfter = {
time: {
from: [0, 0],
to: [23, 59]
},
day: 2,
games: []
};
deepFreeze(filterBefore);
expect(
filter(filterBefore, {
type: 'SET_FILTER_DAY',
day: 2
})
).toEqual(filterAfter);
};
testFilter();
console.log('All good!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment