Skip to content
\n

But the click event has been removed from the stick and replaced by pointerdown/pointerup on the parent which then uses event.target to get the value stored in the stick's attribute (+This has been moved to JavasScript).

\n

What's the canonical way to trigger a pointer event on a higher element at the exact location of the mud-minute? Trying to keep it simple as there's dozens of tests like this.

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

That is a very good question. Given the more \"integration\" nature of the test, I'm leaning towards the fact that using bUnit for that specific instance doesn't help you much.

\n

Whatever you do (as you emulate and set up all JS interop) will most likely result in testing the test code (your JS Mock setup).
\nThe obvious candidate would be something like Playwright/Cypress/... but that would be an entire new approach as far as I could see in MudBlazor's codebase.

\n

Another approach might be to introduce an humble object that does the JS interop:

\n
public interface IClockJsInterop\n{\n    Task<int> GetStickValueAsync(ElementReference clockElement, double clientX, double clientY);\n}
\n

Which you could set:

\n
var jsInteropMock = CreateIClockJsInteropMock();\njsInteropMock.Setup(js => js.GetStickValueAsync(It.IsAny<ElementReference>(), It.IsAny<double>(), It.IsAny<double>()))\n                 .ReturnsAsync(30);
","upvoteCount":0,"url":"https://github.com/bUnit-dev/bUnit/discussions/1497#discussioncomment-9997296"}}}

Handling a click event at the location of a child element #1497

Answered by linkdotnet
danielchalmers asked this question in Q&A
Discussion options

You must be logged in to vote

That is a very good question. Given the more "integration" nature of the test, I'm leaning towards the fact that using bUnit for that specific instance doesn't help you much.

Whatever you do (as you emulate and set up all JS interop) will most likely result in testing the test code (your JS Mock setup).
The obvious candidate would be something like Playwright/Cypress/... but that would be an entire new approach as far as I could see in MudBlazor's codebase.

Another approach might be to introduce an humble object that does the JS interop:

public interface IClockJsInterop
{
    Task<int> GetStickValueAsync(ElementReference clockElement, double clientX, double clientY);
}

Which you could set:

Replies: 1 comment 2 replies

Comment options

linkdotnet
Jul 8, 2024
Maintainer Sponsor

You must be logged in to vote
2 replies
@danielchalmers
Comment options

@linkdotnet
Comment options

linkdotnet Jul 9, 2024
Maintainer Sponsor

Answer selected by danielchalmers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants