Skip to content

Commit

Permalink
Merge pull request #8 from bahadirsofuoglu/dev
Browse files Browse the repository at this point in the history
Unit test updates after checked feature
  • Loading branch information
bahadirsofuoglu authored Jun 15, 2022
2 parents d7f12ee + 5a778b6 commit bdeb76b
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions test/wizard.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ beforeEach(() => {
wrapper = mount(Wizard)
})

const checkActiveItemCount = () => {
const getActiveItemCount = () => {
return wrapper.vm.tabs.filter(tab => tab.active).length
}
const getCheckedItemCount = () => {
return wrapper.vm.tabs.filter(tab => tab.checked).length
}

describe('Wizard unit tests', () => {
test('displayPrevTab should be false when component mount', () => {
expect(wrapper.vm.displayPrevTab).toBe(false)
Expand Down Expand Up @@ -39,18 +43,11 @@ describe('Wizard unit tests', () => {
await wrapper.findAll('.fw-body-list > li')[1].trigger('click')

expect(wrapper.vm.currentTabIndex).toEqual(1)
expect(checkActiveItemCount()).toEqual(2)
})

test('when navigableTabs props is true currentTabIndex should change', async () => {
await wrapper.setProps({ navigableTabs: true })
await wrapper.findAll('.fw-body-list > li')[1].trigger('click')

expect(wrapper.vm.currentTabIndex).toEqual(1)
expect(checkActiveItemCount()).toEqual(2)
expect(getActiveItemCount()).toEqual(1)
expect(getCheckedItemCount()).toEqual(1)
})

test('when navigableTabs props is true currentTabIndex should change', async () => {
test('when navigableTabs props true and tabs cliced buttons text should be changed', async () => {
await wrapper.setProps({ navigableTabs: true })
await wrapper.findAll('.fw-body-list > li')[2].trigger('click')

Expand All @@ -62,7 +59,8 @@ describe('Wizard unit tests', () => {
await wrapper.findAll('.fw-btn')[0].trigger('click')

expect(wrapper.vm.currentTabIndex).toEqual(1)
expect(checkActiveItemCount()).toEqual(2)
expect(getActiveItemCount()).toEqual(1)
expect(getCheckedItemCount()).toEqual(1)
expect(wrapper.emitted().change).toBeTruthy()
})

Expand All @@ -71,7 +69,7 @@ describe('Wizard unit tests', () => {
await wrapper.findAll('.fw-btn')[0].trigger('click')

expect(wrapper.vm.currentTabIndex).toEqual(0)
expect(checkActiveItemCount()).toEqual(1)
expect(getActiveItemCount()).toEqual(1)
expect(wrapper.emitted().change).toBeTruthy()
})

Expand All @@ -82,7 +80,8 @@ describe('Wizard unit tests', () => {

expect(wrapper.findAll('.fw-btn')[1].text()).toBe('Done')
expect(wrapper.vm.currentTabIndex).toEqual(2)
expect(checkActiveItemCount()).toEqual(3)
expect(getActiveItemCount()).toEqual(1)
expect(getCheckedItemCount()).toEqual(2)
expect(wrapper.emitted().completeWizard).toBeTruthy()
})
})

0 comments on commit bdeb76b

Please sign in to comment.