Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 8187580

Browse files
committed
#101 Add test to reset wizard
1 parent 4d2ec91 commit 8187580

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

test/unit/specs/FormWizard.spec.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,31 @@ describe('FormWizard.vue', () => {
8686
const formWizard = wizard.find(FormWizard)
8787
expect(formWizard.vm.activeTabIndex).to.equal(startIndex)
8888
})
89+
it('resets wizard', () => {
90+
const wizard = mount(twoStepWizard, {localVue})
91+
const wizardInstance = wizard.find(FormWizard)
92+
let tabs = wizard.findAll(WizardTab)
93+
expect(tabs.length).to.equal(3)
94+
wizardInstance.vm.nextTab()
95+
wizardInstance.vm.nextTab()
96+
const lastTab = tabs.at(2)
97+
expect(lastTab.vm.active).to.equal(true)
98+
expect(wizardInstance.vm.maxStep).to.equal(tabs.length - 1)
99+
expect(wizardInstance.vm.activeTabIndex).to.equal(tabs.length - 1)
100+
wizardInstance.vm.reset()
101+
const firstTab = tabs.at(0)
102+
expect(firstTab.vm.active).to.equal(true)
103+
expect(wizardInstance.vm.maxStep).to.equal(0)
104+
expect(wizardInstance.vm.activeTabIndex).to.equal(0)
105+
})
106+
89107
it('next tab is called', () => {
90108
const wizard = mount(twoStepWizard, {localVue})
91-
const nextTabHandler = sinon.stub()
92-
const formWizard = wizard.find(FormWizard)
93-
formWizard.setMethods({nextTab: nextTabHandler})
94109
const nextButton = wizard.find('.wizard-footer-right span')
95110
nextButton.trigger('click')
96-
expect(nextTabHandler.called).to.equal(true)
111+
let tabs = wizard.findAll(WizardTab)
112+
const secondTab = tabs.at(1)
113+
expect(secondTab.vm.active).to.equal(true)
97114
})
98115

99116
it('renders tab wrapped in another element', done => {
@@ -109,4 +126,5 @@ describe('FormWizard.vue', () => {
109126
done()
110127
})
111128
})
129+
112130
})

0 commit comments

Comments
 (0)