Permalink
Browse files

Add challenge testing

  • Loading branch information...
1 parent bde6b81 commit 921080f3d2ca71985060a2273d72257c0a35c6e4 @BerkeleyTrue BerkeleyTrue committed Nov 2, 2015
View
@@ -1,7 +1,6 @@
language: node_js
node_js:
- - 'node'
- - '1.6.4'
+ - '4.2.1'
sudo: false
View
@@ -13,7 +13,11 @@
"prestart-production": "bower cache clean && bower install && gulp build",
"start-production": "node pm2Start",
"lint": "eslint --ext=.js,.jsx .",
- "test": "gulp test-challenges"
+ "lint-challenges": "jsonlint -q seed/challenges/*.json",
+ "lint-nonprofits": "jsonlint -q seed/nonprofits.json",
+ "test-challenges": "babel-node seed/test-challenges.js | tnyan",
+ "pretest": "npm run lint-challenges && npm run lint-nonprofits",
+ "test": "npm run test-challenges"
},
"license": "(BSD-3-Clause AND CC-BY-SA-4.0)",
"dependencies": {
@@ -124,11 +128,14 @@
"chai": "~1.10.0",
"envify": "^3.4.0",
"istanbul": "^0.3.15",
+ "jsonlint": "^1.6.2",
"loopback-explorer": "^1.7.2",
"loopback-testing": "^1.1.0",
"mocha": "~2.0.1",
"multiline": "~1.0.1",
"supertest": "~0.15.0",
+ "tap-nyan": "0.0.2",
+ "tape": "^4.2.2",
"vinyl-source-stream": "^1.1.0"
}
}
@@ -157,7 +157,6 @@
"Global Object"
],
"solutions": [
- "var VALUES = [1, 5, 10, 25, 100, 500, 1000, 2000, 10000];\n\nfunction drawer(price, cash, cid) {\n cash = ~~(cash * 100);\n price = ~~(price * 100);\n var diff = cash-price;\n cid.forEach(function(c) {\n c[1] = ~~(c[1] * 100);\n });\n var totalCid = cid.reduce(function(a, c) {\n return a + c[1];\n }, 0);\n if (diff > totalCid) {\n return \"Insufficient Funds\";\n }\n if (diff === totalCid) {\n return \"Closed\";\n }\n \n var change = []; \n var index = cid.length;\n while (diff > 0 && --index > -1) {\n var t = 0;\n var value = VALUES[index];\n while (diff >= value && cid[index][1] > 0) {\n t += value;\n cid[index][1] -= value;\n diff -= value;\n }\n if (t) {\n change.push([cid[index][0], t/100]);\n }\n console.log(JSON.stringify(change));\n }\n // Here is your change, ma'am.\n return change;\n}\n\n// Example cash-in-drawer array:\n// [['PENNY', 1.01],\n// ['NICKEL', 2.05],\n// ['DIME', 3.10],\n// ['QUARTER', 4.25],\n// ['ONE', 90.00],\n// ['FIVE', 55.00],\n// ['TEN', 20.00],\n// ['TWENTY', 60.00],\n// ['ONE HUNDRED', 100.00]]\n\ndrawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]);\n"
],
"type": "bonfire",
"challengeType": 5,
@@ -14,7 +14,12 @@
],
"type": "waypoint",
"challengeType": 2,
- "tests": [],
+ "tests": [
+ "assert(true, 'No test needed');"
+ ],
+ "solutions": [
+ "/* no test needed */"
+ ],
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
@@ -37,7 +42,12 @@
],
"type": "waypoint",
"challengeType": 2,
- "tests": [],
+ "tests": [
+ "assert(true, 'No test needed');"
+ ],
+ "solutions": [
+ "/* no test needed */"
+ ],
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
@@ -60,7 +70,12 @@
],
"type": "waypoint",
"challengeType": 2,
- "tests": [],
+ "tests": [
+ "assert(true, 'No test needed');"
+ ],
+ "solutions": [
+ "/* no test needed */"
+ ],
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
@@ -82,7 +97,12 @@
],
"type": "waypoint",
"challengeType": 2,
- "tests": [],
+ "tests": [
+ "assert(true, 'No test needed');"
+ ],
+ "solutions": [
+ "/* no test needed */"
+ ],
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
@@ -105,7 +125,12 @@
],
"type": "waypoint",
"challengeType": 2,
- "tests": [],
+ "tests": [
+ "assert(true, 'No test needed');"
+ ],
+ "solutions": [
+ "/* no test needed */"
+ ],
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
@@ -116,7 +116,7 @@
"Arithmetic Operators"
],
"solutions": [
- "function factorialize(num) {\n return num === 1 ? 1 : num * factorialize(num-1);\n}\n\nfactorialize(5);\n"
+ "function factorialize(num) {\n return num < 1 ? 1 : num * factorialize(num-1);\n}\n\nfactorialize(5);\n"
],
"type": "bonfire",
"challengeType": 5,
@@ -169,7 +169,6 @@
"String.toLowerCase()"
],
"solutions": [
- "function palindrome(str) {\n var a = str.toLowerCase().replace(/[^a-z]/g, '');\n console.log(a.split('').reverse().join(''));\n return a == a.split('').reverse().join('');\n}\n\n\n\npalindrome(\"eye\");\npalindrome(\"A man, a plan, a canal. Panama\");\n"
],
"type": "bonfire",
"challengeType": 5,
@@ -417,7 +416,6 @@
"String.slice()"
],
"solutions": [
- "function truncate(str, num) {\n if (str.length > num) {\n return str.substring(0, num-3) + '...';\n }\n return str;\n}\n\ntruncate('A-tisket a-tasket A green and yellow basket', 11);\n"
],
"type": "bonfire",
"challengeType": 5,
@@ -663,9 +661,7 @@
"MDNlinks": [
"Array.sort()"
],
- "solutions": [
- "function where(arr, num) {\n // Find my place in this sorted array.\n return num;\n}\n\nwhere([40, 60], 50);\n"
- ],
+ "solutions": [],
"tests": [
"assert(where([10, 20, 30, 40, 50], 35) === 3, 'message: <code>where([10, 20, 30, 40, 50], 35)</code> should return <code>3</code>.');",
"assert(where([10, 20, 30, 40, 50], 30) === 2, 'message: <code>where([10, 20, 30, 40, 50], 30)</code> should return <code>2</code>.');",
Oops, something went wrong.

0 comments on commit 921080f

Please sign in to comment.