This repository has been archived by the owner on Nov 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
157 additions
and
11 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
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,44 @@ | ||
import 'mutationobserver-shim' | ||
import { mount } from '@vue/test-utils' | ||
import Dialog from '../Dialog.vue' | ||
|
||
describe('Dialog', () => { | ||
it('should mount', () => { | ||
const wrapper = mount(Dialog) | ||
expect(wrapper.isVueInstance()).toBeTruthy() | ||
expect(wrapper.vm.$data.mdcDialog).toBeDefined() | ||
}) | ||
|
||
it('should render with no prop', () => { | ||
const wrapper = mount(Dialog) | ||
expect(wrapper).toMatchSnapshot() | ||
expect(wrapper.classes()).toContain('mdc-dialog') | ||
}) | ||
|
||
it('should render as scrollable', () => { | ||
const wrapper = mount(Dialog, { | ||
propsData: { | ||
scrollable: true | ||
} | ||
}) | ||
expect(wrapper).toMatchSnapshot() | ||
expect(wrapper.classes()).toContain('mdc-dialog--scrollable') | ||
}) | ||
|
||
it('should render and emit', () => { | ||
const wrapper = mount(Dialog) | ||
|
||
wrapper.setProps({ open: true }) | ||
|
||
expect(wrapper).toMatchSnapshot() | ||
expect(wrapper.emittedByOrder().map(e => e.name)).toEqual(['opening']) | ||
expect(wrapper.vm.$data.mdcDialog.isOpen).toBe(true) | ||
expect(wrapper.isVisible()).toBe(true) | ||
|
||
wrapper.find('.mdc-dialog__scrim').trigger('click') | ||
expect(wrapper).toMatchSnapshot() | ||
expect(wrapper.emittedByOrder().map(e => e.name)).toEqual(['opening', 'closing']) | ||
expect(wrapper.emitted().closing[0]).toEqual([{ action: 'close' }]) | ||
expect(wrapper.vm.$data.mdcDialog.isOpen).toBe(false) | ||
}) | ||
}) |
53 changes: 53 additions & 0 deletions
53
components/dialog/__test__/__snapshots__/Dialog.spec.js.snap
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,53 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Dialog should render and emit 1`] = ` | ||
<div aria-describedby="my-dialog-content" aria-labelledby="my-dialog-title" aria-modal="true" role="alertdialog" class="mdc-dialog mdc-dialog--opening"> | ||
<div class="mdc-dialog__container"> | ||
<div class="mdc-dialog__surface"> | ||
<!----> | ||
<!----> | ||
<!----> | ||
</div> | ||
</div> | ||
<div class="mdc-dialog__scrim"></div> | ||
</div> | ||
`; | ||
|
||
exports[`Dialog should render and emit 2`] = ` | ||
<div aria-describedby="my-dialog-content" aria-labelledby="my-dialog-title" aria-modal="true" role="alertdialog" class="mdc-dialog mdc-dialog--opening mdc-dialog--closing"> | ||
<div class="mdc-dialog__container"> | ||
<div class="mdc-dialog__surface"> | ||
<!----> | ||
<!----> | ||
<!----> | ||
</div> | ||
</div> | ||
<div class="mdc-dialog__scrim"></div> | ||
</div> | ||
`; | ||
|
||
exports[`Dialog should render as scrollable 1`] = ` | ||
<div aria-describedby="my-dialog-content" aria-labelledby="my-dialog-title" aria-modal="true" role="alertdialog" class="mdc-dialog mdc-dialog--scrollable"> | ||
<div class="mdc-dialog__container"> | ||
<div class="mdc-dialog__surface"> | ||
<!----> | ||
<!----> | ||
<!----> | ||
</div> | ||
</div> | ||
<div class="mdc-dialog__scrim"></div> | ||
</div> | ||
`; | ||
|
||
exports[`Dialog should render with no prop 1`] = ` | ||
<div aria-describedby="my-dialog-content" aria-labelledby="my-dialog-title" aria-modal="true" role="alertdialog" class="mdc-dialog"> | ||
<div class="mdc-dialog__container"> | ||
<div class="mdc-dialog__surface"> | ||
<!----> | ||
<!----> | ||
<!----> | ||
</div> | ||
</div> | ||
<div class="mdc-dialog__scrim"></div> | ||
</div> | ||
`; |