mail/test/unit/controller/app/dialog-ctrl-test.js

47 lines
1.3 KiB
JavaScript
Raw Normal View History

2014-10-07 14:32:23 -04:00
'use strict';
2014-11-25 12:19:40 -05:00
var DialogCtrl = require('../../../../src/js/controller/app/dialog');
2014-10-07 14:32:23 -04:00
describe('Dialog Controller unit test', function() {
2014-11-25 12:19:40 -05:00
var scope, dialogCtrl, dialogService;
2014-10-07 14:32:23 -04:00
beforeEach(function() {
2014-11-25 12:19:40 -05:00
angular.module('dialogtest', ['woUtil']);
angular.mock.module('dialogtest');
angular.mock.inject(function($rootScope, $controller, dialog) {
2014-10-07 14:32:23 -04:00
scope = $rootScope.$new();
scope.state = {
dialog: {}
};
2014-11-25 12:19:40 -05:00
dialogService = dialog;
2014-10-07 14:32:23 -04:00
dialogCtrl = $controller(DialogCtrl, {
2014-11-25 12:19:40 -05:00
$scope: scope,
dialog: dialog
});
});
2014-10-07 14:32:23 -04:00
});
2014-10-07 14:32:23 -04:00
afterEach(function() {});
2014-10-07 14:32:23 -04:00
describe('confirm', function() {
it('should work', function(done) {
2014-11-25 12:19:40 -05:00
scope.callback = function(confirmed) {
2014-10-07 14:32:23 -04:00
expect(confirmed).to.be.true;
2014-11-26 13:51:15 -05:00
expect(scope.state.dialog.open).to.be.false;
2014-10-07 14:32:23 -04:00
done();
};
scope.confirm(true);
});
2014-10-07 14:32:23 -04:00
});
2014-10-07 14:32:23 -04:00
describe('cancel', function() {
it('should work', function(done) {
2014-11-25 12:19:40 -05:00
scope.callback = function(confirmed) {
2014-10-07 14:32:23 -04:00
expect(confirmed).to.be.false;
2014-11-26 13:51:15 -05:00
expect(scope.state.dialog.open).to.be.false;
2014-10-07 14:32:23 -04:00
done();
};
scope.confirm(false);
});
});
});