Browse Source

Tests for components.

pull/711/head
Sebastian Stehle 5 years ago
parent
commit
e6719a084b
  1. 22
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLTestBase.cs
  2. 59
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/TestContent.cs

22
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLTestBase.cs

@ -79,12 +79,6 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
var schemaDef = var schemaDef =
new Schema(schemaId.Name) new Schema(schemaId.Name)
.Publish() .Publish()
.AddNumber(16, "2_numbers", Partitioning.Invariant,
new NumberFieldProperties())
.AddNumber(17, "2-numbers", Partitioning.Invariant,
new NumberFieldProperties())
.AddNumber(18, "content", Partitioning.Invariant,
new NumberFieldProperties())
.AddJson(1, "my-json", Partitioning.Invariant, .AddJson(1, "my-json", Partitioning.Invariant,
new JsonFieldProperties()) new JsonFieldProperties())
.AddString(2, "my-string", Partitioning.Language, .AddString(2, "my-string", Partitioning.Language,
@ -111,11 +105,21 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
new ReferencesFieldProperties { SchemaId = DomainId.NewGuid() }) new ReferencesFieldProperties { SchemaId = DomainId.NewGuid() })
.AddGeolocation(13, "my-geolocation", Partitioning.Invariant, .AddGeolocation(13, "my-geolocation", Partitioning.Invariant,
new GeolocationFieldProperties()) new GeolocationFieldProperties())
.AddTags(14, "my-tags", Partitioning.Invariant, .AddComponent(14, "my-component", Partitioning.Invariant,
new ComponentFieldProperties())
.AddComponents(15, "my-components", Partitioning.Invariant,
new ComponentsFieldProperties())
.AddTags(16, "my-tags", Partitioning.Invariant,
new TagsFieldProperties()) new TagsFieldProperties())
.AddArray(20, "my-empty-array", Partitioning.Invariant, null, .AddArray(17, "my-empty-array", Partitioning.Invariant, null,
new ArrayFieldProperties()) new ArrayFieldProperties())
.AddArray(15, "my-array", Partitioning.Invariant, f => f .AddNumber(50, "2_numbers", Partitioning.Invariant,
new NumberFieldProperties())
.AddNumber(51, "2-numbers", Partitioning.Invariant,
new NumberFieldProperties())
.AddNumber(52, "content", Partitioning.Invariant,
new NumberFieldProperties())
.AddArray(100, "my-array", Partitioning.Invariant, f => f
.AddBoolean(121, "nested-boolean") .AddBoolean(121, "nested-boolean")
.AddNumber(122, "nested-number") .AddNumber(122, "nested-number")
.AddNumber(123, "nested_number")) .AddNumber(123, "nested_number"))

59
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/TestContent.cs

@ -69,6 +69,12 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
myGeolocation { myGeolocation {
iv iv
} }
myComponent {
iv
}
myComponents {
iv
}
myTags { myTags {
iv iv
} }
@ -131,10 +137,30 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
.AddInvariant(JsonValue.Array(refId.ToString()))) .AddInvariant(JsonValue.Array(refId.ToString())))
.AddField("my-geolocation", .AddField("my-geolocation",
new ContentFieldData() new ContentFieldData()
.AddInvariant(JsonValue.Object().Add("latitude", 10).Add("longitude", 20))) .AddInvariant(
JsonValue.Object()
.Add("latitude", 10)
.Add("longitude", 20)))
.AddField("my-component",
new ContentFieldData()
.AddInvariant(
JsonValue.Object()
.Add(Component.Discriminator, DomainId.Empty)
.Add("value1", 100)
.Add("value2", 200)))
.AddField("my-components",
new ContentFieldData()
.AddInvariant(
JsonValue.Array(
JsonValue.Object()
.Add(Component.Discriminator, DomainId.Empty)
.Add("value1", 100)
.Add("value2", 200))))
.AddField("my-json", .AddField("my-json",
new ContentFieldData() new ContentFieldData()
.AddInvariant(JsonValue.Object().Add("value", 1))) .AddInvariant(
JsonValue.Object()
.Add("value", 1)))
.AddField("my-localized", .AddField("my-localized",
new ContentFieldData() new ContentFieldData()
.AddLocalized("de-DE", "de-DE")) .AddLocalized("de-DE", "de-DE"))
@ -279,6 +305,35 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
longitude = 20 longitude = 20
} }
}, },
["myComponent"] = new
{
iv = new
{
schemaId = DomainId.Empty.ToString(),
value1 = 100,
value2 = 200
}
},
["myComponents"] = new
{
iv = new[]
{
new
{
schemaId = DomainId.Empty.ToString(),
value1 = 100,
value2 = 200
}
}
},
["myGeolocation"] = new
{
iv = new
{
latitude = 10,
longitude = 20
}
},
["myTags"] = new ["myTags"] = new
{ {
iv = new[] iv = new[]

Loading…
Cancel
Save