2014-10-07 14:32:23 -04:00
|
|
|
'use strict';
|
2013-11-11 11:56:51 -05:00
|
|
|
|
2014-11-25 12:19:40 -05:00
|
|
|
var DialogCtrl = require('../../../../src/js/controller/app/dialog');
|
2013-11-11 11:56:51 -05:00
|
|
|
|
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;
|
2013-11-11 11:56:51 -05:00
|
|
|
|
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
|
2013-11-11 11:56:51 -05:00
|
|
|
});
|
|
|
|
});
|
2014-10-07 14:32:23 -04:00
|
|
|
});
|
2013-11-11 11:56:51 -05:00
|
|
|
|
2014-10-07 14:32:23 -04:00
|
|
|
afterEach(function() {});
|
2013-11-11 11:56:51 -05:00
|
|
|
|
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);
|
2013-11-11 11:56:51 -05:00
|
|
|
});
|
2014-10-07 14:32:23 -04:00
|
|
|
});
|
2013-11-11 11:56:51 -05: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);
|
2013-11-11 11:56:51 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|