Skip to content

Commit

Permalink
test(client): refactor the unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtajina committed Dec 7, 2013
1 parent 9f0abfd commit c96d78b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/client/karma.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var MockSocket = require('./mocks').Socket;


describe('Karma', function() {
var socket, k, spyStart, windowNavigator, windowLocation, spywindowOpener;
var socket, k, spyStart, windowNavigator, windowLocation, spyWindowOpener;

var setTransportTo = function(transportName) {
socket._setTransportNameTo(transportName);
Expand All @@ -15,10 +15,9 @@ describe('Karma', function() {
socket = new MockSocket();
windowNavigator = {};
windowLocation = {search: ''};
spywindowOpener = spyOn(window, 'open').andReturn({});
k = new Karma(socket, {}, window.open, windowNavigator, windowLocation);
spyWindowOpener = jasmine.createSpy('window.open').andReturn({});
k = new Karma(socket, {}, spyWindowOpener, windowNavigator, windowLocation);
spyStart = spyOn(k, 'start');

});


Expand All @@ -34,6 +33,7 @@ describe('Karma', function() {
expect(spyStart).toHaveBeenCalledWith(config);
});


it('should open a new window when useIFrame is false', function() {
var config = {
useIframe: false
Expand All @@ -44,7 +44,7 @@ describe('Karma', function() {

k.loaded();
expect(spyStart).toHaveBeenCalledWith(config);
expect(spywindowOpener).toHaveBeenCalledWith('about:blank');
expect(spyWindowOpener).toHaveBeenCalledWith('about:blank');
});


Expand Down Expand Up @@ -117,6 +117,7 @@ describe('Karma', function() {
socket.on('result', spyResult);
});


it('should buffer results when polling', function() {
setTransportTo('xhr-polling');

Expand Down Expand Up @@ -228,6 +229,7 @@ describe('Karma', function() {
});
});


it('should clean the result buffer before completing', function() {
var spyResult = jasmine.createSpy('onResult');
socket.on('result', spyResult);
Expand Down

0 comments on commit c96d78b

Please sign in to comment.