Skip to content

Commit

Permalink
test: improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jowjow22 committed Sep 30, 2024
1 parent 52b90db commit 30975b1
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions packages/core/src/components/modal/modal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,51 @@ describe('atom-modal', () => {
expect(page.rootInstance.modal.close).toHaveBeenCalled()
})

it('should call remove and add on backdrop no scroll class when is-open changes', async () => {
page = await newSpecPage({
components: [AtomModal],
html: `
<atom-modal header-title="Header from prop" is-open="true">
Modal content
<div slot="header">Custom Header</div>
</atom-modal>
`,
})

expect(page.root?.innerHTML).toContain('isopen')

page.rootInstance.modal = {
dismiss: jest.fn(),
}

page.rootInstance.handleDidPresent()

expect(document.body.classList.add).toHaveBeenCalled()
expect(document.documentElement.classList.add).toHaveBeenCalled()
})

it('should call remove on class list when call remove classes', async () => {
page = await newSpecPage({
components: [AtomModal],
html: `
<atom-modal header-title="Header from prop" is-open="true">
Modal content
<div slot="header">Custom Header</div>
</atom-modal>
`,
})

page.rootInstance.addClasses()

expect(document.body.classList.add).toHaveBeenCalled()
expect(document.documentElement.classList.add).toHaveBeenCalled()

page.rootInstance.removeClasses()

expect(document.body.classList.remove).toHaveBeenCalled()
expect(document.documentElement.classList.remove).toHaveBeenCalled()
})

it('should render icon type when alertType is passed', async () => {
await page.setContent(`
<atom-modal alert-type="error">
Expand Down

0 comments on commit 30975b1

Please sign in to comment.