-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added additional tests for the Dynamic PageView Model
- Loading branch information
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
...n/nl/avisi/structurizr/site/generatr/site/model/SoftwareSystemDynamicPageViewModelTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
import assertk.assertThat | ||
import assertk.assertions.containsExactly | ||
import assertk.assertions.isEqualTo | ||
import assertk.assertions.isFalse | ||
import com.structurizr.model.SoftwareSystem | ||
import kotlin.test.Test | ||
|
||
class SoftwareSystemDynamicPageViewModelTest : ViewModelTest() { | ||
private val generatorContext = generatorContext() | ||
private val softwareSystem: SoftwareSystem = generatorContext.workspace.model | ||
.addSoftwareSystem("Software system").also { | ||
val backend = it.addContainer("Backend") | ||
val frontend = it.addContainer("Frontend") | ||
generatorContext.workspace.views.createDynamicView(backend, "backend-dynamic", "Dynamic view 1") | ||
generatorContext.workspace.views.createDynamicView(frontend, "frontend-dynamic", "Dynamic view 2") | ||
} | ||
|
||
@Test | ||
fun `active tab`() { | ||
val viewModel = SoftwareSystemDynamicPageViewModel(generatorContext, softwareSystem) | ||
|
||
assertThat(viewModel.tabs.single { it.link.active }.tab) | ||
.isEqualTo(SoftwareSystemPageViewModel.Tab.DYNAMIC) | ||
} | ||
|
||
@Test | ||
fun `diagrams sorted by key`() { | ||
val viewModel = SoftwareSystemDynamicPageViewModel(generatorContext, softwareSystem) | ||
|
||
assertThat(viewModel.diagrams).containsExactly( | ||
DiagramViewModel( | ||
"backend-dynamic", | ||
"Backend - Dynamic", | ||
"""<svg viewBox="0 0 800 900"></svg>""", | ||
800, | ||
ImageViewModel(viewModel, "/svg/backend-dynamic.svg"), | ||
ImageViewModel(viewModel, "/png/backend-dynamic.png"), | ||
ImageViewModel(viewModel, "/puml/backend-dynamic.puml") | ||
), | ||
DiagramViewModel( | ||
"frontend-dynamic", | ||
"Frontend - Dynamic", | ||
"""<svg viewBox="0 0 800 900"></svg>""", | ||
800, | ||
ImageViewModel(viewModel, "/svg/frontend-dynamic.svg"), | ||
ImageViewModel(viewModel, "/png/frontend-dynamic.png"), | ||
ImageViewModel(viewModel, "/puml/frontend-dynamic.puml") | ||
) | ||
) | ||
} | ||
|
||
@Test | ||
fun `hidden view`() { | ||
val viewModel = SoftwareSystemDynamicPageViewModel( | ||
generatorContext, | ||
generatorContext.workspace.model.addSoftwareSystem("Software system 2") | ||
) | ||
|
||
assertThat(viewModel.visible).isFalse() | ||
} | ||
} |