Skip to content

Commit

Permalink
feat: capture window.alert
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtajina committed Jul 20, 2013
1 parent 15d80f4 commit 284c4f5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions static/karma.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ var Karma = function(socket, context, navigator, location) {
contextWindow.dump = function() {
self.log('dump', arguments);
};

contextWindow.alert = function(msg) {
self.log('alert', [msg]);
};
};

this.log = function(type, args) {
Expand Down
17 changes: 17 additions & 0 deletions test/client/karma.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,23 @@ describe('karma', function() {
});


describe('setupContext', function() {
it('should capture alert', function() {
spyOn(k, 'log');

var mockWindow = {
alert: function() {
throw 'Alert was not patched!';
}
};

k.setupContext(mockWindow);
mockWindow.alert('What?');
expect(k.log).toHaveBeenCalledWith('alert', ['What?']);
})
});


describe('store', function() {

it('should be getter/setter', function() {
Expand Down

0 comments on commit 284c4f5

Please sign in to comment.