You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2014/02/03 11:12:27 UTC

[03/22] Fauxton: Split up api.js

http://git-wip-us.apache.org/repos/asf/couchdb/blob/96be583d/src/fauxton/app/core/tests/routeObjectSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/tests/routeObjectSpec.js b/src/fauxton/app/core/tests/routeObjectSpec.js
new file mode 100644
index 0000000..2fca94d
--- /dev/null
+++ b/src/fauxton/app/core/tests/routeObjectSpec.js
@@ -0,0 +1,96 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+define([
+       'api',
+      'testUtils'
+], function (FauxtonAPI, testUtils) {
+  var assert = testUtils.assert,
+      RouteObject = FauxtonAPI.RouteObject;
+
+  describe('RouteObjects', function () {
+
+    describe('renderWith', function () {
+      var TestRouteObject, testRouteObject, mockLayout;
+
+      beforeEach(function () {
+        TestRouteObject = RouteObject.extend({
+          crumbs: ['mycrumbs']
+        });
+
+        testRouteObject = new TestRouteObject();
+        var apiBar = {};
+        apiBar.hide = sinon.spy();
+
+        // Need to find a better way of doing this
+        mockLayout = {
+          setTemplate: sinon.spy(),
+          clearBreadcrumbs: sinon.spy(),
+          setView: sinon.spy(),
+          renderView: sinon.spy(),
+          hooks: [],
+          setBreadcrumbs: sinon.spy(),
+          apiBar: apiBar
+        };
+
+      });
+
+      it('Should set template for first render ', function () {
+        testRouteObject.renderWith('the-route', mockLayout, 'args');
+
+        assert.ok(mockLayout.setTemplate.calledOnce, 'setTempalte was called');
+      });
+
+      it('Should not set template after first render', function () {
+        testRouteObject.renderWith('the-route', mockLayout, 'args');
+
+        testRouteObject.renderWith('the-route', mockLayout, 'args');
+
+        assert.ok(mockLayout.setTemplate.calledOnce, 'SetTemplate not meant to be called');
+      });
+
+      
+      it("Should call establish of routeObject", function () {
+        var establishSpy = sinon.spy(testRouteObject,"establish");
+
+        testRouteObject.renderWith('the-route', mockLayout, 'args');
+        assert.ok(establishSpy.calledOnce, 'Calls establish');
+      });
+
+      it("Should render views", function () {
+        var view = new FauxtonAPI.View(),
+            getViewsSpy = sinon.stub(testRouteObject,"getViews"),
+            viewSpy = sinon.stub(view, "establish");
+        
+        view.hasRendered = false;
+        getViewsSpy.returns({'#view': view});
+
+        testRouteObject.renderWith('the-route', mockLayout, 'args');
+        assert.ok(viewSpy.calledOnce, 'Should render view');
+      });
+
+      it("Should not re-render a view", function () {
+        var view = new FauxtonAPI.View(),
+            getViewsSpy = sinon.stub(testRouteObject,"getViews"),
+            viewSpy = sinon.stub(view, "establish");
+        
+        view.hasRendered = true;
+        getViewsSpy.returns({'#view': view});
+
+        testRouteObject.renderWith('the-route', mockLayout, 'args');
+        assert.notOk(viewSpy.calledOnce, 'Should render view');
+      });
+    });
+
+  });
+
+
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/96be583d/src/fauxton/app/core/utils.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/utils.js b/src/fauxton/app/core/utils.js
new file mode 100644
index 0000000..44945e8
--- /dev/null
+++ b/src/fauxton/app/core/utils.js
@@ -0,0 +1,94 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+
+// This file creates a set of helper functions that will be loaded for all html
+// templates. These functions should be self contained and not rely on any 
+// external dependencies as they are loaded prior to the application. We may
+// want to change this later, but for now this should be thought of as a
+// "purely functional" helper system.
+
+
+define([
+  "jquery",
+  "lodash"
+],
+
+function($, _ ) {
+
+  var onWindowResize = {};
+
+  var utils = {
+    // Thanks to: http://stackoverflow.com/a/2880929
+    getParams: function(queryString) {
+      if (queryString) {
+        // I think this could be combined into one if
+        if (queryString.substring(0,1) === "?") {
+          queryString = queryString.substring(1);
+        } else if (queryString.indexOf('?') > -1) {
+          queryString = queryString.split('?')[1];
+        }
+      }
+      var hash = window.location.hash.split('?')[1];
+      queryString = queryString || hash || window.location.search.substring(1);
+      var match,
+      urlParams = {},
+      pl     = /\+/g,  // Regex for replacing addition symbol with a space
+      search = /([^&=]+)=?([^&]*)/g,
+      decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
+      query  = queryString;
+
+      if (queryString) {
+        while ((match = search.exec(query))) {
+          urlParams[decode(match[1])] = decode(match[2]);
+        }
+      }
+
+      return urlParams;
+    },
+
+    addWindowResize: function(fun, key){
+      onWindowResize[key]=fun;
+      // You shouldn't need to call it here. Just define it at startup and each time it will loop 
+      // through all the functions in the hash.
+      //app.initWindowResize();
+    },
+
+    removeWindowResize: function(key){
+      delete onWindowResize[key];
+      utils.initWindowResize();
+    },
+
+    initWindowResize: function(){
+      //when calling this it should be overriding what was called previously
+      window.onresize = function(e) {
+        // could do this instead of the above for loop
+        _.each(onWindowResize, function (fn) {
+          fn();
+        });
+      };
+    },
+
+    removeSpecialCharacters: function(name){
+      return name.replace(/[^\w\s]/gi,"");
+    },
+
+    safeURLName: function(name){
+      var testName = name || "";
+      var checkforBad = testName.match(/[\$\-/_,+-]/g);
+      return (checkforBad !== null)?encodeURIComponent(name):name;
+    }
+  };
+
+  return utils;
+});
+

http://git-wip-us.apache.org/repos/asf/couchdb/blob/96be583d/src/fauxton/app/main.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/main.js b/src/fauxton/app/main.js
index 6fe9991..9df15c5 100644
--- a/src/fauxton/app/main.js
+++ b/src/fauxton/app/main.js
@@ -13,19 +13,18 @@
 require([
         // Application.
         "app",
-
-        // Main Router.
-        "router"
+        "api",
+        "load_addons"
 ],
 
-function(app, Router) {
+function(app, FauxtonAPI, LoadAddons) {
 
-  // Define your master router on the application namespace and trigger all
-  // navigation from this instance.
-  app.router = new Router();
+  app.addons = LoadAddons.addons;
+  FauxtonAPI.router = app.router = new FauxtonAPI.Router(app.addons);
   // Trigger the initial route and enable HTML5 History API support, set the
   // root folder to '/' by default.  Change in app.js.
   Backbone.history.start({ pushState: false, root: app.root });
+
   // All navigation that is relative should be passed through the navigate
   // method, to be processed by the router. If the link has a `data-bypass`
   // attribute, bypass the delegation completely.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/96be583d/src/fauxton/app/resizeColumns.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/resizeColumns.js b/src/fauxton/app/resizeColumns.js
deleted file mode 100644
index bb50767..0000000
--- a/src/fauxton/app/resizeColumns.js
+++ /dev/null
@@ -1,87 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-
-// This file creates a set of helper functions that will be loaded for all html
-// templates. These functions should be self contained and not rely on any 
-// external dependencies as they are loaded prior to the application. We may
-// want to change this later, but for now this should be thought of as a
-// "purely functional" helper system.
-
-define([
-  "utils"
-],
-
-function(utils) {
-
-  var Resize = function(options){
-    this.options = options;
-    this.options.selectorElements = options.selectorElements || ".window-resizeable";
-  };
-
-  Resize.prototype = {
-    getPrimaryNavWidth: function(){
-      var primaryNavWidth  = $('body').hasClass('closeMenu')? 64:224;
-      return primaryNavWidth;
-    },
-    getPanelWidth: function(){
-      var sidebarWidth = $('#sidebar-content').length > 0 ? $('#sidebar-content').width(): 0;
-      return (this.getPrimaryNavWidth() + sidebarWidth); 
-    },
-    initialize: function(){
-     // $(window).off('resize');
-      var that = this;
-      //add throttler :) 
-      this.lazyLayout = _.debounce(that.onResizeHandler, 300).bind(this);
-      utils.addWindowResize(this.lazyLayout,"animation");
-      utils.initWindowResize();
-      this.onResizeHandler();
-    },
-    updateOptions:function(options){
-      this.options = {};
-      this.options = options;
-      this.options.selectorElements = options.selectorElements || ".window-resizeable";
-    },
-    turnOff:function(){
-      utils.removeWindowResize("animation");
-    },
-    cleanupCallback: function(){
-      this.callback = null;
-    },
-    onResizeHandler: function (){
-      //if there is an override, do that instead
-      if (this.options.onResizeHandler){
-        this.options.onResizeHandler();
-      } else {
-        var combinedWidth = window.innerWidth - this.getPanelWidth(),
-        smallWidthConstraint = ($('#sidebar-content').length > 0)? 470:800,
-        panelWidth; 
-
-        if( combinedWidth > smallWidthConstraint  && combinedWidth < 1400){
-          panelWidth = window.innerWidth - this.getPanelWidth();
-        } else if (combinedWidth < smallWidthConstraint){
-          panelWidth = smallWidthConstraint;
-        } else if(combinedWidth > 1400){
-          panelWidth = 1400;
-        }
-
-        $(this.options.selectorElements).innerWidth(panelWidth);
-      }
-      //if there is a callback, run that
-      if(this.options.callback) {
-        this.options.callback();
-      }
-    } 
-  };
-
-  return Resize;
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/96be583d/src/fauxton/app/router.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/router.js b/src/fauxton/app/router.js
deleted file mode 100644
index 89c60cf..0000000
--- a/src/fauxton/app/router.js
+++ /dev/null
@@ -1,142 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
-       // Load require for use in nested requiring
-       // as per the note in: http://requirejs.org/docs/api.html#multiversion
-       "require",
-
-       // Application.
-       "app",
-
-       // Initialize application
-       "initialize",
-
-       // Load Fauxton API
-       "api",
-
-       // Modules
-       "addons/fauxton/base",
-       // Layout
-       "addons/fauxton/layout",
-
-       "load_addons"
-],
-
-function(req, app, Initialize, FauxtonAPI, Fauxton, Layout, LoadAddons) {
-
-  var beforeUnloads = {};
-
-  var Router = app.router = Backbone.Router.extend({
-    routes: {},
-
-    beforeUnload: function (name, fn) {
-      beforeUnloads[name] = fn;
-    },
-
-    removeBeforeUnload: function (name) {
-      delete beforeUnloads[name];
-    },
-
-    navigate: function (fragment, trigger) {
-      var continueNav  = true,
-          msg = _.find(_.map(beforeUnloads, function (fn) { return fn(); }), function (beforeReturn) {
-            if (beforeReturn) { return true; }
-          });
-
-      if (msg) {
-        continueNav = window.confirm(msg);
-      }
-
-      if (continueNav) {
-        Backbone.Router.prototype.navigate(fragment, trigger);
-      }
-    },
-
-    addModuleRouteObject: function(RouteObject) {
-      var that = this;
-      var masterLayout = this.masterLayout,
-      routeUrls = RouteObject.prototype.getRouteUrls();
-
-      _.each(routeUrls, function(route) {
-        this.route(route, route.toString(), function() {
-          var args = Array.prototype.slice.call(arguments),
-          roles = RouteObject.prototype.getRouteRoles(route),
-          authPromise = app.auth.checkAccess(roles);
-
-          authPromise.then(function () {
-            if (!that.activeRouteObject || !that.activeRouteObject.hasRoute(route)) {
-              if (that.activeRouteObject) {
-                that.activeRouteObject.cleanup();
-              }
-              that.activeRouteObject = new RouteObject(route, masterLayout, args);
-            }
-
-            var routeObject = that.activeRouteObject;
-            routeObject.routeCallback(route, args);
-            routeObject.renderWith(route, masterLayout, args);
-          }, function () {
-            FauxtonAPI.auth.authDeniedCb();
-          });
-
-        }); 
-      }, this);
-    },
-
-    setModuleRoutes: function() {
-      _.each(LoadAddons.addons, function(module) {
-        if (module){
-          module.initialize();
-          // This is pure routes the addon provides
-          if (module.RouteObjects) {
-            _.each(module.RouteObjects, this.addModuleRouteObject, this);
-          }
-        }
-      }, this);
-    },
-
-    initialize: function() {
-      //TODO: It would be nice to handle this with a router
-      this.navBar = app.navBar = new Fauxton.NavBar();
-      this.apiBar = app.apiBar = new Fauxton.ApiBar();
-      this.auth = app.auth = FauxtonAPI.auth;
-      app.session = FauxtonAPI.session;
-
-      app.masterLayout = this.masterLayout = new Layout(this.navBar, this.apiBar);
-      app.footer = new Fauxton.Footer({el: "#footer-content"});
-
-      // NOTE: This must be below creation of the layout
-      // FauxtonAPI header links and others depend on existence of the layout
-      //this.setAddonHooks();
-      this.setModuleRoutes();
-
-      $("#app-container").html(this.masterLayout.el);
-      this.masterLayout.render();
-
-      // TODO: move this to a proper Fauxton.View
-      $.when.apply(null, app.footer.establish()).done(function() {
-        app.footer.render();
-      });
-    },
-
-    triggerRouteEvent: function(event, args) {
-      if (this.activeRouteObject) {
-        var eventArgs = [event].concat(args);
-        this.activeRouteObject.trigger.apply(this.activeRouteObject, eventArgs );
-        this.activeRouteObject.renderWith(eventArgs, this.masterLayout, args);
-      }
-    }
-  });
-
-  return Router;
-
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/96be583d/src/fauxton/app/utils.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/utils.js b/src/fauxton/app/utils.js
deleted file mode 100644
index ded7dac..0000000
--- a/src/fauxton/app/utils.js
+++ /dev/null
@@ -1,66 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-
-// This file creates a set of helper functions that will be loaded for all html
-// templates. These functions should be self contained and not rely on any 
-// external dependencies as they are loaded prior to the application. We may
-// want to change this later, but for now this should be thought of as a
-// "purely functional" helper system.
-
-
-define([
-  "jquery",
-  "lodash"
-],
-
-function($, _ ) {
-
-  var utils = {};
-
-  var onWindowResize = {};
-   
-  utils.addWindowResize = function(fun, key){
-    onWindowResize[key]=fun;
-    // You shouldn't need to call it here. Just define it at startup and each time it will loop 
-    // through all the functions in the hash.
-    //app.initWindowResize();
-  };
-   
-  utils.removeWindowResize = function(key){
-    delete onWindowResize[key];
-    utils.initWindowResize();
-  };
-   
-  utils.initWindowResize = function(){
-  //when calling this it should be overriding what was called previously
-    window.onresize = function(e) {
-       // could do this instead of the above for loop
-      _.each(onWindowResize, function (fn) {
-        fn();
-      });
-    };
-  };
-
-  utils.removeSpecialCharacters = function(name){
-    return name.replace(/[^\w\s]/gi,"");
-  };
-
-  utils.safeURLName = function(name){
-    var testName = name || "";
-    var checkforBad = testName.match(/[\$\-/_,+-]/g);
-    return (checkforBad !== null)?encodeURIComponent(name):name;
-  };
-
-  return utils;
-});
-

http://git-wip-us.apache.org/repos/asf/couchdb/blob/96be583d/src/fauxton/settings.json.default
----------------------------------------------------------------------
diff --git a/src/fauxton/settings.json.default b/src/fauxton/settings.json.default
index cb09eb2..e817b79 100644
--- a/src/fauxton/settings.json.default
+++ b/src/fauxton/settings.json.default
@@ -1,5 +1,6 @@
 {
   "deps": [
+  { "name": "fauxton" },
   { "name": "databases" },
   { "name": "documents" },
   { "name": "pouchdb" },

http://git-wip-us.apache.org/repos/asf/couchdb/blob/96be583d/src/fauxton/tasks/couchserver.js
----------------------------------------------------------------------
diff --git a/src/fauxton/tasks/couchserver.js b/src/fauxton/tasks/couchserver.js
index 5ccbfe1..21c2fcb 100644
--- a/src/fauxton/tasks/couchserver.js
+++ b/src/fauxton/tasks/couchserver.js
@@ -61,7 +61,7 @@ module.exports = function (grunt) {
         // server js from app directory
         filePath = path.join(app_dir, url.replace('/_utils/fauxton/',''));
       } else if (!!url.match(/testrunner/)) {
-        var testSetup = grunt.util.spawn({cmd: 'grunt', grunt: true, args: ['mochaSetup']}, function (error, result, code) {/* log.writeln(String(result));*/ });
+        var testSetup = grunt.util.spawn({cmd: 'grunt', grunt: true, args: ['test_inline']}, function (error, result, code) {/* log.writeln(String(result));*/ });
         testSetup.stdout.pipe(process.stdout);
         testSetup.stderr.pipe(process.stderr);
         filePath = path.join('./test/runner.html');

http://git-wip-us.apache.org/repos/asf/couchdb/blob/96be583d/src/fauxton/test/core/layoutSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/core/layoutSpec.js b/src/fauxton/test/core/layoutSpec.js
deleted file mode 100644
index 4167100..0000000
--- a/src/fauxton/test/core/layoutSpec.js
+++ /dev/null
@@ -1,94 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-define([
-       'addons/fauxton/layout',
-      'testUtils'
-], function (Layout, testUtils) {
-  var assert = testUtils.assert;
-
-  describe("Faxuton Layout", function () {
-    var layout;
-
-    beforeEach(function () {
-      var navBar = new Backbone.View();
-      var apiBar = new Backbone.View();
-      layout = new Layout(navBar, apiBar);
-    });
-
-    describe('#setTemplate', function () {
-
-      it("Should set template without prefix", function () {
-        layout.setTemplate('myTemplate');
-
-        assert.equal(layout.layout.template, 'templates/layouts/myTemplate');
-
-      });
-
-      it("Should set template with prefix", function () {
-        layout.setTemplate({name: 'myTemplate', prefix: 'myPrefix/'});
-
-        assert.equal(layout.layout.template, 'myPrefix/myTemplate');
-      });
-
-      it("Should remove old views", function () {
-        var view = {
-          remove: function () {}
-        };
-
-        layout.layoutViews = {
-          'selector': view
-        };
-
-        var mockRemove = sinon.spy(view, 'remove');
-        layout.setTemplate('myTemplate');
-        assert.ok(mockRemove.calledOnce);
-
-      });
-
-      it("Should render", function () {
-        var mockRender = sinon.spy(layout, 'render');
-
-        layout.setTemplate('myTemplate');
-
-        assert.ok(mockRender.calledOnce);
-
-      });
-
-    });
-
-    describe('#renderView', function () {
-
-      it('Should render existing view', function () {
-        var view = new Backbone.View();
-        var mockRender = sinon.spy(view, 'render');
-        layout.layoutViews = {
-          '#selector': view
-        };
-
-        var out = layout.renderView('#selector');
-
-        assert.ok(mockRender.calledOnce);
-      });
-
-      it('Should return false for non-existing view', function () {
-        var view = new Backbone.View();
-        layout.layoutViews = {
-          'selector': view
-        };
-
-        var out = layout.renderView('wrongSelector');
-        assert.notOk(out, 'No view found');
-      });
-    });
-
-  });
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/96be583d/src/fauxton/test/core/navbarSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/core/navbarSpec.js b/src/fauxton/test/core/navbarSpec.js
deleted file mode 100644
index 3eca6f6..0000000
--- a/src/fauxton/test/core/navbarSpec.js
+++ /dev/null
@@ -1,107 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-define([
-       'addons/fauxton/base',
-      'testUtils'
-], function (Fauxton, testUtils) {
-  var assert = testUtils.assert,
-      NavBar = Fauxton.NavBar;
-
-  describe('NavBar', function () {
-
-    describe('adding links', function () {
-      var navBar;
-
-      beforeEach(function () {
-        navBar = new NavBar();
-        navBar.navLinks = [];
-        navBar.bottomNavLinks = [];
-        navBar.footerNavLinks = [];
-      });
-
-      it('Should add link to navlinks', function () {
-        navBar.addLink({href: '#/test', title: 'Test Title'});
-
-        assert.equal(navBar.navLinks.length, 1);
-        assert.equal(navBar.footerNavLinks.length, 0);
-        assert.equal(navBar.bottomNavLinks.length, 0);
-      });
-
-      it('Should add link to bottom links', function () {
-        navBar.addLink({href: '#/test', bottomNav: true, title: 'Test Title'});
-
-        assert.equal(navBar.bottomNavLinks.length, 1);
-        assert.equal(navBar.navLinks.length, 0);
-        assert.equal(navBar.footerNavLinks.length, 0);
-      });
-
-      it('Should add link to footer links', function () {
-        navBar.addLink({href: '#/test', footerNav: true, title: 'Test Title'});
-
-        assert.equal(navBar.footerNavLinks.length, 1);
-        assert.equal(navBar.bottomNavLinks.length, 0);
-        assert.equal(navBar.navLinks.length, 0);
-      });
-    });
-
-    describe('removing links', function () {
-      var navBar;
-
-      beforeEach(function () {
-        navBar = new NavBar();
-        navBar.navLinks = [];
-        navBar.bottomNavLinks = [];
-        navBar.footerNavLinks = [];
-        navBar.addLink({
-          href: '#/test', 
-          footerNav: true, 
-          title: 'Test Title Footer'
-        });
-
-        navBar.addLink({
-          href: '#/test', 
-          bottomNav: true, 
-          title: 'Test Title Bottom'
-        });
-
-        navBar.addLink({
-          href: '#/test', 
-          title: 'Test Title'
-        });
-      });
-
-      it("should remove links from list", function () {
-        navBar.removeLink({
-          title: 'Test Title Footer',
-          footerNav: true
-        });
-
-        assert.equal(navBar.footerNavLinks.length, 0);
-        assert.equal(navBar.bottomNavLinks.length, 1);
-        assert.equal(navBar.navLinks.length, 1);
-      });
-
-      it("Should call render after removing links", function () {
-        var renderSpy = sinon.stub(navBar,'render');
-
-        navBar.removeLink({
-          title: 'Test Title Footer',
-          footerNav: true
-        });
-
-        assert.ok(renderSpy.calledOnce);
-      });
-
-    });
-  });
-
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/96be583d/src/fauxton/test/core/paginateSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/core/paginateSpec.js b/src/fauxton/test/core/paginateSpec.js
deleted file mode 100644
index d05b322..0000000
--- a/src/fauxton/test/core/paginateSpec.js
+++ /dev/null
@@ -1,109 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-define([
-       'api',
-       'addons/fauxton/components',
-       'addons/documents/resources',
-       'testUtils',
-       'app'
-], function (FauxtonAPI, Views, Models, testUtils, app) {
-  var assert = testUtils.assert,
-  ViewSandbox = testUtils.ViewSandbox;
-
-
-  describe('IndexPaginate', function () {
-    var viewSandbox, paginate, collection, navigateMock;
-    beforeEach(function () {
-      app.router = {
-        navigate: function () {}
-      };
-
-      collection = new Models.IndexCollection([{
-        id:'myId1',
-        doc: 'num1'
-      },
-      {
-        id:'myId2',
-        doc: 'num2'
-      }], {
-        database: {id: 'databaseId'},
-        design: '_design/myDoc'
-      });
-
-      paginate = new Views.IndexPagination({
-        collection: collection,
-        previousUrlfn: function () {},
-        nextUrlfn: function () {},
-        canShowPreviousfn: function () { return true; },
-        canShowNextfn: function () { return true;}
-      });
-      viewSandbox = new ViewSandbox();
-      viewSandbox.renderView(paginate); 
-    });
-
-    afterEach(function () {
-      viewSandbox.remove();
-    });
-
-    describe('#next', function () {
-      beforeEach(function () {
-        //do this so it doesn't throw an error on other unwired up components
-        FauxtonAPI.triggerRouteEvent = function () {};
-        //FauxtonAPI.triggerRouteEvent.restore && FauxtonAPI.triggerRouteEvent.restore();
-        //FauxtonAPI.navigate.restore && FauxtonAPI.navigate.restore(); 
-      });
-
-      it('Should navigate', function () {
-        var navigateMock = sinon.spy(FauxtonAPI, 'navigate');
-
-        paginate.$('a#next').click();
-
-        assert.ok(navigateMock.calledOnce);
-        FauxtonAPI.navigate.restore();
-      });
-
-      it('Should trigger routeEvent', function () {
-        var navigateMock = sinon.spy(FauxtonAPI, 'triggerRouteEvent');
-
-        paginate.$('a#next').click();
-
-        assert.ok(navigateMock.calledOnce);
-        FauxtonAPI.triggerRouteEvent.restore();
-      });
-
-    });
-
-
-    describe('#previous', function () {
-
-      it('Should navigate', function () {
-        var navigateMock = sinon.spy(FauxtonAPI, 'navigate');
-
-        paginate.$('a#previous').click();
-
-        assert.ok(navigateMock.calledOnce);
-        FauxtonAPI.navigate.restore();
-      });
-
-      it('Should trigger routeEvent', function () {
-        var navigateMock = sinon.spy(FauxtonAPI, 'triggerRouteEvent');
-
-        paginate.$('a#previous').click();
-
-        assert.ok(navigateMock.calledOnce);
-        FauxtonAPI.triggerRouteEvent.restore();
-      });
-
-    });
-
-  });
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/96be583d/src/fauxton/test/core/routeObjectSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/core/routeObjectSpec.js b/src/fauxton/test/core/routeObjectSpec.js
deleted file mode 100644
index 987d5b7..0000000
--- a/src/fauxton/test/core/routeObjectSpec.js
+++ /dev/null
@@ -1,105 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-define([
-       'api',
-      'testUtils'
-], function (FauxtonAPI, testUtils) {
-  var assert = testUtils.assert,
-      RouteObject = FauxtonAPI.RouteObject;
-
-  describe('RouteObjects', function () {
-
-    describe('renderWith', function () {
-      var TestRouteObject, testRouteObject, mockLayout;
-
-      beforeEach(function () {
-        TestRouteObject = RouteObject.extend({
-          crumbs: ['mycrumbs']
-        });
-
-        testRouteObject = new TestRouteObject();
-        var apiBar = {};
-        apiBar.hide = sinon.spy();
-
-        // Need to find a better way of doing this
-        mockLayout = {
-          setTemplate: sinon.spy(),
-          clearBreadcrumbs: sinon.spy(),
-          setView: sinon.spy(),
-          renderView: sinon.spy(),
-          hooks: [],
-          setBreadcrumbs: sinon.spy(),
-          apiBar: apiBar
-        };
-
-      });
-
-      it('Should set template for first render ', function () {
-        testRouteObject.renderWith('the-route', mockLayout, 'args');
-
-        assert.ok(mockLayout.setTemplate.calledOnce, 'setTempalte was called');
-      });
-
-      it('Should not set template after first render', function () {
-        testRouteObject.renderWith('the-route', mockLayout, 'args');
-
-        testRouteObject.renderWith('the-route', mockLayout, 'args');
-
-        assert.ok(mockLayout.setTemplate.calledOnce, 'SetTemplate not meant to be called');
-      });
-
-      it('Should clear breadcrumbs', function () {
-        testRouteObject.renderWith('the-route', mockLayout, 'args');
-        assert.ok(mockLayout.clearBreadcrumbs.calledOnce, 'Clear Breadcrumbs called');
-      });
-
-      it('Should set breadcrumbs when breadcrumbs exist', function () {
-        testRouteObject.renderWith('the-route', mockLayout, 'args');
-        assert.ok(mockLayout.setBreadcrumbs.calledOnce, 'Set Breadcrumbs was called');
-      });
-
-      it("Should call establish of routeObject", function () {
-        var establishSpy = sinon.spy(testRouteObject,"establish");
-
-        testRouteObject.renderWith('the-route', mockLayout, 'args');
-        assert.ok(establishSpy.calledOnce, 'Calls establish');
-      });
-
-      it("Should render views", function () {
-        var view = new FauxtonAPI.View(),
-            getViewsSpy = sinon.stub(testRouteObject,"getViews"),
-            viewSpy = sinon.stub(view, "establish");
-        
-        view.hasRendered = false;
-        getViewsSpy.returns({'#view': view});
-
-        testRouteObject.renderWith('the-route', mockLayout, 'args');
-        assert.ok(viewSpy.calledOnce, 'Should render view');
-      });
-
-      it("Should not re-render a view", function () {
-        var view = new FauxtonAPI.View(),
-            getViewsSpy = sinon.stub(testRouteObject,"getViews"),
-            viewSpy = sinon.stub(view, "establish");
-        
-        view.hasRendered = true;
-        getViewsSpy.returns({'#view': view});
-
-        testRouteObject.renderWith('the-route', mockLayout, 'args');
-        assert.notOk(viewSpy.calledOnce, 'Should render view');
-      });
-    });
-
-  });
-
-
-});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/96be583d/src/fauxton/test/mocha/testUtils.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/mocha/testUtils.js b/src/fauxton/test/mocha/testUtils.js
index f9643e8..2c418f9 100644
--- a/src/fauxton/test/mocha/testUtils.js
+++ b/src/fauxton/test/mocha/testUtils.js
@@ -11,11 +11,12 @@
 // the License.
 
 define([
+       "api",
        "chai",
        "sinon-chai",
        "underscore"
 ],
-function(chai, sinonChai) {
+function(FauxtonAPI,chai, sinonChai) {
   chai.use(sinonChai);
 
   var ViewSandbox = function () {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/96be583d/src/fauxton/test/test.config.underscore
----------------------------------------------------------------------
diff --git a/src/fauxton/test/test.config.underscore b/src/fauxton/test/test.config.underscore
index dda16f2..5cebe78 100644
--- a/src/fauxton/test/test.config.underscore
+++ b/src/fauxton/test/test.config.underscore
@@ -5,6 +5,7 @@ require.config(
 );
 
 require([
+        "app",
         <% _.each(testFiles, function (test) {%>
            '../<%= test %>',
         <% }) %>