Skip to content

Commit 7bf8f94

Browse files
committed
Wait for .setValue()
1 parent 5aeea0d commit 7bf8f94

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

tests/unit/components/BaseDropdown.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ describe('BaseDropdown', () => {
5757
expect(dropdown.find('option').exists()).toBe(true);
5858
});
5959

60-
it('emits `input` event on each select change', () => {
60+
it('emits `input` event on each select change', async () => {
6161
const value = 'foo';
6262
const wrapper = createWrapper({
6363
slots: {
6464
default: `<option value="${value}">Foo</option>`,
6565
},
6666
});
6767

68-
wrapper.findComponent('select').setValue(value);
68+
await wrapper.findComponent('select').setValue(value);
6969
expect(wrapper.emitted('input')).toEqual([[value]]);
7070
});
7171

tests/unit/components/DocumentationTopic/DocumentationNav/LanguageToggle.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ describe('LanguageToggle', () => {
104104
Object.defineProperty(sizer, 'clientWidth', {
105105
get: () => 20,
106106
});
107-
toggle.setValue(Language.objectiveC.key.api);
108-
await wrapper.vm.$nextTick();
107+
await toggle.setValue(Language.objectiveC.key.api);
108+
await flushPromises();
109109
expect(toggle.attributes()).toHaveProperty('style', 'width: 28px;');
110110
});
111111

tests/unit/components/Filter/FilterInput.spec.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,12 @@ describe('FilterInput', () => {
132132
});
133133
expect(input.attributes('placeholder')).toBe('Foo');
134134
// make sure it emits the correct event
135-
input.setValue(inputValue);
135+
await input.setValue(inputValue);
136136
expect(wrapper.emitted('input')).toEqual([[inputValue]]);
137137
// make sure the input is bound
138138
await wrapper.setProps({
139139
value: 'new-value',
140140
});
141-
await wrapper.vm.$nextTick();
142141
expect(input.element.value).toEqual('new-value');
143142
});
144143

@@ -244,7 +243,7 @@ describe('FilterInput', () => {
244243
});
245244

246245
it('adds character `/` as input value', async () => {
247-
input.setValue('/');
246+
await input.setValue('/');
248247
expect(wrapper.emitted('input')).toEqual([['/']]);
249248
});
250249

@@ -1037,11 +1036,10 @@ describe('FilterInput', () => {
10371036
wrapper.findComponent({ ref: 'selectedTags' }).vm.$emit('select-all');
10381037
await wrapper.vm.$nextTick();
10391038
input.trigger('keydown', { key: singleCharacter });
1040-
input.setValue(singleCharacter);
1039+
await input.setValue(singleCharacter);
10411040

10421041
expect(wrapper.emitted('input')).toEqual([[''], [singleCharacter]]);
10431042
expect(wrapper.emitted('update:selectedTags')).toBeTruthy();
1044-
await wrapper.vm.$nextTick();
10451043
expect(document.activeElement).toBe(input.element);
10461044
});
10471045

@@ -1057,11 +1055,10 @@ describe('FilterInput', () => {
10571055
key: singleCharacter,
10581056
shiftKey: true,
10591057
});
1060-
input.setValue(singleCharacter);
1058+
await input.setValue(singleCharacter);
10611059

10621060
expect(wrapper.emitted('input')).toEqual([[''], [singleCharacter]]);
10631061
expect(wrapper.emitted('update:selectedTags')).toBeTruthy();
1064-
await wrapper.vm.$nextTick();
10651062
expect(document.activeElement).toBe(input.element);
10661063
});
10671064

0 commit comments

Comments
 (0)