Skip to content

Commit

Permalink
added secure field
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazar Otasevic committed Sep 9, 2024
1 parent 08ed7e9 commit 6da8ad8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Sources/ViewInspection/Elements/Extensions/_SecureField.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import SwiftUI

extension InspectableType._SecureField {
var text: Binding<String> {
get throws {
try node.one(.binding).tryCast()
}
}
}
13 changes: 13 additions & 0 deletions Tests/ViewInspectionTests/Elements/_SecureField.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import SwiftUI
import XCTest
@testable import ViewInspection

@MainActor final class Test_SecureField: XCTestCase {
func test_SecureField() throws {
let binding = Binding.variable("")
let secureField = try SecureField("", text: binding).snap.one(.secureField)
XCTAssertEqual(binding.wrappedValue, "")
try secureField.text.wrappedValue = "password123"
XCTAssertEqual(binding.wrappedValue, "password123")
}
}

0 comments on commit 6da8ad8

Please sign in to comment.