@@ -5,7 +5,7 @@ import {shell} from 'electron';
55import ActionableReviewView from '../../lib/views/actionable-review-view' ;
66import * as reporterProxy from '../../lib/reporter-proxy' ;
77
8- describe ( 'ActionableReviewView' , function ( ) {
8+ describe . only ( 'ActionableReviewView' , function ( ) {
99 let atomEnv , mockEvent , mockMenu ;
1010
1111 beforeEach ( function ( ) {
@@ -266,14 +266,55 @@ describe('ActionableReviewView', function() {
266266 } ) ;
267267
268268 describe ( 'when the cancel button is clicked' , function ( ) {
269- it ( 'reverts to non-editing mode when the text is unchanged' ) ;
269+ it ( 'reverts to non-editing mode when the text is unchanged' , async function ( ) {
270+ const confirm = sinon . stub ( ) . returns ( 0 ) ;
270271
271- it ( 'reverts to non-editing mode when the text is empty' ) ;
272+ const wrapper = shallowEditMode ( {
273+ originalContent : { id : 'id-0' , body : 'original' } ,
274+ confirm,
275+ render : ( ) => < div className = "original" /> ,
276+ } ) ;
277+
278+ await wrapper . find ( '.github-Review-editableCancelButton' ) . prop ( 'onClick' ) ( ) ;
279+ assert . isFalse ( confirm . called ) ;
280+ assert . isTrue ( wrapper . exists ( '.original' ) ) ;
281+ } ) ;
272282
273283 describe ( 'when the text has changed' , function ( ) {
274- it ( 'reverts to non-editing mode when the user confirms' ) ;
284+ it ( 'reverts to non-editing mode when the user confirms' , async function ( ) {
285+ const confirm = sinon . stub ( ) . returns ( 0 ) ;
286+ const contentUpdater = sinon . stub ( ) . resolves ( ) ;
287+
288+ const wrapper = shallowEditMode ( {
289+ originalContent : { id : 'id-0' , body : 'original' } ,
290+ confirm,
291+ contentUpdater,
292+ render : ( ) => < div className = "original" /> ,
293+ } ) ;
294+
295+ wrapper . find ( 'AtomTextEditor' ) . prop ( 'buffer' ) . setText ( 'new text' ) ;
296+ await wrapper . find ( '.github-Review-editableCancelButton' ) . prop ( 'onClick' ) ( ) ;
297+ assert . isTrue ( confirm . called ) ;
298+ assert . isFalse ( contentUpdater . called ) ;
299+ assert . isFalse ( wrapper . exists ( '.github-Review-editable' ) ) ;
300+ assert . isTrue ( wrapper . exists ( '.original' ) ) ;
301+ } ) ;
302+
303+ it ( 'remains in editing mode when the user cancels' , async function ( ) {
304+ const confirm = sinon . stub ( ) . returns ( 1 ) ;
275305
276- it ( 'remains in editing mode when the user cancels' ) ;
306+ const wrapper = shallowEditMode ( {
307+ originalContent : { id : 'id-0' , body : 'original' } ,
308+ confirm,
309+ render : ( ) => < div className = "original" /> ,
310+ } ) ;
311+
312+ wrapper . find ( 'AtomTextEditor' ) . prop ( 'buffer' ) . setText ( 'new text' ) ;
313+ await wrapper . find ( '.github-Review-editableCancelButton' ) . prop ( 'onClick' ) ( ) ;
314+ assert . isTrue ( confirm . called ) ;
315+ assert . isTrue ( wrapper . exists ( '.github-Review-editable' ) ) ;
316+ assert . isFalse ( wrapper . exists ( '.original' ) ) ;
317+ } ) ;
277318 } ) ;
278319 } ) ;
279320 } ) ;
0 commit comments