-
-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Update tests for VTU beta-31 #10356
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,6 @@ describe('VAlert.ts', () => { | |
mountFunction = (options = {}) => { | ||
return mount(VAlert, { | ||
...options, | ||
// https://github.com/vuejs/vue-test-utils/issues/1130 | ||
sync: false, | ||
mocks: { | ||
$vuetify: { | ||
lang: { | ||
|
@@ -36,9 +34,14 @@ describe('VAlert.ts', () => { | |
|
||
expect(wrapper.element.style.display).toBe('') | ||
expect(wrapper.html()).toMatchSnapshot() | ||
}) | ||
|
||
wrapper.setProps({ value: false }) | ||
await wrapper.vm.$nextTick() | ||
it('should sets display to none when value is false', async () => { | ||
const wrapper = mountFunction({ | ||
propsData: { | ||
value: false, | ||
} | ||
}) | ||
|
||
expect(wrapper.element.style.display).toBe('none') | ||
expect(wrapper.html()).toMatchSnapshot() | ||
|
@@ -60,7 +63,7 @@ describe('VAlert.ts', () => { | |
}) | ||
|
||
const icon = wrapper.find('.v-alert__dismissible') | ||
const input = jest.fn(show => wrapper.setProps({ show })) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like this wasn't doing anything, removing it made no difference There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that was supposed to be like v-model from before it stored its own state. |
||
const input = jest.fn() | ||
|
||
wrapper.vm.$on('input', input) | ||
|
||
|
@@ -89,26 +92,22 @@ describe('VAlert.ts', () => { | |
expect(wrapper.contains('.v-icon')).toBe(false) | ||
}) | ||
|
||
// TODO: this fails without sync, nextTick doesn't help | ||
// https://github.com/vuejs/vue-test-utils/issues/1130 | ||
it.skip('should display contextual colors by type', async () => { | ||
it('should display contextual colors by type', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be merged with the one below |
||
const wrapper = mountFunction({ | ||
propsData: { type: 'error' }, | ||
}) | ||
|
||
expect(wrapper.classes('error')).toBe(true) | ||
}) | ||
|
||
wrapper.setProps({ type: 'success' }) | ||
await wrapper.vm.$nextTick() | ||
expect(wrapper.classes('success')).toBe(true) | ||
|
||
wrapper.setProps({ type: 'warning' }) | ||
await wrapper.vm.$nextTick() | ||
expect(wrapper.classes('warning')).toBe(true) | ||
;['success', 'error', 'warning', 'info'].forEach(type => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can avoid using |
||
it('should display contextual colors by type', () => { | ||
const wrapper = mountFunction({ | ||
propsData: { type }, | ||
}) | ||
|
||
wrapper.setProps({ type: 'info' }) | ||
await wrapper.vm.$nextTick() | ||
expect(wrapper.classes('info')).toBe(true) | ||
expect(wrapper.classes(type)).toBe(true) | ||
}) | ||
}) | ||
|
||
it('should allow overriding color for contextual alert', () => { | ||
|
@@ -135,22 +134,20 @@ describe('VAlert.ts', () => { | |
expect(icon.text()).toBe('block') | ||
}) | ||
|
||
it('should show border', async () => { | ||
const directions = ['top', 'right', 'bottom', 'left'] | ||
const wrapper = mountFunction() | ||
|
||
expect(wrapper.classes('v-alert--border')).toBe(false) | ||
|
||
for (const border of directions) { | ||
wrapper.setProps({ border }) | ||
await wrapper.vm.$nextTick() | ||
;['top', 'right', 'bottom', 'left'].forEach(border => { | ||
it('should show border', async () => { | ||
const wrapper = mountFunction({ | ||
propsData: { | ||
border, | ||
} | ||
}) | ||
|
||
expect(wrapper.classes('v-alert--border')).toBe(true) | ||
expect(wrapper.classes(`v-alert--border-${border}`)).toBe(true) | ||
} | ||
}) | ||
}) | ||
|
||
it('should move color classes to border and icon elements', async () => { | ||
it('renders without a colored border and icons', async () => { | ||
const wrapper = mountFunction({ | ||
propsData: { | ||
color: 'pink', | ||
|
@@ -161,9 +158,18 @@ describe('VAlert.ts', () => { | |
|
||
expect(wrapper.classes('pink')).toBe(true) | ||
expect(border.classes('pink')).toBe(false) | ||
}) | ||
|
||
it('renders a colored border and icons', async () => { | ||
const wrapper = mountFunction({ | ||
propsData: { | ||
color: 'pink', | ||
border: 'left', | ||
coloredBorder: true, | ||
}, | ||
}) | ||
const border = wrapper.find('.v-alert__border') | ||
|
||
wrapper.setProps({ coloredBorder: true }) | ||
await wrapper.vm.$nextTick() | ||
expect(wrapper.classes('pink')).toBe(false) | ||
expect(border.classes('pink')).toBe(true) | ||
expect(border.classes('v-alert__border--has-color')).toBe(true) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.