Created
September 11, 2015 16:16
-
-
Save greyaperez/ee8132135d4dd2062233 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('WidgetFactory', function () { | |
var Factory; | |
var $rootScope; | |
var $q; | |
var mockDI = { | |
index: [ | |
'MyConstants', | |
'MyFactory', | |
'MyService' | |
], | |
spies: {}, | |
deferred: {} | |
}; | |
beforeEach(module('myModule')); | |
beforeEach(module(function ($provide) { | |
_.forEach(mockDI.index, function (name) { | |
$provide.value(name, mockDI.spies[name]); | |
}); | |
})); | |
beforeEach(inject(function (_$rootScope_, _$q_, WidgetFactory) { | |
// Useful for Triggering Digests After Promises Resolved thru $rootScope.$apply() | |
$rootScope = _$rootScope_; | |
$q = _$q_; | |
/* Setup Non-Angular Injected Mock Resources */ | |
_.forEach(mockDI.index, function (name) { | |
// Defer Resource Value | |
mockDI.deferred[name] = $q.defer(); | |
mockDI.spies[name] = jasmine.createSpy(name).and.returnValue(mockDI.deferred[name].promise); | |
}); | |
Factory = WidgetFactory; | |
})); | |
it('should have the factory defined', function (){ | |
expect(Factory).toBeDefined(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment