Skip to content

Instantly share code, notes, and snippets.

@bclinkinbeard
Created October 28, 2013 19:16
Show Gist options
  • Save bclinkinbeard/7202844 to your computer and use it in GitHub Desktop.
Save bclinkinbeard/7202844 to your computer and use it in GitHub Desktop.
// this would actually be in a beforeEach or something
// just haven't done that yet
var angular = require('angular');
var app = angular.module('app', [])
.directive('someDirective', require('./myDirective'));
module.exports = app;
module.exports = function () {
return function (scope, elem) {
elem.addClass('fizzbuzz');
};
}
var test = require('tape'),
proxyquire = require('proxyquire').noCallThru(),
angular = require('angular-node')(),
app = proxyquire('./app', {'angular': angular});
inject = angular.injector(['ng', 'app']).invoke;
test('someDirective', function (t) {
var el;
inject(function($rootScope, $compile, $document) {
el = angular.element('<div some-directive>{{ 7 + 5 }}</div>');
el = $compile(el)($rootScope);
$rootScope.$digest();
})
t.true(el.hasClass('fizzbuzz'), 'fizzbuzz class present');
t.equal(+el.html(), 12, 'YESSSS');
t.end();
});
@jamestalmage
Copy link

I don't think you need the trailing () in require('angular-node')(), this was written a long time ago, so I'm guessing things have changed since then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment