couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [7/7] git commit: updated refs/heads/fauxton-test-framework to 251a7ef
Date Wed, 17 Jul 2013 16:12:33 GMT
add some tests for Routeobject


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/251a7eff
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/251a7eff
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/251a7eff

Branch: refs/heads/fauxton-test-framework
Commit: 251a7eff7fa61a1181fc5d7139922822ff19c95a
Parents: 3021090
Author: Garren Smith <garren.smith@gmail.com>
Authored: Wed Jul 17 18:11:43 2013 +0200
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Wed Jul 17 18:11:43 2013 +0200

----------------------------------------------------------------------
 src/fauxton/Gruntfile.js                 |  6 +--
 src/fauxton/test/core/routeObjectSpec.js | 68 +++++++++++++++++++++++++++
 src/fauxton/test/test.config.js          |  2 +
 3 files changed, 73 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/251a7eff/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
index 474030f..3992d91 100644
--- a/src/fauxton/Gruntfile.js
+++ b/src/fauxton/Gruntfile.js
@@ -119,7 +119,7 @@ module.exports = function(grunt) {
     // https://github.com/cowboy/grunt/blob/master/docs/task_lint.md
     lint: {
       files: [
-        "build/config.js", "app/**/*.js"
+        "build/config.js", "app/**/*.js" 
       ]
     },
 
@@ -136,7 +136,7 @@ module.exports = function(grunt) {
     // override inside main.js needs to test for them so as to not accidentally
     // route.
     jshint: {
-      all: ['app/**/*.js', 'Gruntfile.js'],
+      all: ['app/**/*.js', 'Gruntfile.js', "test/core/*.js"],
       options: {
         scripturl: true,
         evil: true
@@ -302,7 +302,7 @@ module.exports = function(grunt) {
 
     mochaSetup: {
       default: {
-        files: { src: helper.watchFiles(['[Ss]pec.js'], ['./app/**/*[Ss]pec.js'])},
+        files: { src: helper.watchFiles(['[Ss]pec.js'], ['./test/core/**/*[Ss]pec.js', './app/**/*[Ss]pec.js'])},
         template: 'test/test.config.underscore',
         config: './app/config.js'
       }

http://git-wip-us.apache.org/repos/asf/couchdb/blob/251a7eff/src/fauxton/test/core/routeObjectSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/core/routeObjectSpec.js b/src/fauxton/test/core/routeObjectSpec.js
new file mode 100644
index 0000000..7fdb719
--- /dev/null
+++ b/src/fauxton/test/core/routeObjectSpec.js
@@ -0,0 +1,68 @@
+define([
+       'api',
+       'chai'
+], function (FauxtonAPI, chai) {
+  var assert = chai.assert,
+      RouteObject = FauxtonAPI.RouteObject;
+
+  describe('RouteObjects', function () {
+
+    describe('renderWith', function () {
+      var TestRouteObject, testRouteObject, mockLayout;
+
+      beforeEach(function () {
+        TestRouteObject = RouteObject.extend({
+          crumbs: ['mycrumbs']
+        });
+
+        testRouteObject = new TestRouteObject();
+
+        mockLayout = {
+          called: false,
+          clearBreadcumbsCalled: false,
+          setBreadcumbsCalled: false,
+          setTemplate: function (layout) {
+            this.called = true;
+          },
+
+          clearBreadcrumbs: function () {
+            this.clearBreadcumbsCalled = true;
+
+          },
+
+          setBreadcrumbs: function () {
+            this.setBreadcumbsCalled = true;
+          }
+        };
+      });
+
+      it('Should set template for first render ', function () {
+        testRouteObject.renderWith('the-route', mockLayout, 'args');
+
+        assert.ok(mockLayout.called, 'setTempalte was called');
+      });
+
+      it('Should not set template after first render', function () {
+        testRouteObject.renderWith('the-route', mockLayout, 'args');
+
+        mockLayout.called = false;
+        testRouteObject.renderWith('the-route', mockLayout, 'args');
+
+        assert.notOk(mockLayout.called, 'SetTemplate not meant to be called');
+      });
+
+      it('Should clear breadcrumbs', function () {
+        testRouteObject.renderWith('the-route', mockLayout, 'args');
+        assert.ok(mockLayout.clearBreadcumbsCalled, 'Clear Breadcrumbs called');
+      });
+
+      it('Should set breadcrumbs', function () {
+        testRouteObject.renderWith('the-route', mockLayout, 'args');
+        assert.ok(mockLayout.setBreadcumbsCalled, 'Set Breadcrumbs was called');
+      });
+    });
+
+  });
+
+
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/251a7eff/src/fauxton/test/test.config.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/test.config.js b/src/fauxton/test/test.config.js
index 7e6e487..54f976e 100644
--- a/src/fauxton/test/test.config.js
+++ b/src/fauxton/test/test.config.js
@@ -58,6 +58,8 @@ require.config(
 
 require([
         
+           '.././test/core/routeObjectSpec.js',
+        
            '.././app/addons/logs/tests/logSpec.js',
         
 ], function() {


Mime
View raw message