Permalink
Browse files

Added jsTest Driver unit test files.

  • Loading branch information...
a727891 committed May 9, 2013
1 parent 2f280bd commit c5513c8df7d540662ce1ce128655fcf5ad2388b3
Showing with 94 additions and 1 deletion.
  1. +15 −0 FallingBlocks.jstd
  2. +45 −0 test/TestApp.js
  3. +30 −0 test/TestGame.js
  4. +4 −1 test/TestInput.js
View
@@ -0,0 +1,15 @@
+#http://pseudobry.com/js-test-driver-qunit-coverage-requirejs/
+
+load:
+- js/lib/require-jquery.js
+- js/lib/class.js
+
+test:
+- test/*.js
+
+serve:
+- js/main.js
+- js/app.js
+- js/game.js
+- js/input.js
+- js/render.js
View
@@ -0,0 +1,45 @@
+require({
+ baseUrl: "/test/js"
+}, [ "app" ], function (APP) {
+
+ var requestAnimFrame = function(callback){return true;};
+ var app = {};
+ //Define mock objects
+ var game = {
+ updateState: function (input) {
+ return true;
+ }
+ };
+ var input = {
+ parseInput: function (event) {
+ return true;
+ },
+ readInput: function () {
+ return {};
+ }
+ };
+ var renderer = {
+ render: function (isStopped) {
+ return true;
+ }
+ };
+
+ TestCase("TestApp", {
+ setUp: function () {
+ app = new APP();
+ },
+
+ "testAssignObjects":function(){
+ assertTrue('Never see this',true);
+ app.setObjects(game,input,renderer);
+ assertSame('game not set correctly',game,app.game);
+ },
+
+ "testNotifyUserComplete_App":function(){
+ console.info("App tests finished successfully");
+ }
+
+ });
+
+});
+
View
@@ -0,0 +1,30 @@
+require({
+ baseUrl: "/test/js"
+}, ["game"], function ( GAME) {
+ var app = {
+ 'stop': function () {
+ return true;
+ },
+ 'resume': function () {
+ return true;
+ },
+ 'isStopped': false,
+ 'game': {
+ 'ActiveBlock': {
+ 'TypeIndex': 0
+ }
+ }
+ };
+ var game = new GAME(app);
+ TestCase("TestGame", {
+ setUp: function () {
+ },
+
+
+ "testNotifyUserComplete_Game":function(){
+ console.info("Game tests finished successfully");
+ }
+
+ });
+});
+
View
@@ -107,8 +107,11 @@ require({
}
- }
+ },
+ "testNotifyUserComplete_Input":function(){
+ console.info("Input tests finished successfully");
+ }
});
});

0 comments on commit c5513c8

Please sign in to comment.