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

Commit

Permalink
#101 Add test to reset wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
cristijora committed Nov 27, 2017
1 parent 4d2ec91 commit 8187580
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions test/unit/specs/FormWizard.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,31 @@ describe('FormWizard.vue', () => {
const formWizard = wizard.find(FormWizard)
expect(formWizard.vm.activeTabIndex).to.equal(startIndex)
})
it('resets wizard', () => {
const wizard = mount(twoStepWizard, {localVue})
const wizardInstance = wizard.find(FormWizard)
let tabs = wizard.findAll(WizardTab)
expect(tabs.length).to.equal(3)
wizardInstance.vm.nextTab()
wizardInstance.vm.nextTab()
const lastTab = tabs.at(2)
expect(lastTab.vm.active).to.equal(true)
expect(wizardInstance.vm.maxStep).to.equal(tabs.length - 1)
expect(wizardInstance.vm.activeTabIndex).to.equal(tabs.length - 1)
wizardInstance.vm.reset()
const firstTab = tabs.at(0)
expect(firstTab.vm.active).to.equal(true)
expect(wizardInstance.vm.maxStep).to.equal(0)
expect(wizardInstance.vm.activeTabIndex).to.equal(0)
})

it('next tab is called', () => {
const wizard = mount(twoStepWizard, {localVue})
const nextTabHandler = sinon.stub()
const formWizard = wizard.find(FormWizard)
formWizard.setMethods({nextTab: nextTabHandler})
const nextButton = wizard.find('.wizard-footer-right span')
nextButton.trigger('click')
expect(nextTabHandler.called).to.equal(true)
let tabs = wizard.findAll(WizardTab)
const secondTab = tabs.at(1)
expect(secondTab.vm.active).to.equal(true)
})

it('renders tab wrapped in another element', done => {
Expand All @@ -109,4 +126,5 @@ describe('FormWizard.vue', () => {
done()
})
})

})

0 comments on commit 8187580

Please sign in to comment.