Skip to content

Commit

Permalink
22846 - add unit tests for component (#747)
Browse files Browse the repository at this point in the history
* 22846 - show resolution dates in amalgamations

* 22846 - fixes after review 1

* 22846 - fixes after review 2

* 22846 - fixes after review 3

* 22846 - update package version

* 22846 - add unit tests

* 22846 - update package version
  • Loading branch information
ketaki-deodhar authored Oct 11, 2024
1 parent 6be0690 commit 6b170b8
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "business-create-ui",
"version": "5.12.5",
"version": "5.12.6",
"private": true,
"appName": "Create UI",
"sbcName": "SBC Common Components",
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/ListResolutions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
cols="12"
sm="9"
>
<div>
<div id="resolution-list">
<tr
v-for="(item, index) in resolutionList"
:key="index"
Expand Down
61 changes: 61 additions & 0 deletions tests/unit/ListResolutions.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import Vuetify from 'vuetify'
import { createPinia, setActivePinia } from 'pinia'
import ListResolutions from '@/components/common/ListResolutions.vue'
import { useStore } from '@/store/store'
import { mount } from '@vue/test-utils'

const vuetify = new Vuetify({})
setActivePinia(createPinia())
const store = useStore()

describe('List Resolutions component', () => {
let wrapper: any

const resolutionList = [
{
'date': '2024-07-15',
'id': 123456,
'type': 'SPECIAL'
},
{
'date': '2024-07-17',
'id': 123457,
'type': 'SPECIAL'
},
{
'date': '2024-07-18',
'id': 123458,
'type': 'SPECIAL'
},
{
'date': '2024-08-15',
'id': 123459,
'type': 'SPECIAL'
}
]

it('ddoes not display resolutions if list is empty', () => {
store.stateModel.resolutions = []
wrapper = mount(ListResolutions, { vuetify })

expect(wrapper.find('#resolution-list').exists()).toBe(false)
expect(wrapper.find('#resolution-label').exists()).toBeFalsy()

wrapper.destroy()
})

it('displays the correct number and dates of resolutions', () => {
store.stateModel.resolutions = resolutionList
wrapper = mount(ListResolutions, { vuetify })

const list = wrapper.find('#resolution-list')
const td = list.findAll('tr > td')

expect(wrapper.find('#resolution-label').exists()).toBeTruthy()
expect(td.length).toBe(4)
expect(td.at(0).text()).toBe('2024-07-15')
expect(td.at(3).text()).toBe('2024-08-15')

wrapper.destroy()
})
})

0 comments on commit 6b170b8

Please sign in to comment.