|
2 | 2 |
|
3 | 3 | All notable changes to **bUnit** will be documented in this file. The project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
4 | 4 |
|
| 5 | +<!-- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) --> |
| 6 | + |
| 7 | +## [UNRELEASED BETA 11] |
| 8 | + |
| 9 | +The following section list all changes in beta-11. |
| 10 | + |
| 11 | +### Added |
| 12 | +List of new features. |
| 13 | + |
| 14 | +- Two new overloads to the `RenderFragment()` and `ChildContent()` component parameter factory methods have been added that takes a `RenderFragment` as input. By [@egil](https://github.com/egil) in [#203](https://github.com/egil/bUnit/pull/203). |
| 15 | + |
| 16 | +- Added a `ComponentParameterCollection` type. The `ComponentParameterCollection` is a collection of component parameters, that knows how to turn those components parameters into a `RenderFragment`, which will render a component and pass any parameters inside the collection to that component. That logic was spread out over multiple places in bUnit, and is now owned by the `ComponentParameterCollection` type. By [@egil](https://github.com/egil) in [#203](https://github.com/egil/bUnit/pull/203). |
| 17 | + |
| 18 | +- Added additional placeholder services for `NavigationManager`, `HttpClient`, and `IStringLocalizer`, to make it easier for users to figure out why a test is failing due to missing service registration before rendering a component. By [@joro550](https://github.com/joro550) in [#223](https://github.com/egil/bUnit/pull/223). |
| 19 | + |
| 20 | +- Added `Key` class that represents a keyboard key and helps to avoid constructing `KeyboardEventArgs` object manually. The key can be passed to `KeyPress`, `KeyDown`, or `KeyUp` helper methods to raise keyboard events. The `Key` class provides static special keys or can be obtained from character or string. Keys can be combined with key modifiers: `Key.Enter + Key.Alt`. |
| 21 | + |
| 22 | + For example, this makes it easier to trigger keyboard events on an element: |
| 23 | + |
| 24 | + ```csharp |
| 25 | + var cut = ctx.RenderComponent<ComponentWithKeyboardEvents>(); |
| 26 | + var element = cut.Find("input"); |
| 27 | + |
| 28 | + element.KeyDown(Key.Enter + Key.Control); // Triggers onkeydown event with Ctrl + Enter |
| 29 | + element.KeyUp(Key.Control + Key.Shift + 'B'); // Triggers onkeyup event with Ctrl + Shift + B |
| 30 | + element.KeyPress('1'); // Triggers onkeypress event with key 1 |
| 31 | + element.KeyDown(Key.Alt + "<"); // Triggers onkeydown event with Alt + < |
| 32 | + ``` |
| 33 | + |
| 34 | + By [@duracellko](https://github.com/duracellko) in [#101](https://github.com/egil/bUnit/issues/101). |
| 35 | + |
| 36 | +- Added support for registering/adding components to a test context root render tree, which components under test is rendered inside. This allows you to simplify the "arrange" step of a test when a component under test requires a certain render tree as its parent, e.g. a cascading value. |
| 37 | + |
| 38 | + For example, to pass a cascading string value `foo` to all components rendered with the test context, do the following: |
| 39 | + |
| 40 | + ```csharp |
| 41 | + ctx.RenderTree<CascadingValue<string>>(parameters => parameters.Add(p => p.Value, "foo")); |
| 42 | + var cut = ctx.RenderComponent<ComponentReceivingFoo>(); |
| 43 | + ``` |
| 44 | + |
| 45 | + By [@egil](https://github.com/egil) in [#236](https://github.com/egil/bUnit/pull/236). |
| 46 | + |
| 47 | +- Added "catch-all" `Setup` method to bUnit's mock JS runtime, that allows you to specify only the type when setting up a planned invocation. By [@nemesv](https://github.com/nemesv) in [#234](https://github.com/egil/bUnit/issues/234). |
| 48 | + |
| 49 | +### Changed |
| 50 | +List of changes in existing functionality. |
| 51 | + |
| 52 | +- The `ComponentParameterBuilder` has been renamed to `ComponentParameterCollectionBuilder`, since it now builds the `ComponentParameterCollection` type, introduced in this release of bUnit. By [@egil](https://github.com/egil) in [#203](https://github.com/egil/bUnit/pull/203). |
| 53 | + |
| 54 | +- `ComponentParameterCollectionBuilder` now allows adding cascading values that is not directly used by the component type it targets. This makes it possible to add cascading values to children of the target component. By [@egil](https://github.com/egil) in [#203](https://github.com/egil/bUnit/pull/203). |
| 55 | + |
| 56 | +- The `Add(object)` has been replaced by `AddCascadingValue(object)` in `ComponentParameterCollectionBuilder`, to make it more clear that an unnamed cascading value is being passed to the target component or one of its child components. It is also possible to pass unnamed cascading values using the `Add(parameterSelector, value)` method, which now correctly detect if the selected cascading value parameter is named or unnamed. By [@egil](https://github.com/egil) in [#203](https://github.com/egil/bUnit/pull/203). |
| 57 | + |
| 58 | +- It is now possible to call the `Add()`, `AddChildContent()` methods on `ComponentParameterCollectionBuilder`, and the factory methods `RenderFragment()`, `ChildContent()`, and `Template()`, _**multiple times**_ for the same parameter, if it is of type `RenderFragment` or `RenderFragment<TValue>`. Doing so previously would either result in an exception or just the last passed `RenderFragment` to be used. Now all the provided `RenderFragment` or `RenderFragment<TValue>` will be combined at runtime into a single `RenderFragment` or `RenderFragment<TValue>`. |
| 59 | + |
| 60 | + For example, this makes it easier to pass e.g. both a markup string and a component to a `ChildContent` parameter: |
| 61 | + |
| 62 | + ```csharp |
| 63 | + var cut = ctx.RenderComponent<Component>(parameters => parameters |
| 64 | + .AddChildContent("<h1>Below you will find a most interesting alert!</h1>") |
| 65 | + .AddChildContent<Alert>(childParams => childParams |
| 66 | + .Add(p => p.Heading, "Alert heading") |
| 67 | + .Add(p => p.Type, AlertType.Warning) |
| 68 | + .AddChildContent("<p>Hello World</p>") |
| 69 | + ) |
| 70 | + ); |
| 71 | + ``` |
| 72 | + By [@egil](https://github.com/egil) in [#203](https://github.com/egil/bUnit/pull/203). |
| 73 | + |
| 74 | +- All test doubles are now in the same namespace, `Bunit.TestDoubles`. So all import statements for `Bunit.TestDoubles.JSInterop` and `Bunit.TestDoubles.Authorization` must be changed to `Bunit.TestDoubles`. By [@egil](https://github.com/egil) in [#223](https://github.com/egil/bUnit/pull/223). |
| 75 | + |
| 76 | +- Marked MarkupMatches methods as assertion methods to stop SonarSource analyzers complaining about missing assertions in tests. By [@egil](https://github.com/egil) in [#229](https://github.com/egil/bUnit/pull/229). |
| 77 | + |
| 78 | +- `AddTestAuthorization` now extends `TestContext` instead of `TestServiceProvider`, and also automatically adds the `CascadingAuthenticationState` component to the root render tree. [@egil](https://github.com/egil) in [#237](https://github.com/egil/bUnit/pull/367). |
| 79 | + |
| 80 | +### Deprecated |
| 81 | +List of soon-to-be removed features. |
| 82 | + |
| 83 | +### Removed |
| 84 | +List of now removed features. |
| 85 | + |
| 86 | +- The async event dispatcher helper methods have been removed (e.g. `ClickAsync()`), as they do not provide any benefit. If you have an event that triggers async operations in the component under test, instead use `cut.WaitForState()` or `cut.WaitForAssertion()` to await the expected state in the component. |
| 87 | + |
| 88 | +### Fixed |
| 89 | +List of any bug fixes. |
| 90 | + |
| 91 | +- Using the ComponentParameterCollectionBuilder's `Add(p => p.Param, value)` method to add a unnamed cascading value didn't create an unnnamed cascading value parameter. By [@egil](https://github.com/egil) in [#203](https://github.com/egil/bUnit/pull/203). Credits to [Ben Sampica (@benjaminsampica)](https://github.com/benjaminsampica) for reporting and helping investigate this issue. |
| 92 | +- Triggered events now bubble correctly up the DOM tree and triggers other events of the same type. This is a **potentially breaking change,** since this changes the behaviour of event triggering and thus you might see tests start breaking as a result hereof. By [@egil](https://github.com/egil) in [#119](https://github.com/egil/bUnit/issues/119). |
| 93 | + |
5 | 94 | ## [1.0.0-beta 10] - 2020-09-15 |
6 | 95 |
|
7 | | -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) |
| 96 | +The following section list all changes in beta-10. |
8 | 97 |
|
9 | 98 | ### Added |
10 | 99 | List of new features. |
|
0 commit comments