mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.8 KiB
57 lines
1.8 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using Squidex.Domain.Apps.Core;
|
|
using Squidex.Domain.Apps.Core.Schemas;
|
|
using Squidex.Domain.Apps.Entities.Contents.Queries.Steps;
|
|
using Squidex.Domain.Apps.Entities.TestHelpers;
|
|
using Squidex.Infrastructure.Json;
|
|
|
|
namespace Squidex.Domain.Apps.Entities.Contents.Queries;
|
|
|
|
public class CalculateTokensTests : GivenContext
|
|
{
|
|
private readonly IJsonSerializer serializer = A.Fake<IJsonSerializer>();
|
|
private readonly IUrlGenerator urlGenerator = A.Fake<IUrlGenerator>();
|
|
private readonly CalculateTokens sut;
|
|
|
|
public CalculateTokensTests()
|
|
{
|
|
sut = new CalculateTokens(urlGenerator, serializer);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Should_compute_ui_tokens()
|
|
{
|
|
var content = CreateContent();
|
|
|
|
await sut.EnrichAsync(ApiContext, [content], SchemaProvider(), CancellationToken);
|
|
|
|
Assert.NotNull(content.EditToken);
|
|
|
|
A.CallTo(() => urlGenerator.Root())
|
|
.MustHaveHappened();
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Should_also_compute_ui_tokens_for_frontend()
|
|
{
|
|
var content = CreateContent();
|
|
|
|
await sut.EnrichAsync(FrontendContext, [content], SchemaProvider(), CancellationToken);
|
|
|
|
Assert.NotNull(content.EditToken);
|
|
|
|
A.CallTo(() => urlGenerator.Root())
|
|
.MustHaveHappened();
|
|
}
|
|
|
|
private ProvideSchema SchemaProvider()
|
|
{
|
|
return x => Task.FromResult((Schema, ResolvedComponents.Empty));
|
|
}
|
|
}
|
|
|