public async Task uri_extension_is_removed()
        {
            using var kernel = new CompositeKernel();

            var kernelExtension = new NteractKernelExtension();
            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.ExploreWithNteract();

            explorer.LibraryUri = new Uri("https://a.cdn.url/script.js");
            var formatted = explorer.ToDisplayString(HtmlFormatter.MimeType);

            formatted.Should()
            .Contain("'https://a.cdn.url/script'")
            .And
            .NotContain("'https://a.cdn.url/script.js'");
        }
        public async Task it_checks_and_load_require()
        {
            using var kernel = new CompositeKernel();

            var kernelExtension = new NteractKernelExtension();
            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.ExploreWithNteract();

            explorer.LibraryUri = new Uri("https://a.cdn.url/script.js");
            var formatted = explorer.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 it_can_load_script_from_the_extension()
        {
            using var kernel = new CompositeKernel();

            var kernelExtension = new NteractKernelExtension();

            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.ExploreWithNteract().ToDisplayString(HtmlFormatter.MimeType);

            formatted.Should().Contain("configureRequireFromExtension");
        }
Ejemplo n.º 4
0
        public async Task it_registers_formatters()
        {
            using var kernel = new CompositeKernel();

            var kernelExtension = new NteractKernelExtension();

            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.ExploreWithNteract().ToDisplayString(HtmlFormatter.MimeType);

            formatted.Should().Contain("configureRequireFromExtension('nteract','1.0.0')(['nteract/nteractapi'], (nteract) => {");
        }
Ejemplo n.º 5
0
        public async Task it_can_loads_script_from_uri_and_specify_context()
        {
            using var kernel = new CompositeKernel();

            var kernelExtension = new NteractKernelExtension();
            await kernelExtension.OnLoadAsync(kernel);

            kernel.UseNteractDataExplorer("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.ExploreWithNteract().ToDisplayString(HtmlFormatter.MimeType);

            formatted.Should().Contain("'context': '2.2.2'");
        }
        public async Task widget_code_generation_is_not_broken()
        {
            using var kernel = new CompositeKernel();

            var kernelExtension = new NteractKernelExtension();

            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 html = data.ExploreWithNteract().ToDisplayString(HtmlFormatter.MimeType);

            this.Assent(html.FixedGuid());
        }
        public async Task it_registers_formatters()
        {
            using var kernel = new CompositeKernel();

            var kernelExtension = new NteractKernelExtension();

            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.ToTabularJsonString().ToDisplayString(HtmlFormatter.MimeType);

            formatted.Should().Contain("getExtensionRequire('nteract','1.0.0')(['nteract/index'], (nteract) => {");
        }
Ejemplo n.º 8
0
        public async Task can_specify_cacheBuster()
        {
            using var kernel = new CompositeKernel();

            var kernelExtension = new NteractKernelExtension();
            await kernelExtension.OnLoadAsync(kernel);

            kernel.UseNteractDataExplorer("https://a.cdn.url/script.js", cacheBuster: "XYZ");

            var data = new[]
            {
                new { Type = "orange", Price = 1.2 },
                new { Type = "apple", Price = 1.3 },
                new { Type = "grape", Price = 1.4 }
            };


            var formatted = data.ExploreWithNteract().ToDisplayString(HtmlFormatter.MimeType);

            formatted.Should().Contain("'urlArgs': 'cacheBuster=XYZ'");
        }
        public async Task it_can_loads_script_from_uri()
        {
            using var kernel = new CompositeKernel();

            var kernelExtension = new NteractKernelExtension();
            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.ExploreWithNteract();

            explorer.LibraryUri = new Uri("https://a.cdn.url/script.js");
            var formatted = explorer.ToDisplayString(HtmlFormatter.MimeType);

            formatted.Should().Contain("require.config(");
        }
        public async Task uri_extension_is_removed()
        {
            using var kernel = new CompositeKernel();

            var kernelExtension = new NteractKernelExtension();

            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.ToTabularJsonString().ToDisplayString(HtmlFormatter.MimeType);

            formatted.Should().NotContain("'https://a.cdn.url/script.js'");
        }