@@ -133,6 +133,13 @@ describe('Console', () => {
133133 expect ( promptSpy ) . toHaveBeenCalledOnceWith ( 'give me a line!' ) ;
134134 expect ( windowPromptSpy ) . toHaveBeenCalledOnceWith ( 'modified prompt' ) ;
135135 } ) ;
136+ it ( 'Prints a parsed result' , ( ) => {
137+ const promptSpy = spyOn ( window , 'prompt' ) . and . returnValue ( 'hiya' ) ;
138+ const outputSpy = jasmine . createSpy ( ) ;
139+ const c = new Console ( { output : outputSpy } ) ;
140+ c . readLine ( 'give me a line!' ) ;
141+ expect ( outputSpy . calls . allArgs ( ) ) . toEqual ( [ [ 'give me a line!' ] , [ 'hiya' , '\n' ] ] ) ;
142+ } ) ;
136143 } ) ;
137144 describe ( 'readFloat' , ( ) => {
138145 it ( 'Errors for >1 argument' , ( ) => {
@@ -211,6 +218,20 @@ describe('Console', () => {
211218 expect ( promptSpy ) . toHaveBeenCalledOnceWith ( 'give me an int!' ) ;
212219 expect ( windowPromptSpy ) . toHaveBeenCalledOnceWith ( 'modified prompt' ) ;
213220 } ) ;
221+ it ( 'Prints a parsed result' , ( ) => {
222+ const promptSpy = spyOn ( window , 'prompt' ) . and . returnValue ( 1 ) ;
223+ const outputSpy = jasmine . createSpy ( ) ;
224+ const c = new Console ( { output : outputSpy } ) ;
225+ c . readInt ( 'give me an int!' ) ;
226+ expect ( outputSpy . calls . allArgs ( ) ) . toEqual ( [ [ 'give me an int!' ] , [ 1 , '\n' ] ] ) ;
227+ } ) ;
228+ it ( 'Doesnt print a default value' , ( ) => {
229+ const promptSpy = spyOn ( window , 'prompt' ) . and . returnValue ( null ) ;
230+ const outputSpy = jasmine . createSpy ( ) ;
231+ const c = new Console ( { output : outputSpy } ) ;
232+ c . readInt ( 'give me an int!' ) ;
233+ expect ( outputSpy . calls . allArgs ( ) ) . toEqual ( [ ] ) ;
234+ } ) ;
214235 } ) ;
215236 describe ( 'readBoolean' , ( ) => {
216237 it ( 'Errors for >1 argument' , ( ) => {
0 commit comments