Skip to content

Commit 57e6946

Browse files
Ilya Obuhovtravist
authored andcommitted
Fix wizard tests because of prev button logic change
1 parent df7182a commit 57e6946

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

test/wizards/condional.next.page.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import _map from 'lodash/map';
22
import assert from 'power-assert';
3+
import { expect } from 'chai';
34

45
import Harness from '../harness';
56

@@ -218,7 +219,7 @@ export default {
218219

219220
'Wizard With Condinal Next Page: ByPass page'(form, done) {
220221
// Check current page
221-
assert.equal(form.page, 0);
222+
expect(form.page, 'shod start form page 0').to.equal(0);
222223
Harness.testElements(form, 'input[type="text"]', 2);
223224
const buttonsToValid = ['Cancel', 'Next'];
224225
const buttonsText = _map(Harness.testElements(form, 'button'), (button) => button.innerText);
@@ -261,16 +262,18 @@ export default {
261262
});
262263
})
263264
.then(() => {
264-
// Go to first page.
265+
// Go to prev page.
265266
return Harness.testWizardPrevPage(form, null, (data) => {
266267
// Check prevPage event
267-
assert.equal(data.page, 0);
268+
assert.equal(data.page, 1);
268269
assert.deepEqual(data.submission.data, {
269270
a: 'goTo2',
270271
b: 'b',
271272
e: 'e',
272273
f: 'f',
273-
g: 'g'
274+
g: 'g',
275+
c: '',
276+
d: ''
274277
});
275278
});
276279
})
@@ -280,9 +283,9 @@ export default {
280283
})
281284
.then(() => {
282285
// Check previous page
283-
assert.equal(form.page, 0);
286+
assert.equal(form.page, 1);
284287
Harness.testElements(form, 'input[type="text"]', 2);
285-
const buttonsToValid = ['Cancel', 'Next'];
288+
const buttonsToValid = ['Cancel', 'Previous', 'Next'];
286289
const buttonsText = _map(Harness.testElements(form, 'button'), (button) => button.innerText);
287290
assert.deepEqual(buttonsText, buttonsToValid);
288291
})
@@ -296,7 +299,9 @@ export default {
296299
b: 'b',
297300
e: 'e',
298301
f: 'f',
299-
g: 'g'
302+
g: 'g',
303+
c: '',
304+
d: ''
300305
});
301306
});
302307
})
@@ -319,7 +324,9 @@ export default {
319324
b: 'b',
320325
e: 'e',
321326
f: 'f',
322-
g: 'g'
327+
g: 'g',
328+
c: '',
329+
d: ''
323330
};
324331
Harness.testSubmission(form, {
325332
data: wizardData

test/wizards/simple.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import _map from 'lodash/map';
22
import assert from 'power-assert';
3+
import { expect } from 'chai';
34

45
import Harness from '../harness';
56

@@ -218,13 +219,7 @@ export default {
218219
// Try to go to previous page. Stay on page 0
219220
return Harness.testWizardPrevPage(form)
220221
.then(() => {
221-
// Should returns a reject
222-
done('Should not be called');
223-
})
224-
.catch((error) => {
225-
// Catch prev page error
226-
assert.equal(form.page, 0);
227-
assert.equal(error, 'Page not found');
222+
expect(form.page, 'should stay on page 0').to.equal(0);
228223
})
229224
.then(() => {
230225
return form.submit();
@@ -474,8 +469,21 @@ export default {
474469
done();
475470
});
476471
},
477-
'Test wizard control': (wizard, done) => {
478-
done();
472+
'Test Wizard.setPage with invalid page number': (form, done) => {
473+
let res;
474+
try {
475+
res = form.setPage(-1);
476+
}
477+
catch (error) {
478+
done(error);
479+
}
480+
481+
res
482+
.then(() => expect.fail('should reject'))
483+
.catch(error => {
484+
expect(error).to.equal('Page not found');
485+
done();
486+
});
479487
}
480488
}
481489
};

0 commit comments

Comments
 (0)