-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
21154 - Unit tests for all involuntary dissolution views/components (#…
…2852) * 21154 - Added unit tests for all involuntary dissolution views/components * possible fix to sonarcloud issue * Fixed SonarCloud issue * updated package version after rebase
- Loading branch information
1 parent
b4eb472
commit 69fbf80
Showing
6 changed files
with
194 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Wrapper, createLocalVue, mount } from '@vue/test-utils' | ||
import CardHeader from '@/components/CardHeader.vue' | ||
import Vuetify from 'vuetify' | ||
|
||
describe('CardHeader.vue', () => { | ||
let wrapper: Wrapper<any> | ||
|
||
beforeEach(() => { | ||
const localVue = createLocalVue() | ||
|
||
wrapper = mount(CardHeader, { | ||
localVue, | ||
vuetify: new Vuetify({}), | ||
propsData: { | ||
badgeText: 'Megatron', | ||
icon: 'mdi-calendar-clock', | ||
label: 'Optimus Prime', | ||
showBadge: true | ||
} | ||
}) | ||
}) | ||
|
||
afterEach(() => { | ||
wrapper.destroy() | ||
}) | ||
|
||
it('renders the component properly', () => { | ||
expect(wrapper.findComponent(CardHeader).exists()).toBe(true) | ||
expect(wrapper.find('.v-card-header').exists()).toBe(true) | ||
expect(wrapper.find('.v-card-header').find('.v-icon').exists()).toBe(true) | ||
expect(wrapper.find('.v-card-header').find('.v-chip').exists()).toBe(true) | ||
expect(wrapper.find('.v-card-label').exists()).toBe(true) | ||
}) | ||
|
||
it('shows proper components with proper content', () => { | ||
expect(wrapper.find('.v-card-header').find('.v-icon').attributes().class.includes('mdi-calendar-clock')).toBe(true) | ||
expect(wrapper.find('.v-card-label').text()).toBe('Optimus Prime') | ||
expect(wrapper.find('.v-card-header').find('.v-chip').text()).toBe('Megatron') | ||
}) | ||
}) |
118 changes: 118 additions & 0 deletions
118
auth-web/tests/unit/components/DissolutionSchedule.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { Wrapper, createLocalVue, mount } from '@vue/test-utils' | ||
import DissolutionSchedule from '@/components/auth/staff/DissolutionSchedule.vue' | ||
import { InvoluntaryDissolutionConfigNames } from '@/util/constants' | ||
import StaffService from '../../../src/services/staff.services' | ||
import Vue from 'vue' | ||
import Vuetify from 'vuetify' | ||
import { useStaffStore } from '@/stores' | ||
|
||
describe('DissolutionSchedule.vue', () => { | ||
let wrapper: Wrapper<any> | ||
|
||
beforeEach(() => { | ||
const localVue = createLocalVue() | ||
|
||
vi.spyOn((StaffService as any), 'getInvoluntaryDissolutionBatchSize').mockImplementation(() => ({})) | ||
|
||
const staffStore = useStaffStore() | ||
staffStore.involuntaryDissolutionConfigurations = { | ||
configurations: [ | ||
{ | ||
'fullDescription': 'Number of involuntary dissolutions per day.', | ||
'name': InvoluntaryDissolutionConfigNames.NUM_DISSOLUTIONS_ALLOWED, | ||
'shortDescription': 'Number of involuntary dissolutions per day.', | ||
'value': '250' | ||
} | ||
] | ||
} | ||
|
||
wrapper = mount(DissolutionSchedule, { | ||
localVue, | ||
vuetify: new Vuetify({}) | ||
}) | ||
}) | ||
|
||
afterEach(() => { | ||
wrapper.destroy() | ||
}) | ||
|
||
it('renders the component properly', () => { | ||
expect(wrapper.findComponent(DissolutionSchedule).exists()).toBe(true) | ||
expect(wrapper.find('#dissolution-schedule').isVisible()).toBe(true) | ||
expect(wrapper.find('#schedule-summary-text').exists()).toBe(true) | ||
expect(wrapper.find('.section-container').exists()).toBe(true) | ||
}) | ||
|
||
it('shows the proper schedule summary text', async () => { | ||
await Vue.nextTick() | ||
expect(wrapper.find('#schedule-summary-text').text()).toBe('Schedule Summary') | ||
expect(wrapper.findAll('span').at(1).text()).toContain('Moving 250 businesses into D1 dissolution every Tuesday,') | ||
expect(wrapper.findAll('span').at(1).text()).toContain(' Wednesday, and Thursday at 12:15 a.m. Pacific Time.') | ||
}) | ||
|
||
it('clicking on edit button shows the editing panel', async () => { | ||
// verify that proper components don't exist | ||
expect(wrapper.vm.isEdit).toBe(false) | ||
expect(wrapper.find('#dissolution-batch-size-text').exists()).toBe(false) | ||
expect(wrapper.find('#dissolution-batch-size-text-field').exists()).toBe(false) | ||
|
||
// verify Edit button and click it | ||
const editButton = wrapper.find('#edit-btn') | ||
expect(editButton.text()).toBe('Edit') | ||
await editButton.trigger('click') | ||
|
||
// verify that proper components exist and now are visible | ||
expect(wrapper.vm.isEdit).toBe(true) | ||
expect(wrapper.find('#dissolution-batch-size-text').isVisible()).toBe(true) | ||
expect(wrapper.find('#dissolution-batch-size-text-field').isVisible()).toBe(true) | ||
}) | ||
|
||
it('clicking on cancel button closes the editing panel', async () => { | ||
// verify that proper components don't exist | ||
expect(wrapper.vm.isEdit).toBe(false) | ||
expect(wrapper.find('#cancel-btn').exists()).toBe(false) | ||
expect(wrapper.find('#dissolution-batch-size-text').exists()).toBe(false) | ||
expect(wrapper.find('#dissolution-batch-size-text-field').exists()).toBe(false) | ||
|
||
// Edit button clicked | ||
const editButton = wrapper.find('#edit-btn') | ||
await editButton.trigger('click') | ||
|
||
// verify that cancel button now exists and is visible | ||
expect(wrapper.find('#cancel-btn').isVisible()).toBe(true) | ||
|
||
// Cancel button clicked | ||
const cancelButton = wrapper.find('#cancel-btn') | ||
expect(cancelButton.text()).toBe('Cancel') | ||
await cancelButton.trigger('click') | ||
|
||
// verify that proper components don't exist anymore and are not shown | ||
expect(wrapper.vm.isEdit).toBe(false) | ||
expect(wrapper.find('#dissolution-batch-size-text').exists()).toBe(false) | ||
expect(wrapper.find('#dissolution-batch-size-text-field').exists()).toBe(false) | ||
}) | ||
|
||
it('clicking on save button saves the batch size', async () => { | ||
expect(wrapper.find('#save-btn').exists()).toBe(false) | ||
|
||
// Edit button clicked | ||
const editButton = wrapper.find('#edit-btn') | ||
await editButton.trigger('click') | ||
|
||
// verify that save button now exists and is visible | ||
expect(wrapper.find('#save-btn').isVisible()).toBe(true) | ||
|
||
// set the batch size to 10 instead of 250 | ||
const input = wrapper.find('#dissolution-batch-size-text-field') | ||
input.setValue('10') | ||
input.trigger('change') | ||
|
||
// Save button clicked | ||
const saveButton = wrapper.find('#save-btn') | ||
expect(saveButton.text()).toBe('Save') | ||
await saveButton.trigger('click') | ||
|
||
// the number is updated | ||
expect(wrapper.findAll('span').at(2).text()).toContain('Moving 10 businesses into D1 dissolution every Tuesday,') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters