-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60ecf63
commit 6eec3ad
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
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,70 @@ | ||
import { useStore } from '@/store/store' | ||
import { nextTick } from 'vue' | ||
import NoticePanel from '@/components/registration/securities-act-notices/NoticePanel.vue' | ||
import SecuritiesActNoticesPanels from '@/components/registration/securities-act-notices/SecuritiesActNoticesPanels.vue' | ||
import { beforeEach } from 'vitest' | ||
import { createComponent } from './utils' | ||
import { SaNoticeTypes } from '@/enums' | ||
|
||
const store = useStore() | ||
|
||
describe('SecuritiesActNoticesPanel.vue', () => { | ||
let wrapper | ||
beforeEach(async () => { | ||
wrapper = await createComponent(SecuritiesActNoticesPanels, { | ||
isAddingNotice: false | ||
}) | ||
}) | ||
|
||
it('renders no notices message when no notices are available', async () => { | ||
// Check if the no notices message is rendered | ||
expect(wrapper.find('.empty-notices-msg').exists()).toBe(true) | ||
}) | ||
|
||
it('renders notice panels when notices are available', async () => { | ||
// Simulate having notices available | ||
store.setSecuritiesActNotices([ | ||
{ | ||
noticeType: SaNoticeTypes.NOTICE_OF_LIEN, | ||
effectiveDate: '2024-05-10' | ||
}, | ||
{ | ||
noticeType: SaNoticeTypes.NOTICE_OF_PROCEEDINGS, | ||
effectiveDate: '2024-05-10' | ||
} | ||
]) | ||
|
||
await nextTick() | ||
|
||
// Check if notice panels are rendered | ||
expect(wrapper.findAllComponents(NoticePanel).length).toBe(2) | ||
}) | ||
|
||
it('toggles panel when clicked', async () => { | ||
// Simulate having notices available | ||
store.setSecuritiesActNotices([ | ||
{ | ||
noticeType: SaNoticeTypes.NOTICE_OF_LIEN, | ||
effectiveDate: '2024-05-10' | ||
}, | ||
{ | ||
noticeType: SaNoticeTypes.NOTICE_OF_PROCEEDINGS, | ||
effectiveDate: '2024-05-10' | ||
} | ||
]) | ||
|
||
const panels = await wrapper.findAllComponents(NoticePanel) | ||
|
||
// Click on the first panel | ||
await panels.at(0).find('.security-notice-header-action').trigger('click') | ||
|
||
// Check if the first panel is active | ||
expect(wrapper.vm.activePanels).toEqual([0]) | ||
|
||
// Click on the second panel | ||
await panels.at(1).find('.security-notice-header-action').trigger('click') | ||
|
||
// Check if the second panel is active and the first active panel was closed | ||
expect(wrapper.vm.activePanels).toEqual([1]) | ||
}) | ||
}) |