Skip to content

Instantly share code, notes, and snippets.

@xrd
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save xrd/8923697 to your computer and use it in GitHub Desktop.

Select an option

Save xrd/8923697 to your computer and use it in GitHub Desktop.
Firebase mocking in AngularJS
...
var mockFirebase = mockSimpleLogin = undefined;
function generateMockFirebaseSupport() { // <1>
mockFirebase = function() {};
mockSimpleLogin = function() {
return {
'$login': function() {
return { then: function( cb ) {
cb( { name: "someUser",
accessToken: "abcdefghi" } );
} };
}
}
};
}
var $timeout;
beforeEach( inject( function ($controller, $rootScope, $injector ) {
generateMockFirebaseSupport(); // <2>
$timeout = $injector.get( '$timeout' );
scope = $rootScope.$new();
ctrl = $controller( "GithubCtrl", { $scope: scope, Github: ghs, '$timeout': $timeout, '$window': prompter, '$firebase': mockFirebase, '$firebaseSimpleLogin': mockSimpleLogin } ); // <3>
} ) );
...
var Firebase = function (url) {
}
angular.module( 'firebase', [] );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment