From 10556fd3864e30d2e1a488e0bf1957f89894e170 Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Date: Wed, 26 Jul 2017 13:34:26 -0400 Subject: [PATCH] Fix: Wizard call nextCallback and backCallback on navigate Fixes #530 --- src/wizard/wizard-buttons.js | 2 +- test/wizard/wizard.spec.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/wizard/wizard-buttons.js b/src/wizard/wizard-buttons.js index f62a72eb9..85af20176 100644 --- a/src/wizard/wizard-buttons.js +++ b/src/wizard/wizard-buttons.js @@ -32,7 +32,7 @@ e.preventDefault(); $scope.$apply(function () { // scope apply in button module - $scope.wizard[action.replace("pfWiz", "").toLowerCase()]($scope.callback); + $scope.wizard[action.replace("pfWiz", "").toLowerCase()](ctrl.callback); }); }); }; diff --git a/test/wizard/wizard.spec.js b/test/wizard/wizard.spec.js index db136e0c7..4b1d46f4a 100644 --- a/test/wizard/wizard.spec.js +++ b/test/wizard/wizard.spec.js @@ -68,11 +68,15 @@ describe('Component: pfWizard', function () { $scope.data = {}; + $scope.wasNextCalled = false; $scope.nextCallback = function () { + $scope.wasNextCalled = true; return true; }; + $scope.wasBackCalled = false; $scope.backCallback = function () { + $scope.wasBackCalled = true; return true; }; @@ -150,6 +154,23 @@ describe('Component: pfWizard', function () { expect(stepIndicator.text()).toBe('1B.'); }); + it('should call the next callback and back callback when buttons are clicked', function () { + setupWizard('test/wizard/wizard-container.html'); + var nextButton = element.find('.wizard-pf-next'); + var nameBox = element.find('#new-name'); + nameBox.val('test').triggerHandler('input'); + + expect($scope.wasNextCalled).toBe(false); + eventFire(nextButton[0], 'click'); + expect($scope.wasNextCalled).toBe(true); + + var backButton = element.find('#backButton'); + + expect($scope.wasBackCalled).toBe(false); + eventFire(backButton[0], 'click'); + expect($scope.wasBackCalled).toBe(true); + }); + it('should have allowed moving back to first page after input and allowed navigation', function () { setupWizard('test/wizard/wizard-container.html'); var nextButton = element.find('.wizard-pf-next');