Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('MyApp')
- .directive('widgetContainer', function() {
- return {
- templateUrl: '/static/templates/container.html',
- controller: 'ContainerCtrl'
- };
- })
- .controller('ContainerCtrl', ['$scope', '$modal', function($scope, $modal) {
- function editWidget(widget) {
- var modalInstance = $modal.open({
- templateUrl: '/static/templates//modal.html',
- controller: 'ModalInstanceCtrl',
- scope: $scope,
- size: 'lg',
- backdrop: 'static'
- });
- modalInstance.opened.then(function() {
- $scope.widgetCopy = editWidgetInit(widget);
- });
- modalInstance.result
- .then(function() {
- // some result
- });
- return modalInstance;
- }
- function editWidgetInit(widget) {
- widgetCopy = setSelectedChart(widget);
- // lots of other setup tasks
- return widgetCopy;
- }
- }]);
- describe('on edit widget', function() {
- it('should setup selectedChart from widget', function() {
- var widget = {widget: {indicators: [{name: 'indicator'}]}};
- var modalInstance = scope.editWidget(widget);
- rootScope.$digest();
- expect(scope.selectedChart).toBe('pie');
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement