1
0
mirror of https://github.com/moparisthebest/mail synced 2024-08-13 16:43:47 -04:00
mail/test/unit/util/status-display-test.js

65 lines
2.2 KiB
JavaScript
Raw Normal View History

2014-11-21 07:33:22 -05:00
'use strict';
describe('Status Display Service unit test', function() {
var statusDisplay, logInfoStub;
beforeEach(function() {
angular.module('statusDisplay-test', ['woUtil']);
angular.mock.module('statusDisplay-test');
angular.mock.inject(function($injector, axe) {
logInfoStub = sinon.stub(axe, 'info');
statusDisplay = $injector.get('statusDisplay');
});
});
afterEach(function() {
logInfoStub.restore();
});
describe('update', function() {
it('should work', inject(function($rootScope) {
var message = 'Tada!',
time = new Date();
statusDisplay.showStatus = function() {};
var showStatusStub = sinon.stub(statusDisplay, 'showStatus');
statusDisplay.update(message, time).then(function(result) {
expect(result).to.not.exist;
});
expect(logInfoStub.calledOnce).to.be.true;
$rootScope.$apply();
expect(showStatusStub.withArgs(message, time).calledOnce).to.be.true;
}));
it('should fail for no display function', inject(function($rootScope) {
statusDisplay.update().catch(function(err) {
expect(err.message).to.match(/showStatus/);
});
expect(logInfoStub.calledOnce).to.be.true;
$rootScope.$apply();
}));
});
describe('setSearching', function() {
it('should work', inject(function($rootScope) {
statusDisplay.showSearching = function() {};
var showSearchingStub = sinon.stub(statusDisplay, 'showSearching');
statusDisplay.setSearching(true).then(function(result) {
expect(result).to.not.exist;
});
$rootScope.$apply();
expect(showSearchingStub.withArgs(true).calledOnce).to.be.true;
}));
it('should fail for no display function', inject(function($rootScope) {
statusDisplay.setSearching().catch(function(err) {
expect(err.message).to.match(/showSearching/);
});
$rootScope.$apply();
}));
});
});