@@ -29,10 +29,12 @@ describe("CloudAuth component", () => {
29
29
beforeEach ( async ( ) => {
30
30
const creds = listCredentials . map ( Credential . create ) ;
31
31
stub = sinon . stub ( mockSvc , "listCredentials" ) . resolves ( creds ) ;
32
- /* https://github.com/vuejs/vue-test-utils/issues/829 for more info
33
- * regarding the sync option used here.
34
- */
35
- wrapper = shallowMount ( CloudAuth , { sync : false , localVue } ) ;
32
+ const attachElement = document . createElement ( "div" ) ;
33
+ if ( document . body ) {
34
+ document . body . appendChild ( attachElement ) ;
35
+ }
36
+
37
+ wrapper = shallowMount ( CloudAuth , { localVue, attachTo : attachElement } ) ;
36
38
await flushPromises ( ) ;
37
39
} ) ;
38
40
@@ -44,10 +46,10 @@ describe("CloudAuth component", () => {
44
46
45
47
describe ( "initialization" , ( ) => {
46
48
it ( "should render the initial list" , ( ) => {
47
- assert ( wrapper ) ;
48
- assert ( wrapper . contains ( CloudAuthItem ) ) ;
49
- assert ( wrapper . vm . items . length == 2 ) ;
50
- assert ( wrapper . vm . filteredItems . length == 2 ) ;
49
+ expect ( wrapper ) . toBeTruthy ( ) ;
50
+ expect ( wrapper . findComponent ( CloudAuthItem ) . exists ( ) ) . toBeTruthy ( ) ;
51
+ expect ( wrapper . vm . items . length == 2 ) . toBeTruthy ( ) ;
52
+ expect ( wrapper . vm . filteredItems . length == 2 ) . toBeTruthy ( ) ;
51
53
} ) ;
52
54
} ) ;
53
55
@@ -57,35 +59,35 @@ describe("CloudAuth component", () => {
57
59
58
60
wrapper . vm . filter = "aws" ;
59
61
results = wrapper . vm . filteredItems ;
60
- assert ( wrapper . contains ( CloudAuthItem ) ) ;
61
- assert ( results . length == 1 , `Wrong number of items: ${ results . length } ` ) ;
62
+ expect ( wrapper . findComponent ( CloudAuthItem ) . exists ( ) ) . toBeTruthy ( ) ;
63
+ expect ( results . length == 1 ) . toBeTruthy ( ) ;
62
64
63
65
wrapper . vm . filter = "azure" ;
64
66
results = wrapper . vm . filteredItems ;
65
- assert ( results . length == 1 , `Wrong number of items: ${ results . length } ` ) ;
67
+ expect ( results . length == 1 ) . toBeTruthy ( ) ;
66
68
67
69
wrapper . vm . filter = "" ;
68
70
results = wrapper . vm . filteredItems ;
69
- assert ( results . length == 2 , `Wrong number of items: ${ results . length } ` ) ;
71
+ expect ( results . length == 2 ) . toBeTruthy ( ) ;
70
72
} ) ;
71
73
} ) ;
72
74
73
75
describe ( "create button" , ( ) => {
74
76
it ( "clicking create button should add a blank key" , ( ) => {
75
77
let results = wrapper . vm . filteredItems ;
76
- assert ( wrapper . contains ( CloudAuthItem ) ) ;
77
- assert ( results . length == 2 , `Wrong number of items: ${ results . length } ` ) ;
78
+ expect ( wrapper . findComponent ( CloudAuthItem ) . exists ( ) ) . toBeTruthy ( ) ;
79
+ expect ( results . length == 2 ) . toBeTruthy ( ) ;
78
80
79
81
const button = wrapper . find ( "button[name=createNewKey]" ) ;
80
- assert ( button ) ;
82
+ expect ( button ) . toBeTruthy ( ) ;
81
83
button . trigger ( "click" ) ;
82
84
83
85
results = wrapper . vm . filteredItems ;
84
- assert ( results . length == 3 , `Wrong number of items: ${ results . length } ` ) ;
86
+ expect ( results . length == 3 ) . toBeTruthy ( ) ;
85
87
86
88
const blank = results . find ( ( i ) => i . id == null ) ;
87
- assert ( blank , "missing blank key" ) ;
88
- assert ( blank . id == null ) ;
89
+ expect ( blank ) . toBeTruthy ( ) ;
90
+ expect ( blank . id == null ) . toBeTruthy ( ) ;
89
91
} ) ;
90
92
} ) ;
91
93
} ) ;
0 commit comments