Skip to content

Commit 44035db

Browse files
authored
Merge pull request #16 from shaderzz/master
Updated dependencies to their lastest versions, updated tests and coverage. Removed deprecated components
2 parents 2acf574 + 52a1e90 commit 44035db

File tree

8 files changed

+138
-144
lines changed

8 files changed

+138
-144
lines changed

.babelrc

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
{
2-
"presets": ["react", "env"],
2+
"presets": [
3+
"@babel/preset-react",
4+
"@babel/preset-env"
5+
],
36
"plugins": [
4-
["react-transform", {
5-
"transforms": [
6-
{
7-
"transform": "react-transform-hmr",
8-
"imports": ["react"],
9-
"locals": ["module"]
10-
},
11-
{
12-
"transform": "react-transform-catch-errors",
13-
"imports": ["react", "redbox-react"]
14-
}
15-
]
16-
}],
17-
"transform-decorators-legacy",
18-
"transform-class-properties",
19-
"transform-object-rest-spread"
7+
[
8+
"@babel/plugin-proposal-decorators",
9+
{
10+
"legacy": true
11+
}
12+
],
13+
"@babel/plugin-proposal-class-properties",
14+
"@babel/plugin-proposal-object-rest-spread"
2015
],
2116
"env": {
2217
"test": {

.nycrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"require": [
3-
"babel-register"
3+
"@babel/register"
44
],
55
"reporter": [
66
"lcov",

dist/bundle.js

Lines changed: 1 addition & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"start": "node devServer.js",
88
"build:webpack": "NODE_ENV=production webpack --config webpack.config.prod.js",
9-
"test": "mocha --require babel-core/register --recursive",
9+
"test": "mocha --require @babel/register --recursive",
1010
"test:watch": "npm test -- --watch",
1111
"coverage": "cross-env NODE_ENV=test nyc -- npm test",
1212
"coveralls": "cross-env NODE_ENV=test nyc report --reporter=lcov && coveralls < ./coverage/lcov.info && rm -rf ./coverage"
@@ -19,51 +19,48 @@
1919
"author": "Edoardo Colombo <edo.gcolombo@gmail.com>",
2020
"license": "MIT",
2121
"dependencies": {
22-
"immutable": "^3.7.5",
22+
"immutable": "^4.0.0-rc.12",
2323
"lodash": "^4.17.5",
2424
"prop-types": "^15.6.0",
25-
"react": "^16.2.0",
26-
"react-dnd": "^2.0.2",
27-
"react-dnd-html5-backend": "^2.0.0",
25+
"react": "^16.8.3",
26+
"react-dnd": "^9.4.0",
27+
"react-dnd-html5-backend": "^9.4.0",
2828
"react-dom": "^16.2.0",
29-
"react-prefixer": "^2.0.0",
30-
"react-redux": "^5.0.6",
31-
"redux": "^3.0.2"
29+
"react-prefixer": "^2.0.1",
30+
"react-redux": "^7.1.1",
31+
"redux": "^4.0.4"
3232
},
3333
"devDependencies": {
34-
"babel-cli": "^6.26.0",
35-
"babel-core": "^6.26.0",
36-
"babel-eslint": "^8.2.1",
37-
"babel-loader": "^7.1.2",
38-
"babel-plugin-istanbul": "^4.1.5",
39-
"babel-plugin-react-transform": "^3.0.0",
40-
"babel-plugin-transform-class-properties": "^6.24.1",
41-
"babel-plugin-transform-decorators-legacy": "^1.3.4",
42-
"babel-plugin-transform-object-rest-spread": "^6.26.0",
43-
"babel-preset-env": "^1.6.1",
44-
"babel-preset-react": "^6.24.1",
45-
"babel-register": "^6.26.0",
34+
"@babel/cli": "^7.6.4",
35+
"@babel/core": "^7.6.4",
36+
"@babel/plugin-proposal-class-properties": "^7.5.5",
37+
"@babel/plugin-proposal-decorators": "^7.0.0",
38+
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
39+
"@babel/preset-env": "^7.6.3",
40+
"@babel/preset-react": "^7.6.3",
41+
"@babel/register": "^7.6.2",
42+
"babel-eslint": "^10.0.3",
43+
"babel-loader": "^8.0.6",
44+
"babel-plugin-istanbul": "^5.2.0",
4645
"coveralls": "^3.0.0",
47-
"cross-env": "^5.1.3",
48-
"eslint": "^4.15.0",
46+
"cross-env": "^6.0.3",
47+
"eslint": "^6.6.0",
4948
"eslint-plugin-react": "^7.5.1",
50-
"expect": "^22.1.0",
49+
"expect": "^24.9.0",
5150
"express": "^4.13.3",
52-
"mocha": "^5.0.0",
53-
"nyc": "^11.4.1",
51+
"mocha": "^6.2.2",
52+
"nyc": "^14.1.1",
5453
"react-test-renderer": "^16.2.0",
55-
"react-transform-catch-errors": "^1.0.0",
56-
"react-transform-hmr": "^1.0.0",
57-
"redbox-react": "^1.0.1",
5854
"redux-devtools": "^3.4.1",
5955
"redux-devtools-dock-monitor": "^1.1.3",
6056
"redux-slider-monitor": "^2.0.0-1",
61-
"rimraf": "^2.4.3",
62-
"unexpected": "^10.0.2",
57+
"rimraf": "^3.0.0",
58+
"uglifyjs-webpack-plugin": "^2.2.0",
59+
"unexpected": "^11.8.0",
6360
"unexpected-react-shallow": "^0.7.0",
64-
"webpack": "^3.10.0",
65-
"webpack-dev-middleware": "^2.0.4",
66-
"webpack-dev-server": "^2.11.0",
61+
"webpack": "^4.41.2",
62+
"webpack-dev-middleware": "^3.7.2",
63+
"webpack-dev-server": "^3.9.0",
6764
"webpack-hot-middleware": "^2.0.0"
6865
}
6966
}

src/components/controller/Game.jsx

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import React from 'react';
22
import SmartDeck from './SmartDeck.jsx';
33
import SmartPile from './SmartPile.jsx';
44
import SmartFoundation from './SmartFoundation.jsx';
5-
import { DragDropContext } from 'react-dnd';
5+
import { DndProvider } from "react-dnd";
66
import HTML5Backend from 'react-dnd-html5-backend';
77
import range from 'lodash/range';
88
import { connect } from 'react-redux';
99
import ActionCreators from '../../actions';
1010
import { Colors, Dimensions } from '../../constants';
1111

1212
@connect((state) => { return { game: state.game.toJS(), score: state.score } })
13-
@DragDropContext(HTML5Backend)
13+
1414
class Game extends React.Component {
1515

1616
turnCard = () => {
@@ -28,59 +28,61 @@ class Game extends React.Component {
2828
const { moveCards, turnCard } = this;
2929
console.log(score);
3030
return (
31-
<div style={{
32-
width: Dimensions.Game.width,
33-
height: Dimensions.Game.height,
34-
backgroundColor: Colors.Game.backgroundColor,
35-
padding: 10
36-
}}>
37-
<div style={{display: 'flex', justifyContent: 'space-between'}}>
38-
<SmartDeck deck={game.DECK} turnCard={turnCard} />
31+
<DndProvider backend={HTML5Backend}>
32+
<div style={{
33+
width: Dimensions.Game.width,
34+
height: Dimensions.Game.height,
35+
backgroundColor: Colors.Game.backgroundColor,
36+
padding: 10
37+
}}>
38+
<div style={{display: 'flex', justifyContent: 'space-between'}}>
39+
<SmartDeck deck={game.DECK} turnCard={turnCard} />
40+
<div style={{
41+
width: 540,
42+
display: 'flex',
43+
justifyContent: 'space-between'
44+
}}>
45+
<SmartFoundation
46+
suit="HEARTS"
47+
cards={game.FOUNDATION.HEARTS}
48+
moveCards={moveCards}
49+
/>
50+
<SmartFoundation
51+
suit="DIAMONDS"
52+
cards={game.FOUNDATION.DIAMONDS}
53+
moveCards={moveCards}
54+
/>
55+
<SmartFoundation
56+
suit="CLUBS"
57+
cards={game.FOUNDATION.CLUBS}
58+
moveCards={moveCards}
59+
/>
60+
<SmartFoundation
61+
suit="SPADES"
62+
cards={game.FOUNDATION.SPADES}
63+
moveCards={moveCards}
64+
/>
65+
</div>
66+
</div>
3967
<div style={{
40-
width: 540,
4168
display: 'flex',
42-
justifyContent: 'space-between'
69+
justifyContent: 'space-between',
70+
width: '100%',
71+
marginTop: 40
4372
}}>
44-
<SmartFoundation
45-
suit="HEARTS"
46-
cards={game.FOUNDATION.HEARTS}
47-
moveCards={moveCards}
48-
/>
49-
<SmartFoundation
50-
suit="DIAMONDS"
51-
cards={game.FOUNDATION.DIAMONDS}
52-
moveCards={moveCards}
53-
/>
54-
<SmartFoundation
55-
suit="CLUBS"
56-
cards={game.FOUNDATION.CLUBS}
57-
moveCards={moveCards}
58-
/>
59-
<SmartFoundation
60-
suit="SPADES"
61-
cards={game.FOUNDATION.SPADES}
62-
moveCards={moveCards}
63-
/>
73+
{
74+
range(0, 6).map(index =>
75+
<SmartPile
76+
cards={game.PILE[index]}
77+
index={index}
78+
key={index}
79+
moveCards={moveCards}
80+
/>
81+
)
82+
}
6483
</div>
6584
</div>
66-
<div style={{
67-
display: 'flex',
68-
justifyContent: 'space-between',
69-
width: '100%',
70-
marginTop: 40
71-
}}>
72-
{
73-
range(0, 6).map(index =>
74-
<SmartPile
75-
cards={game.PILE[index]}
76-
index={index}
77-
key={index}
78-
moveCards={moveCards}
79-
/>
80-
)
81-
}
82-
</div>
83-
</div>
85+
</DndProvider>
8486
);
8587
}
8688
}

test/reducers/GameReducer_test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ describe('MOVE_CARD', () => {
5151
const newState = getNewGame(TestActions.PILE_TO_PILE);
5252
expect(
5353
newState.PILE[5]
54-
).toContain(TestActions.PILE_TO_PILE.payload.cards[0]);
54+
).toContainEqual(TestActions.PILE_TO_PILE.payload.cards[0]);
5555

5656
expect(
5757
newState.PILE[3]
58-
).not.toContain(TestActions.PILE_TO_PILE.payload.cards[0])
58+
).not.toContainEqual(TestActions.PILE_TO_PILE.payload.cards[0])
5959
});
6060

6161
it('should handle from PILE to PILE, multiple cards');
@@ -64,18 +64,18 @@ describe('MOVE_CARD', () => {
6464
const newState = getNewGame(TestActions.FOUNDATION_TO_PILE);
6565
expect(
6666
newState.PILE[2]
67-
).toContain(TestActions.FOUNDATION_TO_PILE.payload.cards[0]);
67+
).toContainEqual(TestActions.FOUNDATION_TO_PILE.payload.cards[0]);
6868
expect(
6969
newState.FOUNDATION.CLUBS
70-
).not.toContain(TestActions.FOUNDATION_TO_PILE.payload.cards[0]);
70+
).not.toContainEqual(TestActions.FOUNDATION_TO_PILE.payload.cards[0]);
7171

7272
});
7373

7474
it('should handle from DECK to PILE', () => {
7575
const newState = getNewGame(TestActions.DECK_TO_PILE);
7676
expect(
7777
newState.PILE[5]
78-
).toContain(TestActions.DECK_TO_PILE.payload.cards[0]);
78+
).toContainEqual(TestActions.DECK_TO_PILE.payload.cards[0]);
7979
expect(
8080
newState.DECK.upturned
8181
).not.toContain(TestActions.DECK_TO_PILE.payload.cards[0]);
@@ -88,13 +88,13 @@ describe('MOVE_CARD', () => {
8888
const newState = getNewGame(TestActions.DECK_TO_FOUNDATION);
8989
expect(
9090
newState.FOUNDATION.CLUBS
91-
).toContain(TestActions.DECK_TO_FOUNDATION.payload.cards[0]);
91+
).toContainEqual(TestActions.DECK_TO_FOUNDATION.payload.cards[0]);
9292
expect(
9393
newState.DECK.upturned
94-
).not.toContain(TestActions.DECK_TO_FOUNDATION.payload.cards[0]);
94+
).not.toContainEqual(TestActions.DECK_TO_FOUNDATION.payload.cards[0]);
9595
expect(
9696
newState.DECK.downturned
97-
).not.toContain(TestActions.DECK_TO_FOUNDATION.payload.cards[0]);
97+
).not.toContainEqual(TestActions.DECK_TO_FOUNDATION.payload.cards[0]);
9898
});
9999

100100
});

webpack.config.dev.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var webpack = require('webpack');
33

44
module.exports = {
55
devtool: 'eval',
6+
mode: 'development',
67
entry: [
78
'webpack-hot-middleware/client?reload=true',
89
'./src/index'
@@ -17,13 +18,16 @@ module.exports = {
1718
new webpack.NoEmitOnErrorsPlugin()
1819
],
1920
module: {
20-
loaders: [
21+
rules: [
2122
{
2223
test: /\.jsx?$/,
23-
loaders: ['babel-loader'],
24+
use: 'babel-loader',
2425
include: path.join(__dirname, 'src')
2526
},
26-
{test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192'}
27+
{
28+
test: /\.(png|jpg)$/,
29+
use: 'url-loader?limit=8192'
30+
}
2731
]
2832
}
2933
};

0 commit comments

Comments
 (0)