-
Notifications
You must be signed in to change notification settings - Fork 61
Picker tests: set data-app attribute in template instead of body in beforeAll hook #960
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
Changes from all commits
3fcc8bd
ce392a5
5cbcf83
9d512e6
8f9c27a
16a0f96
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 |
---|---|---|
|
@@ -46,11 +46,6 @@ describe('An EColorPicker', () => { | |
|
||
const mount = (options) => mountComponent(EColorPicker, { vuetify, i18n, ...options }) | ||
|
||
beforeAll(() => { | ||
// prevent "[Vuetify] Unable to locate target [data-app]" warnings | ||
document.body.setAttribute('data-app', 'true') | ||
}) | ||
|
||
beforeEach(() => { | ||
vuetify = new Vuetify() | ||
}) | ||
|
@@ -68,16 +63,18 @@ describe('An EColorPicker', () => { | |
test('looks like a color picker', async () => { | ||
const wrapper = mountComponent({ | ||
data: () => ({ color: COLOR_1 }), | ||
template: '<div><e-color-picker v-model="color"></e-color-picker></div>', | ||
template: '<div data-app><e-color-picker v-model="color"></e-color-picker></div>', | ||
components: { 'e-color-picker': EColorPicker } | ||
}, { | ||
vuetify, | ||
attachTo: document.body, | ||
i18n | ||
}) | ||
await waitForDebounce() | ||
expect(wrapper).toMatchSnapshot('pickerclosed') | ||
await wrapper.find('button').trigger('click') | ||
expect(document.body).toMatchSnapshot('pickeropen') | ||
expect(wrapper).toMatchSnapshot('pickeropen') | ||
wrapper.destroy() | ||
}) | ||
|
||
test('updates v-model when the value changes', async () => { | ||
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. Weshalb kommt dieser Test ohne 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. The picker is never opened in this test (and others), thus we don't need a |
||
|
@@ -114,12 +111,14 @@ describe('An EColorPicker', () => { | |
}) | ||
|
||
test('updates its value when a color is picked', async () => { | ||
// prevent "[Vuetify] Unable to locate target [data-app]" warnings | ||
document.body.setAttribute('data-app', 'true') | ||
const wrapper = mount({ | ||
propsData: { | ||
value: COLOR_2 | ||
} | ||
const wrapper = mountComponent({ | ||
data: () => ({ color: COLOR_2 }), | ||
template: '<div data-app><e-color-picker v-model="color"></e-color-picker></div>', | ||
components: { 'e-color-picker': EColorPicker } | ||
}, { | ||
vuetify, | ||
attachTo: document.body, | ||
i18n | ||
}) | ||
await waitForDebounce() | ||
// open the color picker | ||
|
@@ -135,13 +134,18 @@ describe('An EColorPicker', () => { | |
await closeButton.trigger('click') | ||
await waitForDebounce() | ||
expect(wrapper.find('input[type=text]').element.value).toBe('#E6CFE6') | ||
wrapper.destroy() | ||
}) | ||
|
||
test('accepts 3-digit hex color codes', async () => { | ||
const wrapper = mount({ | ||
propsData: { | ||
value: '#abc' | ||
} | ||
const wrapper = mountComponent({ | ||
data: () => ({ color: '#abc' }), | ||
template: '<div data-app><e-color-picker v-model="color"></e-color-picker></div>', | ||
components: { 'e-color-picker': EColorPicker } | ||
}, { | ||
vuetify, | ||
attachTo: document.body, | ||
i18n | ||
}) | ||
await waitForDebounce() | ||
// open the color picker | ||
|
@@ -152,5 +156,6 @@ describe('An EColorPicker', () => { | |
await closeButton.trigger('click') | ||
await waitForDebounce() | ||
expect(wrapper.find('input[type=text]').element.value).toBe('#AABBCC') | ||
wrapper.destroy() | ||
}) | ||
}) |
Uh oh!
There was an error while loading. Please reload this page.
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.
Ist
wrapper.destroy()
in jedem Test nötig derattachTo: document.body
verwendet?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.
I would say so. The documentation says (https://vue-test-utils.vuejs.org/api/options.html#attachto):
However, it seems that in other tests using
attachTo: document.body
there are currently no side-effects of not callingdestroy
. But I think we should do it anyway.