@@ -2,22 +2,36 @@ import RSVP from 'rsvp';
22import { moduleForComponent , test } from 'ember-qunit' ;
33import hbs from 'htmlbars-inline-precompile' ;
44import stubService from 'code-corps-ember/tests/helpers/stub-service' ;
5+ import pageObject from 'ember-cli-page-object' ;
6+ import taskCommentList from 'code-corps-ember/tests/pages/components/task-comment-list' ;
7+
8+ let page = pageObject . create ( taskCommentList ) ;
9+
10+ function renderPage ( ) {
11+ page . render ( hbs `
12+ {{task-comment-list comments=comments}}`
13+ ) ;
14+ }
515
616moduleForComponent ( 'task-comment-list' , 'Integration | Component | task comment list' , {
717 integration : true ,
818 beforeEach ( ) {
19+ page . setContext ( this ) ;
920 stubService ( this , 'store' , {
1021 query ( ) {
1122 return RSVP . resolve ( [ ] ) ;
1223 }
1324 } ) ;
25+ } ,
26+ afterEach ( ) {
27+ page . removeContext ( ) ;
1428 }
1529} ) ;
1630
1731test ( 'it renders' , function ( assert ) {
1832 assert . expect ( 1 ) ;
19- this . render ( hbs `{{task-comment-list}}` ) ;
20- assert . equal ( this . $ ( '.task-comment-list' ) . length , 1 , 'The component\'s element renders' ) ;
33+ renderPage ( ) ;
34+ assert . ok ( page . isVisible , 'The component\'s element renders' ) ;
2135} ) ;
2236
2337test ( 'It renders a list of comments if there are comments' , function ( assert ) {
@@ -30,14 +44,13 @@ test('It renders a list of comments if there are comments', function(assert) {
3044 ] ;
3145
3246 this . set ( 'comments' , comments ) ;
33- this . render ( hbs `{{task-comment-list comments=comments}}` ) ;
34-
35- assert . equal ( this . $ ( '.comment-item' ) . length , 3 , 'The correct number of comments is rendered' ) ;
47+ renderPage ( ) ;
48+ assert . equal ( page . comments ( ) . count , 3 , 'The correct number of comments is rendered' ) ;
3649} ) ;
3750
3851test ( 'it renders nothing when there are no comments' , function ( assert ) {
3952 assert . expect ( 1 ) ;
4053 this . set ( 'comments' , [ ] ) ;
41- this . render ( hbs `{{task-comment-list comments=comments}}` ) ;
42- assert . equal ( this . $ ( '.comment-item' ) . length , 0 , 'No comments are rendered' ) ;
54+ renderPage ( ) ;
55+ assert . equal ( page . comments ( ) . count , 0 , 'No comments are rendered' ) ;
4356} ) ;
0 commit comments