Skip to content
This repository has been archived by the owner on Aug 9, 2018. It is now read-only.

Commit

Permalink
Merge pull request #12 from kshay/master
Browse files Browse the repository at this point in the history
Override ngAnimate, which dies in server context with no $rootElement
  • Loading branch information
kshay committed Jul 23, 2014
2 parents aa2af92 + 1a666ed commit f896b39
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/ngoverrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ function registerModule(context) {
// depend on it but it makes no sense to run server-defined routes *on* the server.
context.module('sdr', []);

// an app that depends on ngAnimate will fail on the absence of $rootElement in unbootstrapped
// server context, and animation is not relevant on the server, so we just override it.
context.module('ngAnimate', []);

// we depend on ngRoute here to be sure that, even if the application has provided the "real"
// ngRoute module, we'll always register after it and get to override $route.
var module = context.module('angularjs-server', ['ng', 'ngRoute']);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angularjs-server",
"version": "0.0.20",
"version": "0.0.21",
"description": "A specialized server for AngularJS applications",
"author": "Martin Atkins <[email protected]>",
"keywords": ["angularjs"],
Expand Down
12 changes: 11 additions & 1 deletion tests/wrap_middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var path = require('path');

exports.testWrapMiddleware = function (test) {
test.expect(11);
test.expect(13);
var angularServer = require('../lib/main.js');

var server = angularServer.Server(
Expand Down Expand Up @@ -43,6 +43,16 @@ exports.testWrapMiddleware = function (test) {
'angularjs-server module registered'
);

test.ok(
angular.modulesRegistered.indexOf('ngRoute') !== -1,
'fake ngRoute module registered'
);

test.ok(
angular.modulesRegistered.indexOf('ngAnimate') !== -1,
'fake ngAnimate module registered'
);

test.ok(
angular.requestsRegistered.length === 1,
'nodejs request was registered exactly once'
Expand Down

0 comments on commit f896b39

Please sign in to comment.