1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-1593 App | Fix | Create object, template internal flag (#297)

This commit is contained in:
Konstantin Ivanov 2023-08-17 16:19:37 +02:00 committed by GitHub
parent 3ae86e0c65
commit 705367d56f
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 19 deletions

View file

@ -25,19 +25,9 @@ class CreateObject(
val type = params.type ?: getDefaultPageType.run(Unit).type
val objectTemplates = if (type != null) {
getTemplates.run(GetTemplates.Params(type = type))
} else {
null
}
val internalFlags = buildList {
if (!objectTemplates.isNullOrEmpty()) {
add(InternalFlags.ShouldSelectType)
add(InternalFlags.ShouldSelectTemplate)
} else {
add(InternalFlags.ShouldSelectType)
}
add(InternalFlags.ShouldSelectType)
add(InternalFlags.ShouldSelectTemplate)
add(InternalFlags.ShouldEmptyDelete)
}

View file

@ -68,13 +68,17 @@ class CreateObjectTest {
val commands = Command.CreateObject(
prefilled = emptyMap(),
template = null,
internalFlags = listOf(InternalFlags.ShouldSelectType, InternalFlags.ShouldEmptyDelete)
internalFlags = listOf(
InternalFlags.ShouldSelectType,
InternalFlags.ShouldSelectTemplate,
InternalFlags.ShouldEmptyDelete
)
)
verifyBlocking(repo, times(1)) { createObject(commands) }
}
@Test
fun `when type is null and default type is note without template - should send proper params`() =
fun `when type is null and default type is note - should send proper params`() =
runBlocking {
//SETUP
@ -90,12 +94,12 @@ class CreateObjectTest {
createObject.run(params)
//ASSERT
verifyBlocking(getTemplates, times(1)) { run(GetTemplates.Params(defaultType)) }
val commands = Command.CreateObject(
prefilled = buildMap { put(Relations.TYPE, defaultType) },
template = null,
internalFlags = listOf(
InternalFlags.ShouldSelectType,
InternalFlags.ShouldSelectTemplate,
InternalFlags.ShouldEmptyDelete
)
)
@ -122,7 +126,6 @@ class CreateObjectTest {
createObject.run(params)
//ASSERT
verifyBlocking(getTemplates, times(1)) { run(GetTemplates.Params(defaultType)) }
val commands = Command.CreateObject(
prefilled = buildMap { put(Relations.TYPE, defaultType) },
template = null,
@ -150,12 +153,12 @@ class CreateObjectTest {
//ASSERT
verifyNoInteractions(getDefaultPageType)
verifyBlocking(getTemplates, times(1)) { run(GetTemplates.Params(type)) }
val commands = Command.CreateObject(
prefilled = buildMap { put(Relations.TYPE, type) },
template = null,
internalFlags = listOf(
InternalFlags.ShouldSelectType,
InternalFlags.ShouldSelectTemplate,
InternalFlags.ShouldEmptyDelete
)
)
@ -180,7 +183,6 @@ class CreateObjectTest {
//ASSERT
verifyNoInteractions(getDefaultPageType)
verifyBlocking(getTemplates, times(1)) { run(GetTemplates.Params(type)) }
val commands = Command.CreateObject(
prefilled = buildMap { put(Relations.TYPE, type) },
template = null,
@ -219,7 +221,6 @@ class CreateObjectTest {
//ASSERT
verifyNoInteractions(getDefaultPageType)
verifyBlocking(getTemplates, times(1)) { run(GetTemplates.Params(type)) }
val commands = Command.CreateObject(
prefilled = buildMap { put(Relations.TYPE, type) },
template = null,