Skip to content

Commit

Permalink
Additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondjavaxx committed Aug 4, 2023
1 parent da7a0d9 commit e0f1290
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Tests/SmoothGradientTests/GradientSmoothTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import SwiftUI
import SnapshotTesting
import SmoothGradient

#if os(iOS) || os(tvOS)
final class GradientSmoothTests: XCTestCase {
func test_easing_easeInOut() throws {
verify(
Expand Down Expand Up @@ -100,3 +101,4 @@ extension GradientSmoothTests {
)
}
}
#endif
66 changes: 66 additions & 0 deletions Tests/SmoothGradientTests/SmoothLinearGradientTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// SmoothLinearGradientTests.swift
// SmoothGradientTests
//
// Copyright (c) 2023 Ramon Torres
//
// This file is part of SmoothGradient which is released under the MIT license.
// See the LICENSE file in the root directory of this source tree for full details.
//

import XCTest
import SwiftUI
import SnapshotTesting
import SmoothGradient

#if os(iOS) || os(tvOS)
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
final class SmoothLinearGradientTests: XCTestCase {
func test_horizontal() {
verify(
SmoothLinearGradient(from: .green, to: .blue, startPoint: .leading, endPoint: .trailing)
)
}

func test_vertical() {
verify(
SmoothLinearGradient(from: .green, to: .blue, startPoint: .top, endPoint: .bottom)
)
}

func test_diagonal() {
verify(
SmoothLinearGradient(from: .green, to: .blue, startPoint: .topLeading, endPoint: .bottomTrailing)
)
}

func test_stops() {
verify(
SmoothLinearGradient(
from: .init(color: .green, location: 0.2),
to: .init(color: .red, location: 0.4),
startPoint: .top,
endPoint: .bottom
)
)
}
}

@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension SmoothLinearGradientTests {
func verify(
_ gradient: SmoothLinearGradient,
file: StaticString = #file,
testName: String = #function,
line: UInt = #line
) {
assertSnapshot(
matching: gradient.frame(width: 256, height: 256),
as: .image,
file: file,
testName: testName,
line: line
)
}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e0f1290

Please sign in to comment.