-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for JS modules and importmaps
- Loading branch information
1 parent
0e8d85e
commit e93f3f9
Showing
11 changed files
with
495 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using AngleSharp.Io; | ||
using AngleSharp.Io.Network; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Net; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace AngleSharp.Js.Tests.Mocks | ||
{ | ||
/// <summary> | ||
/// Mock HttpClientRequester which returns content for a specific request from a local dictionary. | ||
/// </summary> | ||
internal class MockHttpClientRequester : HttpClientRequester | ||
{ | ||
private readonly Dictionary<string, string> _mockResponses; | ||
|
||
public MockHttpClientRequester(Dictionary<string, string> mockResponses) : base() | ||
{ | ||
_mockResponses = mockResponses; | ||
} | ||
|
||
protected override async Task<IResponse> PerformRequestAsync(Request request, CancellationToken cancel) | ||
{ | ||
var response = new DefaultResponse(); | ||
|
||
if (_mockResponses.TryGetValue(request.Address.PathName, out var responseContent)) | ||
{ | ||
response.StatusCode = HttpStatusCode.OK; | ||
response.Content = new MemoryStream(Encoding.UTF8.GetBytes(responseContent)); | ||
} | ||
else | ||
{ | ||
response.StatusCode = HttpStatusCode.NotFound; | ||
response.Content = new MemoryStream(Encoding.UTF8.GetBytes(string.Empty)); | ||
} | ||
|
||
return response; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.