@@ -11,6 +11,7 @@ function renderPage() {
1111 page . render ( hbs `
1212 {{conversations/conversation-list-item-with-user
1313 close=onClose
14+ reopen=onReopen
1415 conversation=conversation
1516 }}
1617 ` ) ;
@@ -21,14 +22,15 @@ moduleForComponent('conversations/conversation-list-item-with-user', 'Integratio
2122 beforeEach ( ) {
2223 page . setContext ( this ) ;
2324 set ( this , 'onClose' , ( ) => { } ) ;
25+ set ( this , 'onReopen' , ( ) => { } ) ;
2426 } ,
2527 afterEach ( ) {
2628 page . removeContext ( ) ;
2729 }
2830} ) ;
2931
3032test ( 'it renders the conversation details' , function ( assert ) {
31- assert . expect ( 4 ) ;
33+ assert . expect ( 5 ) ;
3234
3335 let user = {
3436 name : 'Test User' ,
@@ -37,6 +39,7 @@ test('it renders the conversation details', function(assert) {
3739 } ;
3840
3941 let conversation = {
42+ status : 'open' ,
4043 updatedAt : moment ( ) . subtract ( 2 , 'days' ) ,
4144 user
4245 } ;
@@ -49,10 +52,11 @@ test('it renders the conversation details', function(assert) {
4952 assert . equal ( page . target . name . text , user . name , 'The target user name renders' ) ;
5053 assert . equal ( page . target . username . text , user . username , 'Their username renders' ) ;
5154 assert . equal ( page . updatedAt . text , '2 days ago' , 'The updated at timestamp renders' ) ;
55+ assert . equal ( page . closeButton . text , 'Close' , 'Close button text is correct' ) ;
5256} ) ;
5357
5458test ( 'it does not render close button when conversation is closed' , function ( assert ) {
55- assert . expect ( 1 ) ;
59+ assert . expect ( 3 ) ;
5660
5761 let user = {
5862 username : 'testuser'
@@ -68,6 +72,8 @@ test('it does not render close button when conversation is closed', function(ass
6872 renderPage ( ) ;
6973
7074 assert . notOk ( page . closeButton . isVisible , 'Close button is hidden' ) ;
75+ assert . ok ( page . reopenButton . isVisible , 'Reopen button is visible' ) ;
76+ assert . equal ( page . reopenButton . text , 'Reopen' , 'Reopen button text is correct' ) ;
7177} ) ;
7278
7379test ( 'it calls bound action when clicking close button' , function ( assert ) {
@@ -93,3 +99,27 @@ test('it calls bound action when clicking close button', function(assert) {
9399
94100 page . closeButton . click ( ) ;
95101} ) ;
102+
103+ test ( 'it calls bound action when clicking reopen button' , function ( assert ) {
104+ assert . expect ( 1 ) ;
105+
106+ let user = {
107+ username : 'testuser'
108+ } ;
109+
110+ let conversation = {
111+ id : '1' ,
112+ status : 'closed' ,
113+ user
114+ } ;
115+
116+ set ( this , 'conversation' , conversation ) ;
117+
118+ set ( this , 'onReopen' , ( c ) => {
119+ assert . equal ( c , conversation , 'Action was called with correct argument' ) ;
120+ } ) ;
121+
122+ renderPage ( ) ;
123+
124+ page . reopenButton . click ( ) ;
125+ } ) ;
0 commit comments