1
- import { render , setupOnerror } from ' @ember/test-helpers' ;
1
+ import { click , render , setupOnerror } from ' @ember/test-helpers' ;
2
2
import { module , test } from ' qunit' ;
3
3
4
4
import Button from ' @crowdstrike/ember-toucan-core/components/button' ;
5
5
import { setupRenderingTest } from ' test-app/tests/helpers' ;
6
6
7
- import { ButtonPageObject } from ' @crowdstrike/ember-toucan-core/test-support' ;
8
-
9
7
module (' Integration | Component | button' , function (hooks ) {
10
8
setupRenderingTest (hooks );
11
9
12
- let buttonPageObject = new ButtonPageObject (' [data-button]' );
13
-
14
10
test (' it renders' , async function (assert ) {
15
11
await render (<template >
16
12
<Button data-button >
17
13
text
18
14
</Button >
19
15
</template >);
20
16
21
- assert .strictEqual ( buttonPageObject . text , ' text' );
22
- assert .false ( buttonPageObject . isDisabled );
17
+ assert .dom ( ' [data-button] ' ). hasText ( ' text' );
18
+ assert .dom ( ' [data-button] ' ). isEnabled ( );
23
19
24
20
assert
25
- .dom (buttonPageObject . element )
21
+ .dom (' [data-button] ' )
26
22
.hasAttribute (' type' , ' button' , ' Expected default type to be "button"' );
27
23
});
28
24
@@ -35,8 +31,6 @@ module('Integration | Component | button', function (hooks) {
35
31
</Button >
36
32
</template >);
37
33
38
- assert .true (buttonPageObject .isLoading );
39
-
40
34
assert
41
35
.dom (' [data-test-loading-content]' )
42
36
.exists (' Expect to have loading named block rendered' );
@@ -55,8 +49,6 @@ module('Integration | Component | button', function (hooks) {
55
49
</Button >
56
50
</template >);
57
51
58
- assert .false (buttonPageObject .isLoading );
59
-
60
52
assert
61
53
.dom (' [data-test-loading]' )
62
54
.doesNotExist (' Expected to NOT have loading named block rendered' );
@@ -73,7 +65,7 @@ module('Integration | Component | button', function (hooks) {
73
65
</Button >
74
66
</template >);
75
67
76
- assert .true ( buttonPageObject . isDisabled );
68
+ assert .dom ( ' [data-button] ' ). hasAttribute ( ' aria-disabled ' , ' true ' );
77
69
});
78
70
79
71
test (' it yields a disabled named block when `@isDisabled={{true}}' , async function (assert ) {
@@ -123,7 +115,7 @@ module('Integration | Component | button', function (hooks) {
123
115
124
116
assert .verifySteps ([]);
125
117
126
- await buttonPageObject . click ();
118
+ await click (' [data-button] ' );
127
119
128
120
assert .verifySteps ([' clicked' ]);
129
121
});
@@ -139,7 +131,7 @@ module('Integration | Component | button', function (hooks) {
139
131
140
132
assert .verifySteps ([]);
141
133
142
- await buttonPageObject . click ();
134
+ await click (' [data-button] ' );
143
135
144
136
assert .verifySteps ([]);
145
137
});
@@ -150,7 +142,7 @@ module('Integration | Component | button', function (hooks) {
150
142
setupOnerror ((e : Error ) => {
151
143
assert .ok (
152
144
e .message .includes (' Invalid variant for Button' ),
153
- ' Expected assertion error message'
145
+ ' Expected assertion error message' ,
154
146
);
155
147
});
156
148
0 commit comments