Hi,

I am trying to do the same in Jasmine. Could you help me?

Ankit

On Wednesday, March 19, 2014 at 5:34:38 AM UTC+5:30, Vitaly wrote:
>
> I made working tests for me. Here there are:
>
> describe('chromeStorageApi', function(){
>     var mockWindow, chromeStorageApi;
>
>     beforeEach(module('myApp'));
>
>     beforeEach(function(){
>         mockWindow = {
>             chrome:{
>                 storage:{
>                     local: sinon.stub({
>                         set: function(){ },
>                         get: function(){ },
>                         remove: function(){ },
>                         clear: function(){ }
>                     })
>                 }
>             },
>             addEventListener: function(){    }
>         }
>         module(function($provide){
>             $provide.value('$window', mockWindow);
>         })
>     })
>
>     beforeEach(inject(function(_chromeStorageApi_){
>         chromeStorageApi =_chromeStorageApi_;
>     }))
>
>     it('should be able to set data to the storage', function(){
>         chromeStorageApi.set({'key':'value'}, function(){ }());
>         expect(mockWindow.chrome.storage.local.set).toHaveBeenCalled();
>         
> expect(mockWindow.chrome.storage.local.set).toHaveBeenCalledWith({'key':'value'},
>  function(){ }());
>
>     });
>
>     it('should be able to get data from the storage', function(){
>         chromeStorageApi.get('key', function(){ });
>         expect(mockWindow.chrome.storage.local.get).toHaveBeenCalled();
>         
> expect(mockWindow.chrome.storage.local.get).toHaveBeenCalledWith('key');
>     })})
>
> I am using sinonJS <http://sinonjs.org/> to create stub with methods. I 
> hope it will be helpful for someone.
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to