Skip to content

Commit a0c6b1b

Browse files
authored
Merge branch 'main' into main
2 parents fb5bb40 + 5f74ff6 commit a0c6b1b

3 files changed

Lines changed: 32 additions & 23 deletions

File tree

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ about: Create a report to help us improve
44
title: ''
55
labels: ''
66
assignees: ''
7-
87
---
98

10-
**NOTE:** _Remove any parts of the template you do not need and replace the default text in each section with your own, including this._
9+
<!-- **NOTE:** Remove any parts of the template you do not need and
10+
replace the default text in each section with your own, including this. -->
11+
12+
**Describe the bug**
1113

12-
**Describe the bug or question**
13-
_A clear and concise description of what the bug or question is._
14+
<!-- A clear and concise description of the bug. This include a list of reproduction steps. -->
1415

1516
**Example:**
1617
Testing this component:
@@ -32,11 +33,15 @@ Message output from running the test.
3233
```
3334

3435
**Expected behavior:**
35-
A clear and concise description of what you expected to happen.
36+
37+
<!-- A clear and concise description of what you expected to happen. -->
3638

3739
**Version info:**
38-
- Library version:
39-
- .NET Core/Blazor version:
40+
41+
- bUnit version:
42+
- .NET Runtime and Blazor version:
43+
- OS type and version:
4044

4145
**Additional context:**
42-
Add any other context about the problem here.
46+
47+
<!-- Add any other context about the problem here. -->
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
---
22
name: Feature request
3-
about: Suggest an idea for this project
3+
about: Suggest an idea or enhancement for this project
44
title: ''
55
labels: ''
66
assignees: ''
77

88
---
99

10-
**NOTE:** _Remove any parts of the template you do not need and replace the default text in each section with your own, including this._
10+
<!-- NOTE: Remove any parts of the template not needed and fill in as needed. -->
1111

12-
**Is your feature request related to a problem? Please describe.**
13-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
**Is the feature request related to a problem? Please elaborate.**
1413

15-
**Describe the solution you'd like**
16-
A clear and concise description of what you want to happen.
14+
<!-- A clear and concise description of what the problem is. -->
1715

18-
**Describe alternatives you've considered**
19-
A clear and concise description of any alternative solutions or features you've considered.
16+
**The suggested solution**
17+
18+
<!-- A clear and concise description of the suggested solution. -->
19+
20+
**Describe any alternative solutions**
21+
22+
<!-- A clear and concise description of any alternative solutions or features considered. -->
2023

2124
**Additional context**
22-
Add any other context or screenshots about the feature request here.
25+
26+
<!-- Add any other context or screenshots about the feature request here. -->

docs/site/docs/test-doubles/emulating-ijsruntime.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: Emulating Blazor's IJSRuntime
77

88
It is common for Blazor components to use `IJSRuntime` to call JavaScript, and since bUnit does not run JavaScript, emulating `IJSRuntime` is needed for components that use it. In that regard, `IJSRuntime` is no different than other services that a component might depend on.
99

10-
bUnit comes with it's own JSInterop, a tailor-made implementation of `IJSRuntime` that is _active by default_, allowing you to specify how JavaScript interop calls should be handled and what values the calls should return, and also allowing you to verify that they the calls have happened. The implementation runs in "strict mode", which means means it will throw an exception if it receives an invocation it has not been configured to handle. See more about strict vs. loose mode in the following section.
10+
bUnit comes with it's own JSInterop, a tailor-made implementation of `IJSRuntime` that is _active by default_, allowing you to specify how JavaScript interop calls should be handled and what values the calls should return, and also allowing you to verify that they the calls have happened. The implementation runs in "strict mode", which means it will throw an exception if it receives an invocation it has not been configured to handle. See more about strict vs. loose mode in the following section.
1111

1212
If you prefer to use the same mocking framework for all mocking in your tests to keep things consistent, general-purpose mocking frameworks like [Moq](https://github.com/Moq), [JustMock Lite](https://github.com/telerik/JustMockLite), or [NSubstitute](https://nsubstitute.github.io/) all work nicely with bUnit and can be used to mock `IJSRuntime`. In general, registering an implementation of `IJSRuntime` with bUnit's `Services` collection replaces bUnit's implementation.
1313

@@ -27,7 +27,7 @@ By default, the bUnit's JSInterop runs in **Strict** mode. To change the mode, d
2727

2828
```csharp
2929
using var ctx = new TestContext();
30-
ctx.JSInterop.Mode = JSRuntimeMockMode.Loose;
30+
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
3131
```
3232

3333
## Setting up invocations
@@ -58,8 +58,8 @@ var plannedInvocation = ctx.JSInterop.SetupVoid("startAnimation");
5858
// only completes or throws, it doesn’t return a value.
5959
// Any calls to InvokeVoidAsync(...) up till this point will
6060
// have received an incomplete Task which the component
61-
// is awaiting until the call to SetCompleted() below.
62-
plannedInvocation.SetCompleted();
61+
// is awaiting until the call to SetVoidResult() below.
62+
plannedInvocation.SetVoidResult();
6363
```
6464

6565
## Verifying invocations
@@ -99,7 +99,7 @@ By default, a module Interop inherits the `Mode` setting from the root JSInterop
9999

100100
```csharp
101101
var moduleInterop = ctx.JSInterop.SetupModule("hello.js");
102-
moduleInterop.Mode = JSRuntimeMockMode.Loose;
102+
moduleInterop.Mode = JSRuntimeMode.Loose;
103103
```
104104

105105
### Support for `IJSInProcessObjectReference` and `IJSUnmarshalledObjectReference`
@@ -156,4 +156,4 @@ ctx.JSInterop.VerifyFocusAsyncInvoke() // Verifies that a FocusAsync call has ha
156156

157157
bUnit's `IJSRuntime` supports being cast to the `IJSInProcessRuntime` and `IJSUnmarshalledRuntime` types, just like Blazor's `IJSRuntime`.
158158

159-
To set up a handler for `Invoke` and `InvokeUnmarshalled` calls, just use the regular `Setup` and `SetupVoid` methods on bUnit's JSInterop.
159+
To set up a handler for `Invoke` and `InvokeUnmarshalled` calls, just use the regular `Setup` and `SetupVoid` methods on bUnit's JSInterop.

0 commit comments

Comments
 (0)