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.
fix(radio): missing watcher for value (#262)
- Loading branch information
1 parent
ad51fea
commit cb6bd2d
Showing
3 changed files
with
64 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import 'mutationobserver-shim' | ||
import { mount } from '@vue/test-utils' | ||
import Radio from '../Radio.vue' | ||
|
||
describe('Checkbox', () => { | ||
it('should mount', () => { | ||
let wrapper = mount(Radio) | ||
expect(wrapper.isVueInstance()).toBeTruthy() | ||
expect(wrapper.vm.$data.mdcRadio).toBeDefined() | ||
}) | ||
|
||
it('should render with no prop', () => { | ||
let wrapper = mount(Radio) | ||
expect(wrapper).toMatchSnapshot() | ||
expect(wrapper.classes()).toContain('mdc-radio') | ||
expect(wrapper.find('input').attributes('disabled')).toBeUndefined() | ||
}) | ||
|
||
it('should render as disabled', () => { | ||
let wrapper = mount(Radio, { | ||
propsData: { | ||
disabled: true | ||
} | ||
}) | ||
expect(wrapper).toMatchSnapshot() | ||
expect(wrapper.classes()).toContain('mdc-radio--disabled') | ||
expect(wrapper.find('input').attributes('disabled')).toBeDefined() | ||
}) | ||
|
||
it('should render and emit', () => { | ||
let wrapper = mount(Radio, { | ||
propsData: { | ||
value: 'val' | ||
} | ||
}) | ||
|
||
const radio = wrapper.find('input') | ||
radio.setChecked(true) | ||
expect(wrapper.emitted().change.length).toBe(1) | ||
expect(wrapper.emitted().change[0]).toEqual(['val']) | ||
}) | ||
}) |
19 changes: 19 additions & 0 deletions
19
components/radio/__test__/__snapshots__/Radio.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,19 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Checkbox should render as disabled 1`] = ` | ||
<div class="mdc-radio mdc-radio--disabled"><input type="radio" class="mdc-radio__native-control" disabled="" value=""> | ||
<div class="mdc-radio__background"> | ||
<div class="mdc-radio__outer-circle"></div> | ||
<div class="mdc-radio__inner-circle"></div> | ||
</div> | ||
</div> | ||
`; | ||
exports[`Checkbox should render with no prop 1`] = ` | ||
<div class="mdc-radio"><input type="radio" class="mdc-radio__native-control" value=""> | ||
<div class="mdc-radio__background"> | ||
<div class="mdc-radio__outer-circle"></div> | ||
<div class="mdc-radio__inner-circle"></div> | ||
</div> | ||
</div> | ||
`; |