Skip to content

Commit 40df4d1

Browse files
Add pluginTests to view injected stencils (#792)
1 parent 95e57a1 commit 40df4d1

8 files changed

+95
-6
lines changed

Sources/NodesGenerator/StencilTemplate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public enum StencilTemplate: Sendable, Equatable, CustomStringConvertible {
138138
builderTests,
139139
contextTests,
140140
flowTests
141-
]
141+
] + (includePlugin ? [.pluginTests] : [])
142142
return stencils + testsStencils
143143
}
144144
}

Tests/NodesGeneratorTests/StencilTemplateTests.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ final class StencilTemplateTests: XCTestCase, TestFactories {
214214
.analyticsTests,
215215
.builderTests,
216216
.contextTests,
217-
.flowTests
217+
.flowTests,
218+
.pluginTests
218219
]
219220
expect(node.stencils(includePlugin: false, includeTests: true)) == [
220221
.analytics,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//___FILEHEADER___
2+
3+
#warning("Manually move this test file to the corresponding test target then delete this warning.")
4+
5+
import Nimble
6+
import NodesTesting
7+
import XCTest
8+
9+
final class PluginTests: XCTestCase {
10+
11+
private var plugin: PluginImp!
12+
13+
@MainActor
14+
override func setUp() {
15+
super.setUp()
16+
plugin = PluginImp(componentFactory: injectComponent { parent in
17+
PluginComponent(parent: parent)
18+
} with: {
19+
// swiftlint:disable:next direct_return
20+
let dependency: PluginDependencyMock = .init()
21+
// dependency.<dependencyName> = <dependencyName>Mock
22+
return dependency
23+
})
24+
}
25+
26+
override func tearDown() {
27+
plugin = nil
28+
super.tearDown()
29+
}
30+
31+
@MainActor
32+
func testCreate() {
33+
expect { self.plugin.create() } != nil
34+
}
35+
36+
@MainActor
37+
func testOverride() {
38+
expect { self.plugin.override() } != nil
39+
}
40+
}

Tests/NodesGeneratorTests/__Snapshots__/XcodeTemplateGeneratorTests/testGenerateWithIdentifier.Writes.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
141 elements
1+
142 elements
22
▿ (2 elements)
33
- path: "/Developer/Xcode/Templates/File Templates/Nodes Architecture Framework (identifier)/Node.xctemplate/AppKitCreatedForPluginList/___FILEBASENAME___Analytics.swift"
44
- atomically: true
@@ -392,6 +392,9 @@
392392
▿ (2 elements)
393393
- path: "/Developer/Xcode/Templates/File Templates/Nodes Architecture Framework (identifier)/View Injected.xctemplate/___FILEBASENAME___FlowTests.swift"
394394
- atomically: true
395+
▿ (2 elements)
396+
- path: "/Developer/Xcode/Templates/File Templates/Nodes Architecture Framework (identifier)/View Injected.xctemplate/___FILEBASENAME___PluginTests.swift"
397+
- atomically: true
395398
▿ (2 elements)
396399
- path: "/Developer/Xcode/Templates/File Templates/Nodes Architecture Framework (identifier)/View Injected.xctemplate/TemplateInfo.plist"
397400
- atomically: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//___FILEHEADER___
2+
3+
#warning("Manually move this test file to the corresponding test target then delete this warning.")
4+
5+
import Nimble
6+
import NodesTesting
7+
import XCTest
8+
9+
final class PluginTests: XCTestCase {
10+
11+
private var plugin: PluginImp!
12+
13+
@MainActor
14+
override func setUp() {
15+
super.setUp()
16+
plugin = PluginImp(componentFactory: injectComponent { parent in
17+
PluginComponent(parent: parent)
18+
} with: {
19+
// swiftlint:disable:next direct_return
20+
let dependency: PluginDependencyMock = .init()
21+
// dependency.<dependencyName> = <dependencyName>Mock
22+
return dependency
23+
})
24+
}
25+
26+
override func tearDown() {
27+
plugin = nil
28+
super.tearDown()
29+
}
30+
31+
@MainActor
32+
func testCreate() {
33+
expect { self.plugin.create() } != nil
34+
}
35+
36+
@MainActor
37+
func testOverride() {
38+
expect { self.plugin.override() } != nil
39+
}
40+
}

Tests/NodesGeneratorTests/__Snapshots__/XcodeTemplateGeneratorTests/testGenerateWithURL.Writes.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
141 elements
1+
142 elements
22
▿ (2 elements)
33
- path: "/Node.xctemplate/AppKitCreatedForPluginList/___FILEBASENAME___Analytics.swift"
44
- atomically: true
@@ -392,6 +392,9 @@
392392
▿ (2 elements)
393393
- path: "/View Injected.xctemplate/___FILEBASENAME___FlowTests.swift"
394394
- atomically: true
395+
▿ (2 elements)
396+
- path: "/View Injected.xctemplate/___FILEBASENAME___PluginTests.swift"
397+
- atomically: true
395398
▿ (2 elements)
396399
- path: "/View Injected.xctemplate/TemplateInfo.plist"
397400
- atomically: true

Tests/NodesGeneratorTests/__Snapshots__/XcodeTemplatePermutationTests/testNodeViewInjectedXcodeTemplatePermutation.1.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
- viewControllableType: "<viewControllableType>"
7272
▿ workerGenericTypes: 1 element
7373
- "<workerGenericType>"
74-
▿ stencils: 10 elements
74+
▿ stencils: 11 elements
7575
- Analytics
7676
▿ Builder
7777
- builder: Variation.default
@@ -83,3 +83,4 @@
8383
- BuilderTests
8484
- ContextTests
8585
- FlowTests
86+
- PluginTests

Tests/NodesGeneratorTests/__Snapshots__/XcodeTemplateTests/testNodeViewInjectedXcodeTemplate.1.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
- viewControllableType: "<viewControllableType>"
7575
▿ workerGenericTypes: 1 element
7676
- "<workerGenericType>"
77-
▿ stencils: 10 elements
77+
▿ stencils: 11 elements
7878
- Analytics
7979
▿ Builder
8080
- builder: Variation.default
@@ -86,6 +86,7 @@
8686
- BuilderTests
8787
- ContextTests
8888
- FlowTests
89+
- PluginTests
8990
▿ propertyList: XcodeTemplatePropertyList
9091
▿ allowedTypes: 1 element
9192
- "public.swift-source"

0 commit comments

Comments
 (0)