2014-10-07 14:32:23 -04:00
|
|
|
'use strict';
|
2013-11-11 11:56:51 -05:00
|
|
|
|
2014-10-07 14:32:23 -04:00
|
|
|
var mocks = angular.mocks,
|
|
|
|
DialogCtrl = require('../../src/js/controller/dialog');
|
2013-11-11 11:56:51 -05:00
|
|
|
|
2014-10-07 14:32:23 -04:00
|
|
|
describe('Dialog Controller unit test', function() {
|
|
|
|
var scope, dialogCtrl;
|
2013-11-11 11:56:51 -05:00
|
|
|
|
2014-10-07 14:32:23 -04:00
|
|
|
beforeEach(function() {
|
|
|
|
angular.module('dialogtest', []);
|
|
|
|
mocks.module('dialogtest');
|
|
|
|
mocks.inject(function($rootScope, $controller) {
|
|
|
|
scope = $rootScope.$new();
|
|
|
|
scope.state = {
|
|
|
|
dialog: {}
|
|
|
|
};
|
|
|
|
dialogCtrl = $controller(DialogCtrl, {
|
|
|
|
$scope: scope
|
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) {
|
|
|
|
scope.state.dialog.callback = function(confirmed) {
|
|
|
|
expect(confirmed).to.be.true;
|
|
|
|
expect(scope.state.dialog.open).to.be.false;
|
|
|
|
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) {
|
|
|
|
scope.state.dialog.callback = function(confirmed) {
|
|
|
|
expect(confirmed).to.be.false;
|
|
|
|
expect(scope.state.dialog.open).to.be.false;
|
|
|
|
done();
|
|
|
|
};
|
|
|
|
scope.confirm(false);
|
2013-11-11 11:56:51 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|