< Summary

Information
Class: Pomodoro.Web.Services.JSInteropService
Assembly: Pomodoro.Web
File(s): /home/runner/work/Pomodoro/Pomodoro/src/Pomodoro.Web/Services/IJSInteropService.cs
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 47
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
InvokeVoidAsync(...)100%11100%
InvokeAsync(...)100%11100%

File(s)

/home/runner/work/Pomodoro/Pomodoro/src/Pomodoro.Web/Services/IJSInteropService.cs

#LineLine coverage
 1using Microsoft.JSInterop;
 2
 3namespace Pomodoro.Web.Services;
 4
 5/// <summary>
 6/// Service for JavaScript interop operations to enable mocking
 7/// </summary>
 8public interface IJSInteropService
 9{
 10    /// <summary>
 11    /// Invokes a JavaScript function that doesn't return a value
 12    /// </summary>
 13    /// <param name="identifier">The identifier of the function to invoke</param>
 14    /// <param name="args">Arguments to pass to the function</param>
 15    Task InvokeVoidAsync(string identifier, params object[] args);
 16
 17    /// <summary>
 18    /// Invokes a JavaScript function that returns a value
 19    /// </summary>
 20    /// <typeparam name="TValue">The return type</typeparam>
 21    /// <param name="identifier">The identifier of the function to invoke</param>
 22    /// <param name="args">Arguments to pass to the function</param>
 23    Task<TValue> InvokeAsync<TValue>(string identifier, params object[] args);
 24}
 25
 26/// <summary>
 27/// Default implementation of IJSInteropService that delegates to IJSRuntime
 28/// </summary>
 29public class JSInteropService : IJSInteropService
 30{
 31    private readonly IJSRuntime _jsRuntime;
 32
 1033    public JSInteropService(IJSRuntime jsRuntime)
 1034    {
 1035        _jsRuntime = jsRuntime;
 1036    }
 37
 38    public Task InvokeVoidAsync(string identifier, params object[] args)
 239    {
 240        return _jsRuntime.InvokeVoidAsync(identifier, args).AsTask();
 241    }
 42
 43    public Task<TValue> InvokeAsync<TValue>(string identifier, params object[] args)
 544    {
 545        return _jsRuntime.InvokeAsync<TValue>(identifier, args).AsTask();
 546    }
 47}