public async Task it_registers_formatters() { using var kernel = new CompositeKernel(); var kernelExtension = new SandDanceKernelExtension(); await kernelExtension.OnLoadAsync(kernel); var data = new[] { new { Type = "orange", Price = 1.2 }, new { Type = "apple", Price = 1.3 }, new { Type = "grape", Price = 1.4 } }; var formatted = data.ExploreWithSandDance().ToDisplayString(HtmlFormatter.MimeType); formatted.Should().Contain("configureRequireFromExtension('SandDance','1.0.0')(['SandDance/sanddanceapi'], (sandDance) => {"); }
public async Task it_can_load_script_from_the_extension() { using var kernel = new CompositeKernel(); var kernelExtension = new SandDanceKernelExtension(); await kernelExtension.OnLoadAsync(kernel); var data = new[] { new { Type = "orange", Price = 1.2 }, new { Type = "apple", Price = 1.3 }, new { Type = "grape", Price = 1.4 } }; var formatted = data.ExploreWithSandDance().ToDisplayString(HtmlFormatter.MimeType); formatted.Should().Contain("configureRequireFromExtension"); }
public async Task it_can_loads_script_from_uri() { using var kernel = new CompositeKernel(); var kernelExtension = new SandDanceKernelExtension(); SandDanceExplorerExtensions.Settings.UseUri("https://a.cdn.url/script.js"); await kernelExtension.OnLoadAsync(kernel); var data = new[] { new { Type = "orange", Price = 1.2 }, new { Type = "apple", Price = 1.3 }, new { Type = "grape", Price = 1.4 } }; var formatted = data.ExploreWithSandDance().ToDisplayString(HtmlFormatter.MimeType); formatted.Should().Contain("require.config("); }
public async Task can_specify_cacheBuster() { using var kernel = new CompositeKernel(); var kernelExtension = new SandDanceKernelExtension(); SandDanceExplorerExtensions.Settings.UseUri("https://a.cdn.url/script.js", cacheBuster: "XYZ"); await kernelExtension.OnLoadAsync(kernel); var data = new[] { new { Type = "orange", Price = 1.2 }, new { Type = "apple", Price = 1.3 }, new { Type = "grape", Price = 1.4 } }; var formatted = data.ExploreWithSandDance().ToDisplayString(HtmlFormatter.MimeType); formatted.Should().Contain("'urlArgs': 'cacheBuster=XYZ'"); }
public async Task uri_is_quoted() { using var kernel = new CompositeKernel(); var kernelExtension = new SandDanceKernelExtension(); await kernelExtension.OnLoadAsync(kernel); var data = new[] { new { Type = "orange", Price = 1.2 }, new { Type = "apple", Price = 1.3 }, new { Type = "grape", Price = 1.4 } }; var explorer = data.ExploreWithSandDance(); explorer.LibraryUri = new Uri("https://a.cdn.url/script.js"); var formatted = explorer.ToDisplayString(HtmlFormatter.MimeType); formatted.Should().Contain("'https://a.cdn.url/script'"); }
public async Task it_can_loads_script_from_uri_and_specify_context() { using var kernel = new CompositeKernel(); var kernelExtension = new SandDanceKernelExtension(); await kernelExtension.OnLoadAsync(kernel); kernel.UseSandDanceExplorer("https://a.cdn.url/script.js", "2.2.2"); var data = new[] { new { Type = "orange", Price = 1.2 }, new { Type = "apple", Price = 1.3 }, new { Type = "grape", Price = 1.4 } }; var formatted = data.ExploreWithSandDance().ToDisplayString(HtmlFormatter.MimeType); formatted.Should().Contain("'context': '2.2.2'"); }
public async Task it_checks_and_load_require() { using var kernel = new CompositeKernel(); var kernelExtension = new SandDanceKernelExtension(); DataExplorerExtensions.Settings.UseUri("https://a.cdn.url/script.js"); await kernelExtension.OnLoadAsync(kernel); var data = new[] { new { Type = "orange", Price = 1.2 }, new { Type = "apple", Price = 1.3 }, new { Type = "grape", Price = 1.4 } }; var formatted = data.ExploreWithSandDance().ToDisplayString(HtmlFormatter.MimeType); formatted.Should() .Contain("if ((typeof(require) !== typeof(Function)) || (typeof(require.config) !== typeof(Function)))") .And .Contain("require_script.onload = function()"); }
public async Task uri_extension_is_removed() { using var kernel = new CompositeKernel(); var kernelExtension = new SandDanceKernelExtension(); await kernelExtension.OnLoadAsync(kernel); kernel.UseSandDanceExplorer("https://a.cdn.url/script.js"); var data = new[] { new { Type = "orange", Price = 1.2 }, new { Type = "apple", Price = 1.3 }, new { Type = "grape", Price = 1.4 } }; var formatted = data.ExploreWithSandDance().ToDisplayString(HtmlFormatter.MimeType); formatted.Should() .Contain("'https://a.cdn.url/script'") .And .NotContain("'https://a.cdn.url/script.js'"); }