import SwiftLintCore
import TestHelpers
import Testing

@testable import SwiftLintBuiltInRules

@Suite(.rulesRegistered)
struct UnusedOptionalBindingRuleTests {
    @Test
    func defaultConfiguration() {
        let baseDescription = UnusedOptionalBindingRule.description
        let triggeringExamples = baseDescription.triggeringExamples + #examples([
            "guard let _ = try? alwaysThrows() else { return }"
        ])

        let description = baseDescription.with(triggeringExamples: triggeringExamples)
        verifyRule(description)
    }

    @Test
    func ignoreOptionalTryEnabled() {
        // Perform additional tests with the ignore_optional_try settings enabled.
        let baseDescription = UnusedOptionalBindingRule.description
        let nonTriggeringExamples = baseDescription.nonTriggeringExamples + #examples([
            "guard let _ = try? alwaysThrows() else { return }"
        ])

        let description = baseDescription.with(nonTriggeringExamples: nonTriggeringExamples)
        verifyRule(description, ruleConfiguration: ["ignore_optional_try": true])
    }
}
