Headless CMS and Content Managment Hub
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.
 
 
 
 
 

62 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.Schemas;
using Squidex.Domain.Apps.Entities.Contents.Queries.Steps;
using Squidex.Domain.Apps.Entities.TestHelpers;
namespace Squidex.Domain.Apps.Entities.Contents.Queries;
public class EnrichWithSchemaTests : GivenContext
{
private readonly EnrichWithSchema sut;
public EnrichWithSchemaTests()
{
sut = new EnrichWithSchema();
}
[Fact]
public async Task Should_enrich_with_reference_fields()
{
var content = CreateContent();
await sut.EnrichAsync(FrontendContext, new[] { content }, SchemaProvider(), CancellationToken);
Assert.NotNull(content.ReferenceFields);
}
[Fact]
public async Task Should_not_enrich_with_reference_fields_if_not_frontend()
{
var content = CreateContent();
await sut.EnrichAsync(ApiContext, new[] { content }, SchemaProvider(), CancellationToken);
Assert.Null(content.ReferenceFields);
}
[Fact]
public async Task Should_enrich_with_schema_names()
{
var content = CreateContent();
await sut.EnrichAsync(ApiContext, new[] { content }, SchemaProvider(), CancellationToken);
Assert.Equal("my-schema", content.SchemaDisplayName);
}
private ContentEntity CreateContent()
{
return new ContentEntity { SchemaId = SchemaId };
}
private ProvideSchema SchemaProvider()
{
return x => Task.FromResult((Schema, ResolvedComponents.Empty));
}
}