< Summary

Information
Class: Chronicis.Client.Infrastructure.PageTitleService
Assembly: Chronicis.Client
File(s): /home/runner/work/chronicis/chronicis/src/Chronicis.Client/Infrastructure/PageTitleService.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 28
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%
SetTitleAsync(...)100%11100%

File(s)

/home/runner/work/chronicis/chronicis/src/Chronicis.Client/Infrastructure/PageTitleService.cs

#LineLine coverage
 1using Chronicis.Client.Abstractions;
 2using Chronicis.Client.Utilities;
 3using Microsoft.JSInterop;
 4
 5namespace Chronicis.Client.Infrastructure;
 6
 7/// <summary>
 8/// Implements <see cref="IPageTitleService"/> using <see cref="IJSRuntime"/>
 9/// to set the browser document title.
 10/// </summary>
 11public sealed class PageTitleService : IPageTitleService
 12{
 13    private readonly IJSRuntime _jsRuntime;
 14
 15    public PageTitleService(IJSRuntime jsRuntime)
 16    {
 417        _jsRuntime = jsRuntime;
 418    }
 19
 20    /// <inheritdoc />
 21    public Task SetTitleAsync(string title)
 22    {
 323        var escaped = JsUtilities.EscapeForJs(title);
 324        return _jsRuntime.InvokeVoidAsync(
 325            "eval",
 326            $"document.title = '{escaped} - Chronicis'").AsTask();
 27    }
 28}