forked from Blazor-Diagrams/Blazor.Diagrams
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from WiseTechGlobal/M71/WI00642713/NCN-Cursors
Introduced cursor change based on allow panning.
- Loading branch information
Showing
4 changed files
with
52 additions
and
2 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
tests/Blazor.Diagrams.Tests/Components/DiagramCursorTests.cs
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,49 @@ | ||
using AngleSharp.Css.Dom; | ||
using Blazor.Diagrams.Components; | ||
using Blazor.Diagrams.Core.Geometry; | ||
using Bunit; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Blazor.Diagrams.Core.Tests.Behaviors | ||
{ | ||
public class DiagramCursorTests | ||
{ | ||
[Fact] | ||
public void Behavior_WhenPanningOptionIsAllowed_CursorShouldBeGrab() | ||
{ | ||
// Arrange | ||
using var ctx = new TestContext(); | ||
var diagram = new BlazorDiagram(); | ||
diagram.Options.AllowPanning = true; | ||
ctx.JSInterop.Setup<Rectangle>("ZBlazorDiagrams.getBoundingClientRect", _ => true); | ||
|
||
// Act | ||
var cut = ctx.RenderComponent<DiagramCanvas>(parameters => parameters | ||
.Add(n => n.BlazorDiagram, diagram)); | ||
var diagramCanvas = cut.Find(".diagram-canvas"); | ||
|
||
// Assert | ||
diagramCanvas.ToMarkup().Should().Contain("cursor: grab; cursor: -webkit-grab;"); | ||
} | ||
|
||
[Fact] | ||
public void Behavior_WhenPanningOptionIsNotAllowed_CursorShouldBeDefault() | ||
{ | ||
// Arrange | ||
using var ctx = new TestContext(); | ||
var diagram = new BlazorDiagram(); | ||
diagram.Options.AllowPanning = false; | ||
ctx.JSInterop.Setup<Rectangle>("ZBlazorDiagrams.getBoundingClientRect", _ => true); | ||
|
||
// Act | ||
var cut = ctx.RenderComponent<DiagramCanvas>(parameters => parameters | ||
.Add(n => n.BlazorDiagram, diagram)); | ||
var diagramCanvas = cut.Find(".diagram-canvas"); | ||
var canvasStyle = diagramCanvas.GetStyle().CssText; | ||
|
||
// Assert | ||
canvasStyle.Should().Contain("cursor: default"); | ||
} | ||
} | ||
} |