7
7
* of patent rights can be found in the PATENTS file in the same directory.
8
8
*/
9
9
10
+ using System . Collections . Generic ;
10
11
using System . Threading ;
11
12
using JavaScriptEngineSwitcher . Core ;
12
13
using Moq ;
@@ -20,6 +21,8 @@ public class JavaScriptEngineFactoryTest
20
21
private JavaScriptEngineFactory CreateFactory ( )
21
22
{
22
23
var config = new Mock < IReactSiteConfiguration > ( ) ;
24
+ config . Setup ( x => x . ScriptsWithoutTransform ) . Returns ( new List < string > ( ) ) ;
25
+ config . Setup ( x => x . LoadReact ) . Returns ( true ) ;
23
26
var fileSystem = new Mock < IFileSystem > ( ) ;
24
27
var registration = new JavaScriptEngineFactory . Registration
25
28
{
@@ -81,5 +84,31 @@ public void ShouldCreateNewEngineForNewThread()
81
84
Assert . AreEqual ( engine1 , engine3 ) ;
82
85
factory . DisposeEngineForCurrentThread ( ) ;
83
86
}
87
+
88
+ [ Test ]
89
+ public void ShouldLoadFilesThatDoNotRequireTransform ( )
90
+ {
91
+ var jsEngine = new Mock < IJsEngine > ( ) ;
92
+ jsEngine . Setup ( x => x . Evaluate < int > ( "1 + 1" ) ) . Returns ( 2 ) ;
93
+
94
+ var config = new Mock < IReactSiteConfiguration > ( ) ;
95
+ config . Setup ( x => x . ScriptsWithoutTransform ) . Returns ( new List < string > { "First.js" , "Second.js" } ) ;
96
+ config . Setup ( x => x . LoadReact ) . Returns ( true ) ;
97
+
98
+ var fileSystem = new Mock < IFileSystem > ( ) ;
99
+ fileSystem . Setup ( x => x . ReadAsString ( It . IsAny < string > ( ) ) ) . Returns < string > ( path => "CONTENTS_" + path ) ;
100
+
101
+ var registration = new JavaScriptEngineFactory . Registration
102
+ {
103
+ Factory = ( ) => jsEngine . Object ,
104
+ Priority = 1
105
+ } ;
106
+ var factory = new JavaScriptEngineFactory ( new [ ] { registration } , config . Object , fileSystem . Object ) ;
107
+
108
+ factory . GetEngineForCurrentThread ( ) ;
109
+
110
+ jsEngine . Verify ( x => x . Execute ( "CONTENTS_First.js" ) ) ;
111
+ jsEngine . Verify ( x => x . Execute ( "CONTENTS_Second.js" ) ) ;
112
+ }
84
113
}
85
114
}
0 commit comments