2014-11-21 07:33:22 -05:00
|
|
|
'use strict';
|
|
|
|
|
2014-12-04 10:24:42 -05:00
|
|
|
describe('Status Service unit test', function() {
|
|
|
|
var status, logInfoStub, rootScope, broadcastSpy;
|
2014-11-21 07:33:22 -05:00
|
|
|
|
|
|
|
beforeEach(function() {
|
2014-12-04 10:24:42 -05:00
|
|
|
angular.module('status-test', ['woUtil']);
|
|
|
|
angular.mock.module('status-test');
|
2014-11-21 07:33:22 -05:00
|
|
|
angular.mock.inject(function($injector, axe) {
|
|
|
|
logInfoStub = sinon.stub(axe, 'info');
|
2014-12-04 10:24:42 -05:00
|
|
|
status = $injector.get('status');
|
2014-11-26 15:12:40 -05:00
|
|
|
rootScope = $injector.get('$rootScope');
|
|
|
|
broadcastSpy = sinon.spy(rootScope, '$broadcast');
|
2014-11-21 07:33:22 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function() {
|
|
|
|
logInfoStub.restore();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('update', function() {
|
2014-11-26 15:12:40 -05:00
|
|
|
it('should work', function() {
|
2014-11-21 07:33:22 -05:00
|
|
|
var message = 'Tada!',
|
|
|
|
time = new Date();
|
|
|
|
|
2014-12-04 10:24:42 -05:00
|
|
|
status.update(message, time);
|
2014-11-21 07:33:22 -05:00
|
|
|
|
2014-11-26 15:12:40 -05:00
|
|
|
expect(broadcastSpy.withArgs('status', message, time).calledOnce).to.be.true;
|
|
|
|
expect(logInfoStub.withArgs('status display', message).calledOnce).to.be.true;
|
|
|
|
});
|
2014-11-21 07:33:22 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('setSearching', function() {
|
2014-11-26 15:12:40 -05:00
|
|
|
it('should work', function() {
|
2014-12-04 10:24:42 -05:00
|
|
|
status.setSearching(true);
|
2014-11-21 07:33:22 -05:00
|
|
|
|
2014-11-26 15:12:40 -05:00
|
|
|
expect(broadcastSpy.withArgs('searching', true).calledOnce).to.be.true;
|
|
|
|
});
|
2014-11-21 07:33:22 -05:00
|
|
|
});
|
|
|
|
|
2014-12-04 10:24:42 -05:00
|
|
|
describe('setReading', function() {
|
|
|
|
it('should work', function() {
|
|
|
|
status.setReading(true);
|
|
|
|
|
|
|
|
expect(broadcastSpy.withArgs('read', true).calledOnce).to.be.true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-11-21 07:33:22 -05:00
|
|
|
});
|