diff --git a/Tests/Expected/Colors/literals-swift3-context-defaults-customname.swift b/Tests/Expected/Colors/literals-swift3-context-defaults-customname.swift index 2608dbe..ef2f48b 100644 --- a/Tests/Expected/Colors/literals-swift3-context-defaults-customname.swift +++ b/Tests/Expected/Colors/literals-swift3-context-defaults-customname.swift @@ -3,17 +3,16 @@ #if os(OSX) import AppKit.NSColor typealias Color = NSColor - enum XCTColors { } + enum UIColor { } #elseif os(iOS) || os(tvOS) || os(watchOS) import UIKit.UIColor typealias Color = UIColor - enum XCTColors { } #endif // swiftlint:disable file_length // swiftlint:disable identifier_name line_length type_body_length -extension XCTColors { +extension UIColor { /// 0x339666ff (r: 51, g: 150, b: 102, a: 255) static let articleBody = #colorLiteral(red: 0.2, green: 0.588235, blue: 0.4, alpha: 1.0) /// 0xff66ccff (r: 255, g: 102, b: 204, a: 255) diff --git a/Tests/Expected/Colors/literals-swift4-context-defaults-customname.swift b/Tests/Expected/Colors/literals-swift4-context-defaults-customname.swift index 2608dbe..ef2f48b 100644 --- a/Tests/Expected/Colors/literals-swift4-context-defaults-customname.swift +++ b/Tests/Expected/Colors/literals-swift4-context-defaults-customname.swift @@ -3,17 +3,16 @@ #if os(OSX) import AppKit.NSColor typealias Color = NSColor - enum XCTColors { } + enum UIColor { } #elseif os(iOS) || os(tvOS) || os(watchOS) import UIKit.UIColor typealias Color = UIColor - enum XCTColors { } #endif // swiftlint:disable file_length // swiftlint:disable identifier_name line_length type_body_length -extension XCTColors { +extension UIColor { /// 0x339666ff (r: 51, g: 150, b: 102, a: 255) static let articleBody = #colorLiteral(red: 0.2, green: 0.588235, blue: 0.4, alpha: 1.0) /// 0xff66ccff (r: 255, g: 102, b: 204, a: 255) diff --git a/Tests/TemplatesTests/ColorsTests.swift b/Tests/TemplatesTests/ColorsTests.swift index f775d83..2daebd5 100644 --- a/Tests/TemplatesTests/ColorsTests.swift +++ b/Tests/TemplatesTests/ColorsTests.swift @@ -13,50 +13,52 @@ class ColorsTests: XCTestCase { } // generate variations to test customname generation - let variations: VariationGenerator = { name, context in - guard name == "defaults" else { return [(context: context, suffix: "")] } - - return [ - (context: context, - suffix: ""), - (context: try StencilContext.enrich(context: context, - parameters: ["enumName=XCTColors"]), - suffix: "-customname") - ] + func variations(customName: String) -> VariationGenerator { + return { name, context in + guard name == "defaults" else { return [(context: context, suffix: "")] } + + return [ + (context: context, + suffix: ""), + (context: try StencilContext.enrich(context: context, + parameters: ["enumName=\(customName)"]), + suffix: "-customname") + ] + } } func testSwift2() { test(template: "swift2", contextNames: Contexts.all, directory: .colors, - contextVariations: variations) + contextVariations: variations(customName: "XCTColors")) } func testSwift3() { test(template: "swift3", contextNames: Contexts.all, directory: .colors, - contextVariations: variations) + contextVariations: variations(customName: "XCTColors")) } func testSwift4() { test(template: "swift4", contextNames: Contexts.all, directory: .colors, - contextVariations: variations) + contextVariations: variations(customName: "XCTColors")) } func testLiteralsSwift3() { test(template: "literals-swift3", contextNames: Contexts.all, directory: .colors, - contextVariations: variations) + contextVariations: variations(customName: "UIColor")) } func testLiteralsSwift4() { test(template: "literals-swift4", contextNames: Contexts.all, directory: .colors, - contextVariations: variations) + contextVariations: variations(customName: "UIColor")) } }