Asserting args calls from spyOn method calls using jasmine karma on $broadcast

Posted: March 20, 2015 in web
...
it('should successfully', inject(function (registerValidValues, registerSucess) {
        spyOn($rootScope, '$broadcast').and.callThrough();
        controller();
        $httpBackend.flush();
        expect($rootScope.$broadcast.calls.mostRecent().args[0]).toMatch('popup');
        expect($rootScope.$broadcast.calls.mostRecent().args[1]).toMatch('info');
        expect($rootScope.$broadcast.calls.mostRecent().args[2]).toMatch(registerSucess.message);
    }));
...


$rootScope.$broadcast('popup', 'info', data.message, {title: 'Confirmation'});

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s