diff options
author | Garren Smith <garren.smith@gmail.com> | 2013-07-17 18:11:43 +0200 |
---|---|---|
committer | Garren Smith <garren.smith@gmail.com> | 2013-07-17 18:11:43 +0200 |
commit | 251a7eff7fa61a1181fc5d7139922822ff19c95a (patch) | |
tree | 42904117d2de25b2c40619f5ac396347bab56a63 | |
parent | 302109092b45c4a72f2dd15fded97b54c329ad45 (diff) | |
download | couchdb-251a7eff7fa61a1181fc5d7139922822ff19c95a.tar.gz |
add some tests for Routeobject
-rw-r--r-- | src/fauxton/Gruntfile.js | 6 | ||||
-rw-r--r-- | src/fauxton/test/core/routeObjectSpec.js | 68 | ||||
-rw-r--r-- | src/fauxton/test/test.config.js | 2 |
3 files changed, 73 insertions, 3 deletions
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js index 474030fcf..3992d9143 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' } diff --git a/src/fauxton/test/core/routeObjectSpec.js b/src/fauxton/test/core/routeObjectSpec.js new file mode 100644 index 000000000..7fdb719fe --- /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'); + }); + }); + + }); + + +}); diff --git a/src/fauxton/test/test.config.js b/src/fauxton/test/test.config.js index 7e6e4874c..54f976e1d 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() { |