1
1
import { computed } from '@ember/object' ;
2
- import { run } from '@ember/runloop' ;
3
2
import { moduleForComponent , test } from 'ember-qunit' ;
3
+ import PageObject from 'ember-cli-page-object' ;
4
4
import hbs from 'htmlbars-inline-precompile' ;
5
+ import userDropdownComponent from 'code-corps-ember/tests/pages/component/user-dropdown' ;
6
+
7
+ let page = PageObject . create ( userDropdownComponent ) ;
8
+
9
+ function renderPage ( ) {
10
+ page . render ( hbs `{{user-dropdown user=user action='hide'}}` ) ;
11
+ }
5
12
6
13
moduleForComponent ( 'user-dropdown' , 'Integration | Component | user dropdown' , {
7
- integration : true
14
+ integration : true ,
15
+ beforeEach ( ) {
16
+ page . setContext ( this ) ;
17
+ } ,
18
+ afterEach ( ) {
19
+ page . removeContext ( ) ;
20
+ }
8
21
} ) ;
9
22
10
23
const stubUser = {
@@ -23,10 +36,11 @@ const stubUser = {
23
36
24
37
test ( 'it renders' , function ( assert ) {
25
38
assert . expect ( 1 ) ;
39
+
26
40
this . set ( 'user' , stubUser ) ;
27
- this . render ( hbs `{{user-dropdown user=user}}` ) ;
41
+ renderPage ( ) ;
28
42
29
- assert . equal ( this . $ ( '.dropdown-menu' ) . length , 1 , 'The component renders' ) ;
43
+ assert . ok ( page . isVisible , 'The component renders' ) ;
30
44
} ) ;
31
45
32
46
test ( 'it triggers the hide action when clicked' , function ( assert ) {
@@ -36,6 +50,8 @@ test('it triggers the hide action when clicked', function(assert) {
36
50
this . on ( 'hide' , function ( ) {
37
51
assert . ok ( true , 'It triggers the hide action when clicked' ) ;
38
52
} ) ;
39
- this . render ( hbs `{{user-dropdown user=user action='hide'}}` ) ;
40
- run ( ( ) => this . $ ( '.dropdown-menu' ) . click ( ) ) ;
53
+
54
+ renderPage ( ) ;
55
+ page . click ( ) ;
56
+
41
57
} ) ;
0 commit comments