@@ -70,7 +70,7 @@ describe("Editor", () => {
7070 selectedSource : I . fromJS ( { loadedState : "loading" } )
7171 } ) ;
7272
73- expect ( mockEditor . setText . mock . calls ) . toEqual ( [ [ "Loading…" ] ] ) ;
73+ expect ( mockEditor . setText . mock . calls ) . toEqual ( [ [ "" ] , [ " Loading…"] ] ) ;
7474 expect ( mockEditor . codeMirror . scrollTo . mock . calls ) . toEqual ( [ ] ) ;
7575 } ) ;
7676 } ) ;
@@ -86,11 +86,54 @@ describe("Editor", () => {
8686 selectedLocation : { sourceId : "foo" , line : 3 , column : 1 }
8787 } ) ;
8888
89- expect ( mockEditor . setText . mock . calls ) . toEqual ( [ [ "the text" ] ] ) ;
89+ expect ( mockEditor . setText . mock . calls ) . toEqual ( [ [ "" ] , [ " the text"] ] ) ;
9090 expect ( mockEditor . codeMirror . scrollTo . mock . calls ) . toEqual ( [ [ 1 , 2 ] ] ) ;
9191 } ) ;
9292 } ) ;
9393
94+ describe ( "When error" , ( ) => {
95+ it ( "should show error text" , async ( ) => {
96+ const { component, mockEditor, props } = render ( { } ) ;
97+
98+ await component . setState ( { editor : mockEditor } ) ;
99+ await component . setProps ( {
100+ ...props ,
101+ selectedSource : createMockSource ( {
102+ loadedState : "loaded" ,
103+ text : undefined ,
104+ error : "error text"
105+ } ) ,
106+ selectedLocation : { sourceId : "bad-foo" , line : 3 , column : 1 }
107+ } ) ;
108+
109+ expect ( mockEditor . setText . mock . calls ) . toEqual ( [
110+ [ "" ] ,
111+ [ "Error loading this URI: error text" ]
112+ ] ) ;
113+ } ) ;
114+
115+ it ( "should show wasm error" , async ( ) => {
116+ const { component, mockEditor, props } = render ( { } ) ;
117+
118+ await component . setState ( { editor : mockEditor } ) ;
119+ await component . setProps ( {
120+ ...props ,
121+ selectedSource : createMockSource ( {
122+ loadedState : "loaded" ,
123+ isWasm : true ,
124+ text : undefined ,
125+ error : "blah WebAssembly binary source is not available blah"
126+ } ) ,
127+ selectedLocation : { sourceId : "bad-foo" , line : 3 , column : 1 }
128+ } ) ;
129+
130+ expect ( mockEditor . setText . mock . calls ) . toEqual ( [
131+ [ "" ] ,
132+ [ "Please refresh to debug this module" ]
133+ ] ) ;
134+ } ) ;
135+ } ) ;
136+
94137 describe ( "When navigating to a loading source" , ( ) => {
95138 it ( "should show loading message and not scroll" , async ( ) => {
96139 const { component, mockEditor, props } = render ( { } ) ;
@@ -113,6 +156,7 @@ describe("Editor", () => {
113156 } ) ;
114157
115158 expect ( mockEditor . setText . mock . calls ) . toEqual ( [
159+ [ "" ] ,
116160 [ "the text" ] ,
117161 [ "Loading…" ]
118162 ] ) ;
@@ -142,6 +186,7 @@ describe("Editor", () => {
142186 } ) ;
143187
144188 expect ( mockEditor . setText . mock . calls ) . toEqual ( [
189+ [ "" ] ,
145190 [ "Loading…" ] ,
146191 [ "the text" ]
147192 ] ) ;
0 commit comments