-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(comp:select): add selelct component (#255)
fix #212
- Loading branch information
Showing
38 changed files
with
2,638 additions
and
4 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
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
5 changes: 5 additions & 0 deletions
5
packages/components/select/__tests__/__snapshots__/option.spec.ts.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,5 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Option.vue render work 1`] = `"<div class=\\"ix-option\\"><!--v-if--><span class=\\"ix-option-label\\">Tom</span></div>"`; | ||
exports[`OptionGroup.vue render work 1`] = `"<div class=\\"ix-option-group\\" style=\\"display: none;\\"><span class=\\"ix-option-group-label\\">TomGroup</span></div>"`; |
11 changes: 11 additions & 0 deletions
11
packages/components/select/__tests__/__snapshots__/select.spec.ts.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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Select.vue multiple template work render work 1`] = `"<div class=\\"ix-select ix-select-multiple ix-select-searchable ix-select-medium\\"><div class=\\"ix-select-selector\\"><div class=\\"ix-select-input\\"><input class=\\"ix-select-input-inner\\" autocomplete=\\"off\\"><span class=\\"ix-select-input-mirror\\" aria-hidden=\\"true\\"></span></div><div class=\\"ix-select-placeholder\\"></div></div><!--v-if--><!--v-if--><!--teleport start--><!--teleport end--></div>"`; | ||
|
||
exports[`Select.vue render options work group options work 1`] = `"<div class=\\"ix-select ix-select-single ix-select-show-suffix ix-select-medium\\"><div class=\\"ix-select-selector\\"><div class=\\"ix-select-item\\"><span class=\\"ix-select-item-label\\">Tom0</span><!--v-if--></div><div class=\\"ix-select-input\\"><input class=\\"ix-select-input-inner\\" autocomplete=\\"off\\" style=\\"opacity: 0;\\"><!--v-if--></div><!--v-if--></div><div class=\\"ix-select-suffix\\"><i class=\\"ix-icon ix-icon-down\\" role=\\"img\\" arialabel=\\"down\\"><svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"64 64 896 896\\" width=\\"1em\\" height=\\"1em\\" focusable=\\"false\\" fill=\\"currentColor\\" aria-hidden=\\"true\\" data-icon=\\"down\\"><path d=\\"M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z\\"></path></svg></i></div><!--v-if--><!--teleport start--><!--teleport end--></div>"`; | ||
|
||
exports[`Select.vue render options work render work 1`] = `"<div class=\\"ix-select ix-select-single ix-select-show-suffix ix-select-medium\\"><div class=\\"ix-select-selector\\"><div class=\\"ix-select-input\\"><input class=\\"ix-select-input-inner\\" autocomplete=\\"off\\" style=\\"opacity: 0;\\"><!--v-if--></div><div class=\\"ix-select-placeholder\\"></div></div><div class=\\"ix-select-suffix\\"><i class=\\"ix-icon ix-icon-down\\" role=\\"img\\" arialabel=\\"down\\"></i></div><!--v-if--><!--teleport start--><!--teleport end--></div>"`; | ||
|
||
exports[`Select.vue single template work group options work 1`] = `"<div class=\\"ix-select ix-select-single ix-select-show-suffix ix-select-medium\\"><div class=\\"ix-select-selector\\"><div class=\\"ix-select-item\\"><span class=\\"ix-select-item-label\\">Tom0</span><!--v-if--></div><div class=\\"ix-select-input\\"><input class=\\"ix-select-input-inner\\" autocomplete=\\"off\\" style=\\"opacity: 0;\\"><!--v-if--></div><!--v-if--></div><div class=\\"ix-select-suffix\\"><i class=\\"ix-icon ix-icon-down\\" role=\\"img\\" arialabel=\\"down\\"><svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"64 64 896 896\\" width=\\"1em\\" height=\\"1em\\" focusable=\\"false\\" fill=\\"currentColor\\" aria-hidden=\\"true\\" data-icon=\\"down\\"><path d=\\"M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z\\"></path></svg></i></div><!--v-if--><!--teleport start--><!--teleport end--></div>"`; | ||
|
||
exports[`Select.vue single template work render work 1`] = `"<div class=\\"ix-select ix-select-single ix-select-show-suffix ix-select-medium\\"><div class=\\"ix-select-selector\\"><div class=\\"ix-select-input\\"><input class=\\"ix-select-input-inner\\" autocomplete=\\"off\\" style=\\"opacity: 0;\\"><!--v-if--></div><div class=\\"ix-select-placeholder\\"></div></div><div class=\\"ix-select-suffix\\"><i class=\\"ix-icon ix-icon-down\\" role=\\"img\\" arialabel=\\"down\\"></i></div><!--v-if--><!--teleport start--><!--teleport end--></div>"`; |
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,54 @@ | ||
import { mount, MountingOptions, VueWrapper } from '@vue/test-utils' | ||
import IxOption from '../src/Option.vue' | ||
import IxOptionGroup from '../src/OptionGroup.vue' | ||
import { OptionProps, OptionGroupProps } from '../src/types' | ||
|
||
describe('Option.vue', () => { | ||
let OptionMount: (options?: MountingOptions<Partial<OptionProps>>) => VueWrapper<InstanceType<typeof IxOption>> | ||
|
||
beforeEach(() => { | ||
OptionMount = options => mount(IxOption, { ...options }) | ||
}) | ||
|
||
afterEach(() => { | ||
jest.spyOn(console, 'warn').mockClear() | ||
}) | ||
|
||
test('render work', () => { | ||
const warn = jest.spyOn(console, 'warn').mockImplementation(() => {}) | ||
const wrapper = OptionMount({ props: { label: 'Tom', value: 'tom' } }) | ||
|
||
expect(wrapper.html()).toMatchSnapshot() | ||
expect(warn).toBeCalledTimes(2) | ||
expect(() => { | ||
wrapper.vm.$forceUpdate() | ||
wrapper.unmount() | ||
}).not.toThrow() | ||
}) | ||
}) | ||
|
||
describe('OptionGroup.vue', () => { | ||
let OptionGroupMount: ( | ||
options?: MountingOptions<Partial<OptionGroupProps>>, | ||
) => VueWrapper<InstanceType<typeof IxOptionGroup>> | ||
|
||
beforeEach(() => { | ||
OptionGroupMount = options => mount(IxOptionGroup, { ...options }) | ||
}) | ||
|
||
afterEach(() => { | ||
jest.spyOn(console, 'warn').mockClear() | ||
}) | ||
|
||
test('render work', () => { | ||
const warn = jest.spyOn(console, 'warn').mockImplementation(() => {}) | ||
const wrapper = OptionGroupMount({ props: { label: 'TomGroup' } }) | ||
|
||
expect(wrapper.html()).toMatchSnapshot() | ||
expect(warn).toBeCalledTimes(1) | ||
expect(() => { | ||
wrapper.vm.$forceUpdate() | ||
wrapper.unmount() | ||
}).not.toThrow() | ||
}) | ||
}) |
Oops, something went wrong.