|
| 1 | +// |
| 2 | +// StepperUITests.swift |
| 3 | +// OpenSwiftUIUITests |
| 4 | + |
| 5 | +import SnapshotTesting |
| 6 | +import Testing |
| 7 | +@testable import TestingHost |
| 8 | + |
| 9 | +@MainActor |
| 10 | +@Suite(.snapshots(record: .never, diffTool: diffTool)) |
| 11 | +struct StepperUITests { |
| 12 | + @Test(arguments: [0, 4, 10]) |
| 13 | + func boundedValues(value: Int) { |
| 14 | + openSwiftUIAssertSnapshot( |
| 15 | + of: StepperExample(value: value), |
| 16 | + size: .init(width: 320, height: 120), |
| 17 | + named: "\(value)" |
| 18 | + ) |
| 19 | + } |
| 20 | + |
| 21 | + @Test(arguments: [ |
| 22 | + (true, true), |
| 23 | + (true, false), |
| 24 | + (false, true), |
| 25 | + (false, false), |
| 26 | + ] as [(Bool, Bool)]) |
| 27 | + func optionalActions(canIncrement: Bool, canDecrement: Bool) { |
| 28 | + openSwiftUIAssertSnapshot( |
| 29 | + of: ActionStepperExample( |
| 30 | + canIncrement: canIncrement, |
| 31 | + canDecrement: canDecrement |
| 32 | + ), |
| 33 | + size: .init(width: 320, height: 100), |
| 34 | + named: "increment-\(canIncrement)-decrement-\(canDecrement)" |
| 35 | + ) |
| 36 | + } |
| 37 | + |
| 38 | + @Test |
| 39 | + func fractionalSteps() { |
| 40 | + openSwiftUIAssertSnapshot( |
| 41 | + of: FractionalStepperExample(), |
| 42 | + size: .init(width: 320, height: 100) |
| 43 | + ) |
| 44 | + } |
| 45 | + |
| 46 | + @Test |
| 47 | + func labelsHidden() { |
| 48 | + openSwiftUIAssertSnapshot( |
| 49 | + of: StepperExample().labelsHidden(), |
| 50 | + size: .init(width: 320, height: 120) |
| 51 | + ) |
| 52 | + } |
| 53 | + |
| 54 | + @Test |
| 55 | + func disabled() { |
| 56 | + openSwiftUIAssertSnapshot( |
| 57 | + of: StepperExample().disabled(true), |
| 58 | + size: .init(width: 320, height: 120) |
| 59 | + ) |
| 60 | + } |
| 61 | + |
| 62 | + @Test(arguments: [.mini, .small, .regular, .large, .extraLarge] as [ControlSize]) |
| 63 | + func controlSizes(size: ControlSize) { |
| 64 | + openSwiftUIAssertSnapshot( |
| 65 | + of: StepperExample().controlSize(size), |
| 66 | + size: .init(width: 320, height: 120), |
| 67 | + named: "\(size)" |
| 68 | + ) |
| 69 | + } |
| 70 | +} |
0 commit comments