public void ReplacesScriptResource() { // Given TestExecutionContext context = new TestExecutionContext(); IDocument document = new TestDocument( @"<html> <head> <script src=""https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.auto.min.js""></script> </head> <body> </body> </html>"); MirrorResources module = new MirrorResources(); // When List <IDocument> result = module.Execute(new[] { document }, context).ToList(); // Then result.Single().Content.ShouldBe( @"<html><head> <script src=""/mirror/cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.auto.min.js""></script> </head> <body> </body></html>", StringCompareShould.IgnoreLineEndings); }
public void DoesNotReplaceDataNoMirrorAttribute() { // Given TestExecutionContext context = new TestExecutionContext(); IDocument document = new TestDocument( @"<html> <head> <script src=""https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.auto.min.js"" data-no-mirror></script> <link rel=""stylesheet"" href=""https://cdn.jsdelivr.net/npm/@@progress/[email protected]/dist/all.min.css"" data-no-mirror /> </head> <body> </body> </html>"); MirrorResources module = new MirrorResources(); // When List <IDocument> result = module.Execute(new[] { document }, context).ToList(); // Then result.Single().Content.ShouldBe( @"<html> <head> <script src=""https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.auto.min.js"" data-no-mirror></script> <link rel=""stylesheet"" href=""https://cdn.jsdelivr.net/npm/@@progress/[email protected]/dist/all.min.css"" data-no-mirror /> </head> <body> </body> </html>", StringCompareShould.IgnoreLineEndings); }
public async Task UsesCustomMirrorPath() { // Given TestDocument document = new TestDocument( @"<html> <head> <script src=""https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.auto.min.js""></script> </head> <body> </body> </html>"); MirrorResources module = new MirrorResources(x => new FilePath("/foo/bar.js")); // When TestDocument result = await ExecuteAsync(document, module).SingleAsync(); // Then result.Content.ShouldBe( @"<html><head> <script src=""/foo/bar.js""></script> </head> <body> </body></html>", StringCompareShould.IgnoreLineEndings); }
public async Task DoesNotReplaceDataNoMirrorAttribute() { // Given TestDocument document = new TestDocument( @"<html> <head> <script src=""https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.auto.min.js"" data-no-mirror></script> <link rel=""stylesheet"" href=""https://cdn.jsdelivr.net/npm/@@progress/[email protected]/dist/all.min.css"" data-no-mirror /> </head> <body> </body> </html>"); MirrorResources module = new MirrorResources(); // When TestDocument result = await ExecuteAsync(document, module).SingleAsync(); // Then result.Content.ShouldBe( @"<html> <head> <script src=""https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.auto.min.js"" data-no-mirror></script> <link rel=""stylesheet"" href=""https://cdn.jsdelivr.net/npm/@@progress/[email protected]/dist/all.min.css"" data-no-mirror /> </head> <body> </body> </html>", StringCompareShould.IgnoreLineEndings); }
public async Task ReplacesLinkResource() { // Given TestDocument document = new TestDocument( @"<html> <head> <link rel=""stylesheet"" href=""https://cdn.jsdelivr.net/npm/@@progress/[email protected]/dist/all.min.css"" /> </head> <body> </body> </html>"); MirrorResources module = new MirrorResources(); // When TestDocument result = await ExecuteAsync(document, module).SingleAsync(); // Then result.Content.ShouldBe( @"<html><head> <link rel=""stylesheet"" href=""/mirror/cdn.jsdelivr.net/npm/@@progress/[email protected]/dist/all.min.css""> </head> <body> </body></html>", StringCompareShould.IgnoreLineEndings); }
public async Task DoesNotReplaceRelativePaths() { // Given TestDocument document = new TestDocument( @"<html> <head> <link rel=""apple-touch-icon"" sizes=""120x120"" href=""/apple-touch-icon.png""> </head> <body> </body> </html>"); MirrorResources module = new MirrorResources(); // When TestDocument result = await ExecuteAsync(document, module).SingleAsync(); // Then result.Content.ShouldBe( @"<html> <head> <link rel=""apple-touch-icon"" sizes=""120x120"" href=""/apple-touch-icon.png""> </head> <body> </body> </html>", StringCompareShould.IgnoreLineEndings); }
public async Task KeepsIndexFileName() { // Given TestExecutionContext context = new TestExecutionContext(); context.Settings[Keys.LinkHideIndexPages] = "true"; TestDocument document = new TestDocument( @"<html> <head> <script src=""https://cdn.jsdelivr.net/npm/es6-promise/dist/index.min.js""></script> </head> <body> </body> </html>"); MirrorResources module = new MirrorResources(); // When TestDocument result = await ExecuteAsync(document, context, module).SingleAsync(); // Then result.Content.ShouldBe( @"<html><head> <script src=""/mirror/cdn.jsdelivr.net/npm/es6-promise/dist/index.min.js""></script> </head> <body> </body></html>", StringCompareShould.IgnoreLineEndings); }