I am having trouble testing an angular service used inside of the link function.
My service Global Passes an anonymous function as the second with a value as its argument. Ex...
$scope.gallery = [];
Global('PhotoGallery', function (PhotoGallery) {
$scope.gallery = PhotoGallery;
});
I need to test that $scope.gallery is set to equal PhotoGallery; Inside of my spec I used window to set a value and pass it in as the first argument.
it('should set PhotoGalleryVM equal to $scope.PhotoGallery', function() {
window.thisIsATest = 'Test';
Globals('thisIsATest', function(thisisATest) {
console.log('this is a test',thisisATest); //Logs: Test})
});
// tried calling haGlobals as a method, but this didn't work
haGlobals(thisIsATest);
// returns an empty array []
expect(scope.gallery).to.equal('Test');
});
I am using bard js to inject the service
bard.inject(Global)
Aucun commentaire:
Enregistrer un commentaire