Skip to content

Commit a6f395c

Browse files
committed
Fix ImageAsset.spec.js
1 parent 10888f9 commit a6f395c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tests/unit/components/ImageAsset.spec.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('ImageAsset', () => {
4747
});
4848

4949
const picture = wrapper.find('picture');
50-
expect(picture.contains('source')).toBe(false);
50+
expect(picture.find('source').exists()).toBe(false);
5151

5252
const image = picture.find('img');
5353

@@ -81,7 +81,7 @@ describe('ImageAsset', () => {
8181
});
8282

8383
const picture = wrapper.find('picture');
84-
expect(picture.contains('source')).toBe(false);
84+
expect(picture.find('source').exists()).toBe(false);
8585

8686
const image = picture.find('img');
8787

@@ -127,7 +127,7 @@ describe('ImageAsset', () => {
127127
});
128128

129129
const picture = wrapper.find('picture');
130-
expect(picture.contains('source')).toBe(false);
130+
expect(picture.find('source').exists()).toBe(false);
131131

132132
const image = wrapper.find('img');
133133

@@ -243,7 +243,7 @@ describe('ImageAsset', () => {
243243
expect(image.attributes('height')).toBe('auto');
244244
});
245245

246-
it('renders a fallback image if the specified one does not load', () => {
246+
it('renders a fallback image if the specified one does not load', async () => {
247247
const url = 'https://www.example.com/image.png';
248248
const alt = 'This is alt text.';
249249
const wrapper = shallowMount(ImageAsset, {
@@ -269,15 +269,16 @@ describe('ImageAsset', () => {
269269
expect(picture.exists()).toBe(true);
270270
const img = picture.find('img');
271271
expect(img.exists()).toBe(true);
272-
expect(img.classes('fallback')).toBe(false);
272+
expect(img.classes()).not.toContain('fallback');
273273

274274
// simulate an error loading the real image
275275
img.trigger('error');
276+
await wrapper.vm.$nextTick();
276277

277278
expect(wrapper.find('picture').exists()).toBe(false);
278279
const fallbackImg = wrapper.find('img');
279280
expect(fallbackImg.exists()).toBe(true);
280-
expect(fallbackImg.classes('fallback')).toBe(true);
281+
expect(fallbackImg.classes()).toContain('fallback');
281282
expect(fallbackImg.attributes('alt')).toBe(alt);
282283
expect(fallbackImg.attributes('title')).toBe('error.image');
283284
});

0 commit comments

Comments
 (0)