public void GivenScriptHasNoTopLevelVarOrReturnExpressionThenDefineHasNoReturn() { var asset = new StubAsset("~/test.js"); var bundle = new ScriptBundle("~"); var module = new PlainScript(asset, bundle, modules.Object); var output = asset.OpenStream().ReadToEnd(); output.ShouldEqual("define(\"test\",[],function(){\r\n});"); }
public void AssetIsWrappedInDefineCall() { var asset = new StubAsset("~/test.js", "var test = {};"); var bundle = new ScriptBundle("~"); var module = new PlainScript(asset, bundle, modules.Object); var output = asset.OpenStream().ReadToEnd(); output.ShouldEqual("define(\"test\",[],function(){var test = {};\r\nreturn test;});"); }
public void AssetIsTransformedToIncludeModulePathInDefineCallWithNoDependencies() { var asset = new StubAsset("~/test.js", "define(function(){})"); var bundle = new ScriptBundle("~"); var module = new AnonymousModule(asset, bundle); var output = asset.OpenStream().ReadToEnd(); output.ShouldEqual("define(\"test\",function(){})"); }
public void AssetIsNotMinified() { var asset = new StubAsset("~/test.js", "define([],function(){var x = 1;})"); var bundle = new ScriptBundle("~"); var module = new AnonymousModule(asset, bundle); var output = asset.OpenStream().ReadToEnd(); output.ShouldEqual("define(\"test\",[],function(){var x = 1;})"); }
public void GivenScriptHasNoTopLevelVarOrReturnExpressionThenDefineHasNoReturn() { var asset = new StubAsset("~/test.js"); var bundle = new ScriptBundle("~"); var module = new PlainScript(asset, bundle, modules.Object); var output = asset.OpenStream().ReadToEnd(); output.ShouldEqual("define(\"test\",[],function(){\r\n});"); }
public void AssetIsWrappedInDefineCall() { var asset = new StubAsset("~/test.js", "var test = {};"); var bundle = new ScriptBundle("~"); var module = new PlainScript(asset, bundle, modules.Object); var output = asset.OpenStream().ReadToEnd(); output.ShouldEqual("define(\"test\",[],function(){var test = {};\r\nreturn test;});"); }
public void AssetIsNotMinified() { var asset = new StubAsset("~/test.js", "define([],function(){var x = 1;})"); var bundle = new ScriptBundle("~"); var module = new AnonymousModule(asset, bundle); var output = asset.OpenStream().ReadToEnd(); output.ShouldEqual("define(\"test\",[],function(){var x = 1;})"); }
public void AssetIsTransformedToIncludeModulePathInDefineCallWithNoDependencies() { var asset = new StubAsset("~/test.js", "define(function(){})"); var bundle = new ScriptBundle("~"); var module = new AnonymousModule(asset, bundle); var output = asset.OpenStream().ReadToEnd(); output.ShouldEqual("define(\"test\",function(){})"); }
public void DefineCallReturnsModuleReturnExpression() { var asset = new StubAsset("~/test.js", "var test = {};"); var bundle = new ScriptBundle("~"); var module = new PlainScript(asset, bundle, modules.Object) { ModuleReturnExpression = "{}" }; var output = asset.OpenStream().ReadToEnd(); output.ShouldEqual("define(\"test\",[],function(){var test = {};\r\nreturn {};});"); }
public void DefineCallReturnsModuleReturnExpression() { var asset = new StubAsset("~/test.js", "var test = {};"); var bundle = new ScriptBundle("~"); var module = new PlainScript(asset, bundle, modules.Object) { ModuleReturnExpression = "{}" }; var output = asset.OpenStream().ReadToEnd(); output.ShouldEqual("define(\"test\",[],function(){var test = {};\r\nreturn {};});"); }
public void AssetReferencesAreTranslatedIntoModuleDependencies() { SetupFakeModule("foo"); SetupFakeModule("bar"); var asset = new StubAsset("~/test.js"); asset.ReferenceList.Add(new AssetReference("~/test.js", "~/foo.js", 1, AssetReferenceType.SameBundle)); asset.ReferenceList.Add(new AssetReference("~/test.js", "~/bar.js", 1, AssetReferenceType.SameBundle)); var bundle = new ScriptBundle("~"); var module = new PlainScript(asset, bundle, modules.Object); var output = asset.OpenStream().ReadToEnd(); output.ShouldEqual("define(\"test\",[\"foo\",\"bar\"],function(foo,bar){\r\n});"); }
public void AssetReferencesAreTranslatedIntoModuleDependencies() { SetupFakeModule("foo"); SetupFakeModule("bar"); var asset = new StubAsset("~/test.js"); asset.ReferenceList.Add(new AssetReference("~/test.js", "~/foo.js", 1, AssetReferenceType.SameBundle)); asset.ReferenceList.Add(new AssetReference("~/test.js", "~/bar.js", 1, AssetReferenceType.SameBundle)); var bundle = new ScriptBundle("~"); var module = new PlainScript(asset, bundle, modules.Object); var output = asset.OpenStream().ReadToEnd(); output.ShouldEqual("define(\"test\",[\"foo\",\"bar\"],function(foo,bar){\r\n});"); }