@@ -47,7 +47,7 @@ describe('ImageAsset', () => {
47
47
} ) ;
48
48
49
49
const picture = wrapper . find ( 'picture' ) ;
50
- expect ( picture . contains ( 'source' ) ) . toBe ( false ) ;
50
+ expect ( picture . find ( 'source' ) . exists ( ) ) . toBe ( false ) ;
51
51
52
52
const image = picture . find ( 'img' ) ;
53
53
@@ -81,7 +81,7 @@ describe('ImageAsset', () => {
81
81
} ) ;
82
82
83
83
const picture = wrapper . find ( 'picture' ) ;
84
- expect ( picture . contains ( 'source' ) ) . toBe ( false ) ;
84
+ expect ( picture . find ( 'source' ) . exists ( ) ) . toBe ( false ) ;
85
85
86
86
const image = picture . find ( 'img' ) ;
87
87
@@ -127,7 +127,7 @@ describe('ImageAsset', () => {
127
127
} ) ;
128
128
129
129
const picture = wrapper . find ( 'picture' ) ;
130
- expect ( picture . contains ( 'source' ) ) . toBe ( false ) ;
130
+ expect ( picture . find ( 'source' ) . exists ( ) ) . toBe ( false ) ;
131
131
132
132
const image = wrapper . find ( 'img' ) ;
133
133
@@ -243,7 +243,7 @@ describe('ImageAsset', () => {
243
243
expect ( image . attributes ( 'height' ) ) . toBe ( 'auto' ) ;
244
244
} ) ;
245
245
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 ( ) => {
247
247
const url = 'https://www.example.com/image.png' ;
248
248
const alt = 'This is alt text.' ;
249
249
const wrapper = shallowMount ( ImageAsset , {
@@ -269,15 +269,16 @@ describe('ImageAsset', () => {
269
269
expect ( picture . exists ( ) ) . toBe ( true ) ;
270
270
const img = picture . find ( 'img' ) ;
271
271
expect ( img . exists ( ) ) . toBe ( true ) ;
272
- expect ( img . classes ( 'fallback' ) ) . toBe ( false ) ;
272
+ expect ( img . classes ( ) ) . not . toContain ( 'fallback' ) ;
273
273
274
274
// simulate an error loading the real image
275
275
img . trigger ( 'error' ) ;
276
+ await wrapper . vm . $nextTick ( ) ;
276
277
277
278
expect ( wrapper . find ( 'picture' ) . exists ( ) ) . toBe ( false ) ;
278
279
const fallbackImg = wrapper . find ( 'img' ) ;
279
280
expect ( fallbackImg . exists ( ) ) . toBe ( true ) ;
280
- expect ( fallbackImg . classes ( 'fallback' ) ) . toBe ( true ) ;
281
+ expect ( fallbackImg . classes ( ) ) . toContain ( 'fallback' ) ;
281
282
expect ( fallbackImg . attributes ( 'alt' ) ) . toBe ( alt ) ;
282
283
expect ( fallbackImg . attributes ( 'title' ) ) . toBe ( 'error.image' ) ;
283
284
} ) ;
0 commit comments