Skip to content

Instantly share code, notes, and snippets.

@deyceg
Created January 9, 2015 15:10
Show Gist options
  • Save deyceg/43b9b95f0490522d4101 to your computer and use it in GitHub Desktop.
Save deyceg/43b9b95f0490522d4101 to your computer and use it in GitHub Desktop.
describe('services', function() {
beforeEach(module('ibeApp'));
var $injector;
var SessionService;
var mockLocalStorage;
beforeEach(function($provide) {
mockLocalStorage = {
setItem: function(key, value){},
getItem: function(key){}
};
$provide.value('StorageBackend', mockLocalStorage);
})
beforeEach(inject(function(_SessionService_, _$injector_){
SessionService = _SessionService_;
spyOn(mockLocalStorage, 'setItem');
spyOn(mockLocalStorage, 'getItem');
}));
describe('SessionService', function() {
it('Gets and sets data', function() {
SessionService.set('name', 'edward');
expect(SessionService.get('name')).toMatch('edward');
});
//it('Uses localStorage', function() {
// SessionService.set('name', 'josh');
// SessionService.save();
// expect(mockLocalStorage).toHaveBeenCalledWith({ 'name': 'josh' });
//});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment