Skip to content

Commit 762f630

Browse files
jeff-phillips-18cdcabrera
authored andcommitted
Fix: Wizard call nextCallback and backCallback on navigate (#531)
Fixes #530
1 parent 38413e4 commit 762f630

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/wizard/wizard-buttons.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
e.preventDefault();
3333
$scope.$apply(function () {
3434
// scope apply in button module
35-
$scope.wizard[action.replace("pfWiz", "").toLowerCase()]($scope.callback);
35+
$scope.wizard[action.replace("pfWiz", "").toLowerCase()](ctrl.callback);
3636
});
3737
});
3838
};

test/wizard/wizard.spec.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,15 @@ describe('Component: pfWizard', function () {
6868

6969
$scope.data = {};
7070

71+
$scope.wasNextCalled = false;
7172
$scope.nextCallback = function () {
73+
$scope.wasNextCalled = true;
7274
return true;
7375
};
7476

77+
$scope.wasBackCalled = false;
7578
$scope.backCallback = function () {
79+
$scope.wasBackCalled = true;
7680
return true;
7781
};
7882

@@ -150,6 +154,23 @@ describe('Component: pfWizard', function () {
150154
expect(stepIndicator.text()).toBe('1B.');
151155
});
152156

157+
it('should call the next callback and back callback when buttons are clicked', function () {
158+
setupWizard('test/wizard/wizard-container.html');
159+
var nextButton = element.find('.wizard-pf-next');
160+
var nameBox = element.find('#new-name');
161+
nameBox.val('test').triggerHandler('input');
162+
163+
expect($scope.wasNextCalled).toBe(false);
164+
eventFire(nextButton[0], 'click');
165+
expect($scope.wasNextCalled).toBe(true);
166+
167+
var backButton = element.find('#backButton');
168+
169+
expect($scope.wasBackCalled).toBe(false);
170+
eventFire(backButton[0], 'click');
171+
expect($scope.wasBackCalled).toBe(true);
172+
});
173+
153174
it('should have allowed moving back to first page after input and allowed navigation', function () {
154175
setupWizard('test/wizard/wizard-container.html');
155176
var nextButton = element.find('.wizard-pf-next');

0 commit comments

Comments
 (0)