Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 93 additions & 86 deletions Tests/NodesGeneratorTests/StencilRendererTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ final class StencilRendererTests: XCTestCase, TestFactories {
private let mockCounts: ClosedRange<Int> = 0...2

func testRenderNode() throws {
let expectedTemplates: [String] = [
"Analytics",
"Builder",
"Context",
"Flow",
"Interface",
"State",
"ViewController",
"ViewState"
]
let stencilRenderer: StencilRenderer = .init()
try mockCounts.forEach { count in
try UIFramework.Kind.allCases.forEach { kind in
Expand All @@ -25,16 +35,7 @@ final class StencilRendererTests: XCTestCase, TestFactories {
kind: kind,
includePlugin: false,
includeTests: false)
expect(templates.keys.sorted()) == [
"Analytics",
"Builder",
"Context",
"Flow",
"Interface",
"State",
"ViewController",
"ViewState"
]
expect(templates.keys.sorted()) == expectedTemplates
templates.forEach { name, template in
assertSnapshot(of: template,
as: .lines,
Expand All @@ -45,6 +46,18 @@ final class StencilRendererTests: XCTestCase, TestFactories {
}

func testRenderNode_withPlugin() throws {
let expectedTemplates: [String] = [
"Analytics",
"Builder",
"Context",
"Flow",
"Interface",
"Plugin",
"PluginInterface",
"State",
"ViewController",
"ViewState"
]
let stencilRenderer: StencilRenderer = .init()
try mockCounts.forEach { count in
try UIFramework.Kind.allCases.forEach { kind in
Expand All @@ -53,18 +66,7 @@ final class StencilRendererTests: XCTestCase, TestFactories {
kind: kind,
includePlugin: true,
includeTests: false)
expect(templates.keys.sorted()) == [
"Analytics",
"Builder",
"Context",
"Flow",
"Interface",
"Plugin",
"PluginInterface",
"State",
"ViewController",
"ViewState"
]
expect(templates.keys.sorted()) == expectedTemplates
templates.forEach { name, template in
assertSnapshot(of: template,
as: .lines,
Expand All @@ -75,6 +77,22 @@ final class StencilRendererTests: XCTestCase, TestFactories {
}

func testRenderNode_withTests() throws {
let expectedTemplates: [String] = [
"Analytics",
"AnalyticsTests",
"Builder",
"BuilderTests",
"Context",
"ContextTests",
"Flow",
"FlowTests",
"Interface",
"State",
"ViewController",
"ViewControllerTests",
"ViewState",
"ViewStateFactoryTests"
]
let stencilRenderer: StencilRenderer = .init()
try mockCounts.forEach { count in
try UIFramework.Kind.allCases.forEach { kind in
Expand All @@ -83,22 +101,7 @@ final class StencilRendererTests: XCTestCase, TestFactories {
kind: kind,
includePlugin: false,
includeTests: true)
expect(templates.keys.sorted()) == [
"Analytics",
"AnalyticsTests",
"Builder",
"BuilderTests",
"Context",
"ContextTests",
"Flow",
"FlowTests",
"Interface",
"State",
"ViewController",
"ViewControllerTests",
"ViewState",
"ViewStateFactoryTests"
]
expect(templates.keys.sorted()) == expectedTemplates
templates.forEach { name, template in
assertSnapshot(of: template,
as: .lines,
Expand All @@ -109,7 +112,6 @@ final class StencilRendererTests: XCTestCase, TestFactories {
}

func testRenderNode_withPluginAndTests() throws {
let stencilRenderer: StencilRenderer = .init()
let expectedTemplates: [String] = [
"Analytics",
"AnalyticsTests",
Expand All @@ -129,7 +131,7 @@ final class StencilRendererTests: XCTestCase, TestFactories {
"ViewState",
"ViewStateFactoryTests"
]

let stencilRenderer: StencilRenderer = .init()
try mockCounts.forEach { count in
try UIFramework.Kind.allCases.forEach { kind in
let context: NodeStencilContext = try givenNodeStencilContext(mockCount: count)
Expand All @@ -148,43 +150,45 @@ final class StencilRendererTests: XCTestCase, TestFactories {
}

func testRenderNodeViewInjected() throws {
let expectedTemplates: [String] = [
"Analytics",
"AnalyticsTests",
"Builder",
"BuilderTests",
"Context",
"ContextTests",
"Flow",
"FlowTests",
"Interface",
"State"
]
let stencilRenderer: StencilRenderer = .init()
try mockCounts.forEach { count in
let context: NodeViewInjectedStencilContext = try givenNodeViewInjectedStencilContext(mockCount: count)
let templates: [String: String] = try stencilRenderer.renderNodeViewInjected(context: context,
includeTests: true)
expect(templates.keys.sorted()) == [
"Analytics",
"AnalyticsTests",
"Builder",
"BuilderTests",
"Context",
"ContextTests",
"Flow",
"FlowTests",
"Interface",
"State"
]
expect(templates.keys.sorted()) == expectedTemplates
templates.forEach { name, template in
assertSnapshot(of: template, as: .lines, named: "\(name)-mockCount-\(count)")
}
}
}

func testRenderNodePresetApp() throws {
let expectedTemplates: [String] = [
"Analytics",
"Builder",
"Context",
"Flow",
"Interface",
"State"
]
let stencilRenderer: StencilRenderer = .init()
try mockCounts.forEach { count in
let context: NodeViewInjectedStencilContext = try givenNodeViewInjectedStencilContext(preset: .app,
mockCount: count)
let templates: [String: String] = try stencilRenderer.renderNodeViewInjected(context: context)
expect(templates.keys.sorted()) == [
"Analytics",
"Builder",
"Context",
"Flow",
"Interface",
"State"
]
expect(templates.keys.sorted()) == expectedTemplates
templates.forEach { name, template in
assertSnapshot(of: template,
as: .lines,
Expand All @@ -194,19 +198,20 @@ final class StencilRendererTests: XCTestCase, TestFactories {
}

func testRenderNodePresetScene() throws {
let expectedTemplates: [String] = [
"Analytics",
"Builder",
"Context",
"Flow",
"Interface",
"State"
]
let stencilRenderer: StencilRenderer = .init()
try mockCounts.forEach { count in
let context: NodeViewInjectedStencilContext = try givenNodeViewInjectedStencilContext(preset: .scene,
mockCount: count)
let templates: [String: String] = try stencilRenderer.renderNodeViewInjected(context: context)
expect(templates.keys.sorted()) == [
"Analytics",
"Builder",
"Context",
"Flow",
"Interface",
"State"
]
expect(templates.keys.sorted()) == expectedTemplates
templates.forEach { name, template in
assertSnapshot(of: template,
as: .lines,
Expand All @@ -216,19 +221,20 @@ final class StencilRendererTests: XCTestCase, TestFactories {
}

func testRenderNodePresetWindow() throws {
let expectedTemplates: [String] = [
"Analytics",
"Builder",
"Context",
"Flow",
"Interface",
"State"
]
let stencilRenderer: StencilRenderer = .init()
try mockCounts.forEach { count in
let context: NodeViewInjectedStencilContext = try givenNodeViewInjectedStencilContext(preset: .window,
mockCount: count)
let templates: [String: String] = try stencilRenderer.renderNodeViewInjected(context: context)
expect(templates.keys.sorted()) == [
"Analytics",
"Builder",
"Context",
"Flow",
"Interface",
"State"
]
expect(templates.keys.sorted()) == expectedTemplates
templates.forEach { name, template in
assertSnapshot(of: template,
as: .lines,
Expand All @@ -238,20 +244,21 @@ final class StencilRendererTests: XCTestCase, TestFactories {
}

func testRenderNodePresetRoot() throws {
let expectedTemplates: [String] = [
"Analytics",
"Builder",
"Context",
"Flow",
"Interface",
"State",
"ViewController",
"ViewState"
]
let stencilRenderer: StencilRenderer = .init()
try mockCounts.forEach { count in
let context: NodeStencilContext = try givenNodeStencilContext(preset: .root, mockCount: count)
let templates: [String: String] = try stencilRenderer.renderNode(context: context, kind: .uiKit)
expect(templates.keys.sorted()) == [
"Analytics",
"Builder",
"Context",
"Flow",
"Interface",
"State",
"ViewController",
"ViewState"
]
expect(templates.keys.sorted()) == expectedTemplates
templates.forEach { name, template in
assertSnapshot(of: template,
as: .lines,
Expand Down