Skip to content

Commit

Permalink
Fixed common tests
Browse files Browse the repository at this point in the history
  • Loading branch information
quigamdev committed Feb 18, 2021
1 parent 757a217 commit aab5747
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,14 @@ public void StaticCommandCompilation_MarkupControlCommandPropertyUsed_WithSamePr
{
TestMarkupControl.CreateInitialized();

var result = CompileBinding("StringProp = _control.Chanege(StringProp) + injectedService.Load(StringProp)", niceMode: true, new[] { typeof(TestViewModel) }, typeof(Command), typeof(TestMarkupControl));
var result = CompileBinding("StringProp = _control.Change(StringProp) + injectedService.Load(StringProp)", niceMode: true, new[] { typeof(TestViewModel) }, typeof(Command), typeof(TestMarkupControl));

var expectedReslt = @"
(function(a, c, b) {
return new Promise(function(resolve, reject) {
(
b = dotvvm.staticCommandPostback(a, ""WARNING/NOT/ENCRYPTED+++WyJEb3RWVk0uRnJhbWV3b3JrLlRlc3RzLkJpbmRpbmcuVGVzdFNlcnZpY2UsIERvdFZWTS5GcmFtZXdvcmsuVGVzdHMuQ29tbW9uIiwiTG9hZCIsW10sIkFRQT0iXQ=="", [c.$data.StringProp()], options) ,
Promise.resolve(c.$control.Chanege()(c.$data.StringProp())).then(function(r_0) {
Promise.resolve(c.$control.Change()(c.$data.StringProp())).then(function(r_0) {
b.then(function(r_1) {
resolve(c.$data.StringProp(r_0 + r_1).StringProp());
}, reject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,28 @@ void checkConfig(DotvvmConfiguration config, string checkName = null, string fil
[TestMethod]
public void SerializeDefaultConfig()
{
checkConfig(DotvvmConfiguration.CreateDefault());
var c = DotvvmConfiguration.CreateDefault();
c.DefaultCulture = "en-US";
checkConfig(c);
}

private static DotvvmConfiguration CreateTestConfiguration()
{
var c = new DotvvmConfiguration();
c.DefaultCulture = "en-US";
return c;
}

[TestMethod]
public void SerializeEmptyConfig()
{
checkConfig(new DotvvmConfiguration());
checkConfig(CreateTestConfiguration());
}

[TestMethod]
public void SerializeRoutes()
{
var c = new DotvvmConfiguration();
var c = CreateTestConfiguration();

c.RouteTable.Add("route1", "url1", "file1.dothtml", new { a = "ccc" });
c.RouteTable.Add("route2", "url2/{int}", "file1.dothtml", new { a = "ccc" });
Expand All @@ -66,28 +75,29 @@ public void SerializeRoutes()
[TestMethod]
public void SerializeResources()
{
var c = new DotvvmConfiguration();
var c = CreateTestConfiguration();

c.Resources.Register("r1", new ScriptResource(
new UrlResourceLocation("x")) {
IntegrityHash = "hash, maybe",
VerifyResourceIntegrity = true,
RenderPosition = ResourceRenderPosition.Head
});
IntegrityHash = "hash, maybe",
VerifyResourceIntegrity = true,
RenderPosition = ResourceRenderPosition.Head
});
c.Resources.Register("r2", new ScriptResource(
new UrlResourceLocation("x")) {
Dependencies = new [] { "r1" },
LocationFallback = new ResourceLocationFallback("window.x", new IResourceLocation [] {
Dependencies = new[] { "r1" },
LocationFallback = new ResourceLocationFallback("window.x", new IResourceLocation[] {
new UrlResourceLocation("y"),
new UrlResourceLocation("z"),
new FileResourceLocation("some-script.js")
})
}
}
);
c.Resources.Register("r3", new StylesheetResource(
new UrlResourceLocation("s")) {
IntegrityHash = "hash, maybe",
VerifyResourceIntegrity = true
}
IntegrityHash = "hash, maybe",
VerifyResourceIntegrity = true
}
);
c.Resources.Register("r4", new InlineStylesheetResource("body { display: none }"));
c.Resources.Register("r5", new InlineStylesheetResource(new FileResourceLocation("some-style.css")));
Expand All @@ -97,25 +107,23 @@ public void SerializeResources()
c.Resources.Register("r9", new TemplateResource("<div></div>"));


checkConfig(c);
checkConfig(c);
}

[TestMethod]
public void ExperimentalFeatures()
{
var c = new DotvvmConfiguration();

c.ExperimentalFeatures.LazyCsrfToken.EnableForAllRoutesExcept(new [] { "r1", "r2" });
c.ExperimentalFeatures.ServerSideViewModelCache.EnableForRoutes(new [] { "r1", "r2" });
var c = CreateTestConfiguration();
c.ExperimentalFeatures.LazyCsrfToken.EnableForAllRoutesExcept(new[] { "r1", "r2" });
c.ExperimentalFeatures.ServerSideViewModelCache.EnableForRoutes(new[] { "r1", "r2" });

checkConfig(c);
checkConfig(c);
}

[TestMethod]
public void Markup()
{
var c = new DotvvmConfiguration();

var c = CreateTestConfiguration();
c.Markup.DefaultDirectives.Add("dir1", "MyDirective");
c.Markup.AddCodeControls("myControls", typeof(ControlLifeCycleMock));
c.Markup.AddMarkupControl("myControls", "C1", "./Controls/C1.dotcontrol");
Expand All @@ -126,31 +134,31 @@ public void Markup()
c.Markup.ImportedNamespaces.Add(new NamespaceImport("System.Collections", "Collections"));
c.Markup.HtmlAttributeTransforms.Add(new HtmlTagAttributePair { AttributeName = "data-uri", TagName = "div" }, new HtmlAttributeTransformConfiguration { Type = typeof(TranslateVirtualPathHtmlAttributeTransformer) });

checkConfig(c);
checkConfig(c);
}

[TestMethod]
public void RestAPI()
{
var c = new DotvvmConfiguration();
var c = CreateTestConfiguration();

c.RegisterApiClient(typeof(Binding.TestApiClient), "http://server/api", "./apiscript.js", "_testApi");

checkConfig(c);
checkConfig(c);
}

[TestMethod]
public void AuxOptions()
{
var c = new DotvvmConfiguration();
var c = CreateTestConfiguration();

c.Debug = true;
c.ApplicationPhysicalPath = "/opt/myApp";
c.ClientSideValidation = false;
c.DefaultCulture = "cs-CZ";
c.UseHistoryApiSpaNavigation = true;

checkConfig(c);
checkConfig(c);
}

}
Expand Down

0 comments on commit aab5747

Please sign in to comment.