Skip to content

Commit

Permalink
add test case and bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kimorkim committed Sep 16, 2016
1 parent 77da1e3 commit 47b924d
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 21 deletions.
42 changes: 25 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
language: node_js
language:
- node_js
env:
global:
- NODE_VERSION=6
- secure: H+Qtnvo8ZsQ5AwytSqVmZbxGYG0ncLFT35i3XKvySwTqlnsaLoZ7HxSti9PireNzJ3y3NT8ePlv1OlLfSFJ7jU7GLkHq+v9O/1duBc5RFtYliwIjlVjotkhS8vX6HlMakL4xeaeU72E6DPPZN36MdMwrDEgZUN3TGEFNiFK50/t8CYPb1avvSwfxbTK/xgtm0u3IfSydOhpq0DrrwhbZSk/krgvfejil3CZ377Z892Hagcsks7GHvz7yVhW5z6kFyW7Th4y6mW/v21OgGKdxtCJCpHXT3JetOlpbEtqtxIZGogNOyXtzCHFvrbZmw3TPH4/0/HMkIy4o2o9rcay23W6YvoBELQDZMVTgf/6yyxt19eMFUXuofNO3vSYu9ALRwoX9jIE7JqoA9g4BZ4vGXf1ucG/Ak6gP/C7+kXYTgTL254RuTQeRq7fwg4ootKINm7DjPwAXUs+Kpb0XtnPej58Mzqu3Rnlm+6RfPvfzE+23xMCMY2xOCLXv2JZOOp9qZqjtcbnnnkHlft/OnUFR4UG1tMjuh7TD/Ci714HuYyGYlpTWHzCVSteMhCFbL4fmWhth0A1evfD9Rtuq2ErGyxIMPiEPe+xDIC5ljR82I8GIp0FpKUEoX3OaMFvaeM8wG68RWVzjIetyJFHn3p77EalX2U4UWKljriXDHrM5KIA=
node_js:
- 5.0.0
before_install:
- npm install -g gulp
- 6.0.0
branches:
only:
- master
cache:
directories:
- node_modules
- app/node_modules
- "$HOME/.electron"
- "$HOME/.npm"
before_install:
- git clone https://github.com/creationix/nvm.git ~/.nvm
- source ~/.nvm/nvm.sh
- nvm install $NODE_VERSION
- nvm use --delete-prefix $NODE_VERSION
install:
- npm prune
- npm install
script:
- npm test
- npm run webpack
notifications:
email:
- [email protected]
before_deploy: gulp deploy
deploy:
provider: releases
api_key:
secure: H+Qtnvo8ZsQ5AwytSqVmZbxGYG0ncLFT35i3XKvySwTqlnsaLoZ7HxSti9PireNzJ3y3NT8ePlv1OlLfSFJ7jU7GLkHq+v9O/1duBc5RFtYliwIjlVjotkhS8vX6HlMakL4xeaeU72E6DPPZN36MdMwrDEgZUN3TGEFNiFK50/t8CYPb1avvSwfxbTK/xgtm0u3IfSydOhpq0DrrwhbZSk/krgvfejil3CZ377Z892Hagcsks7GHvz7yVhW5z6kFyW7Th4y6mW/v21OgGKdxtCJCpHXT3JetOlpbEtqtxIZGogNOyXtzCHFvrbZmw3TPH4/0/HMkIy4o2o9rcay23W6YvoBELQDZMVTgf/6yyxt19eMFUXuofNO3vSYu9ALRwoX9jIE7JqoA9g4BZ4vGXf1ucG/Ak6gP/C7+kXYTgTL254RuTQeRq7fwg4ootKINm7DjPwAXUs+Kpb0XtnPej58Mzqu3Rnlm+6RfPvfzE+23xMCMY2xOCLXv2JZOOp9qZqjtcbnnnkHlft/OnUFR4UG1tMjuh7TD/Ci714HuYyGYlpTWHzCVSteMhCFbL4fmWhth0A1evfD9Rtuq2ErGyxIMPiEPe+xDIC5ljR82I8GIp0FpKUEoX3OaMFvaeM8wG68RWVzjIetyJFHn3p77EalX2U4UWKljriXDHrM5KIA=
file:
- "dist/js/sdm.min.js"
- "dist/js/sdm.min.js.map"
skip_cleanup: true
on:
tags: true
all_branches: true
- [email protected]
4 changes: 3 additions & 1 deletion dist/SudokuMaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ return /******/ (function(modules) { // webpackBootstrap
key: 'gameDataCheck',
value: function gameDataCheck(gameData) {
var checkData = {
state: _Constants.PlayTypes.COMPLETE,
state: _Constants.PlayTypes.SUCCESS,
box: {},
rows: {},
cols: {}
Expand Down Expand Up @@ -318,6 +318,8 @@ return /******/ (function(modules) { // webpackBootstrap
checkData.state = _Constants.PlayTypes.FAIL;
} else if (isSolving) {
checkData.state = _Constants.PlayTypes.SOLVING;
} else {
_Constants.PlayTypes.state = _Constants.PlayTypes.SUCCESS;
}

return checkData;
Expand Down
2 changes: 1 addition & 1 deletion dist/SudokuMaker.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@
"example": "example"
},
"scripts": {
"test": "echo 0",
"test": "ava",
"webpack": "webpack --display-error-details;",
"watch": "webpack --watch --display-error-details;"
},
"ava": {
"files": [
"test/*.js"
],
"failFast": true,
"tap": true,
"babel": "inherit"
},
"repository": {
"type": "git",
"url": "git+https://[email protected]/kimorkim/sudokuMaker.git"
Expand All @@ -25,13 +33,15 @@
},
"homepage": "https://github.com/kimorkim/sudokuMaker#readme",
"devDependencies": {
"ava": "^0.16.0",
"babel": "^6.5.2",
"babel-core": "^6.14.0",
"babel-loader": "^6.2.5",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-es2015-modules-umd": "^6.12.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-stage-2": "^6.13.0",
"babel-register": "^6.14.0",
"babel-runtime": "^6.11.6",
"core-js": "^2.4.1",
"webpack": "^1.13.2"
Expand Down
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class sudokuMaker {

gameDataCheck(gameData) {
const checkData = {
state: PlayTypes.COMPLETE,
state: PlayTypes.SUCCESS,
box: {},
rows: {},
cols: {}
Expand Down Expand Up @@ -178,6 +178,8 @@ class sudokuMaker {
checkData.state = PlayTypes.FAIL;
} else if(isSolving) {
checkData.state = PlayTypes.SOLVING;
} else {
PlayTypes.state = PlayTypes.SUCCESS;
}

return checkData;
Expand Down
54 changes: 54 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import test from 'ava';
import sudokuMaker from '../dist/sudokuMaker';

const testData = {"inCorrectData":[[[4,8,4],[6,5,1],[2,7,9]],[[2,7,9],[3,8,4],[6,5,1]],[[6,5,1],[2,7,9],[3,8,4]],[[4,3,8],[1,6,5],[9,2,7]],[[9,2,7],[4,3,8],[1,6,5]],[[1,6,5],[9,2,7],[4,3,8]],[[8,4,3],[5,1,6],[7,9,2]],[[7,9,2],[8,4,3],[5,1,6]],[[5,1,6],[7,9,2],[8,4,3]]]};
const failCaseData = {"state":"FAIL","box":{"002":{"_i":0,"_j":0,"_k":2},"000":{"_i":0,"_j":0,"_k":0}},"rows":{"002":{"_i":0,"_j":0,"_k":2},"000":{"_i":0,"_j":0,"_k":0}},"cols":{"300":{"_i":3,"_j":0,"_k":0},"000":{"_i":0,"_j":0,"_k":0}}};

test.before(t => {
if(!('createGame' in sudokuMaker)) {
t.fail('sudokuMaker not have createGame');
}
Object.assign(testData, sudokuMaker.createGame());
})


test('Get GameData', t => {
const gameData = sudokuMaker.createGame();

if(gameData && 'correctData' in gameData && 'data' in gameData) {
t.pass('sudokuMaker Complete Game Create');
} else {
t.fail('Do not Create Game');
}
});

test('GameCheck Test', t => {
t.plan(3);

if(!('gameDataCheck' in sudokuMaker)) {
t.fail('sudokuMaker not have GameData Check');
}

const failCase = sudokuMaker.gameDataCheck(testData.inCorrectData);
const solvingCase = sudokuMaker.gameDataCheck(testData.data);
const successCase = sudokuMaker.gameDataCheck(testData.correctData);

if(successCase && successCase.state === 'SUCCESS') {
t.pass('SUCCESS CHECK COMPLETE');
} else {
t.fail('SUCCESS CHECK FAIL');
}

if(solvingCase && solvingCase.state === 'SOLVING') {
t.pass('SOLVING CHECK COMPLETE');
} else {
t.fail('SOLVING CHECK FAIL');
}

if(failCase && failCase.state === 'FAIL') {
t.deepEqual(failCase, failCaseData, 'FAILCASE CHECK COMPLETE')
} else {
t.fail('FAILCASE CHECK FAIL');
}

});

0 comments on commit 47b924d

Please sign in to comment.