1
1
import Vue from "vue" ;
2
- import DImg from "@/components/DImg" ;
2
+ import DImg from "@/components/DImg.vue" ;
3
+ import { expect } from "chai" ;
3
4
4
5
describe ( "DImg.vue" , ( ) => {
5
6
it ( "should change to the src url after the next tick" , ( ) => {
@@ -9,33 +10,33 @@ describe("DImg.vue", () => {
9
10
src : "https://trajano.net/"
10
11
}
11
12
} ) . $mount ( ) ;
12
- expect ( vm . $el . src ) . toEqual (
13
+ expect ( ( vm . $el as HTMLImageElement ) . src ) . eq (
13
14
"data:image/png;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="
14
15
) ;
15
16
vm . $nextTick ( ( ) => {
16
- expect ( vm . $el . src ) . toEqual ( "https://trajano.net/" ) ;
17
+ expect ( ( vm . $el as HTMLImageElement ) . src ) . eq ( "https://trajano.net/" ) ;
17
18
} ) ;
18
19
} ) ;
19
20
20
21
it ( "should not change to the src url after the next tick when prerendering" , ( ) => {
21
- global . __PRERENDER_INJECTED = { } ;
22
+ ( window as any ) . __PRERENDER_INJECTED = { } ;
22
23
const Constructor = Vue . extend ( DImg ) ;
23
24
const vm = new Constructor ( {
24
25
propsData : {
25
26
src : "https://trajano.net/"
26
27
}
27
28
} ) . $mount ( ) ;
28
- expect ( vm . $el . src ) . toEqual (
29
+ expect ( ( vm . $el as HTMLImageElement ) . src ) . eq (
29
30
"data:image/png;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="
30
31
) ;
31
32
vm . $nextTick ( ( ) => {
32
- expect ( vm . $el . src ) . toEqual (
33
+ expect ( ( vm . $el as HTMLImageElement ) . src ) . eq (
33
34
"data:image/png;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="
34
35
) ;
35
36
} ) ;
36
37
} ) ;
37
38
38
39
afterEach ( ( ) => {
39
- delete global . __PRERENDER_INJECTED ;
40
+ // delete global.__PRERENDER_INJECTED;
40
41
} ) ;
41
42
} ) ;
0 commit comments