Fix tests

This commit is contained in:
Simon 2018-12-26 16:56:51 +08:00
parent 47baa6b418
commit 5a4625ee66
2 changed files with 6 additions and 14 deletions

View File

@ -27,11 +27,11 @@ public struct Placeholder {
}
public struct PlaceholderBuilder {
public func coloredBackground(color: UIColor, size: CGSize) -> Image? {
public func coloredBackground(color: Color, size: CGSize) -> Image? {
return Image.image(withColor: color, size: size)
}
public func imageBackground(image: UIImage, size: CGSize, tiled: Bool = false) -> Image? {
public func imageBackground(image: Image, size: CGSize, tiled: Bool = false) -> Image? {
return nil
}

View File

@ -9,24 +9,16 @@
import XCTest
@testable import PlaceholderKit
class PlaceholderFactoryTests: XCTestCase {
var factory: PlaceholderFactory?
class PlaceholderTests: XCTestCase {
func testSolidColor() {
// Given a valid setting
let outputSize = CGSize(width: 1600, height: 900)
let settings = PlaceholderSettings(size: outputSize,
background: .solidColor(Color(red: 1.0, green: 0.0, blue: 0.0, alpha: 1.0)),
showDimensionAsText: true,
convertDimensionToAspectRatio: true)
factory = PlaceholderFactory(settings: settings)
let placeholder = factory?.createPlaceholder()
let image = PlaceholderBuilder().coloredBackground(color: .red, size: outputSize)
// output should not be nil
XCTAssertNotNil(placeholder)
XCTAssertNotNil(image)
// output should have the correct size
XCTAssert(placeholder!.size == outputSize, "Expected output to have size: \(outputSize), got \(placeholder!.size)")
XCTAssert(image!.size == outputSize, "Expected output to have size: \(outputSize), got \(image!.size)")
}
}