|
| 1 | +// |
| 2 | +// ShareLinkButtonTests.swift |
| 3 | +// |
| 4 | +// |
| 5 | +// Created by Igor on 03.07.24. |
| 6 | +// |
| 7 | + |
| 8 | +import XCTest |
| 9 | +import SwiftUI |
| 10 | +@testable import sharelink_for_swiftui |
| 11 | + |
| 12 | +final class ShareLinkButtonTests: XCTestCase { |
| 13 | + |
| 14 | + func testShareText() { |
| 15 | + let shareLinkButton = ShareLinkButton(item: "Hello, world!") { |
| 16 | + Text("Share Text") |
| 17 | + } |
| 18 | + XCTAssertNotNil(shareLinkButton) |
| 19 | + } |
| 20 | + |
| 21 | + func testShareURL() { |
| 22 | + let url = URL(string: "https://example.com")! |
| 23 | + let shareLinkButton = ShareLinkButton(item: url) { |
| 24 | + Text("Share URL") |
| 25 | + } |
| 26 | + XCTAssertNotNil(shareLinkButton) |
| 27 | + } |
| 28 | + |
| 29 | + func testShareImage() { |
| 30 | + let image = UIImage(systemName: "photo")! |
| 31 | + let shareLinkButton = ShareLinkButton(item: image) { |
| 32 | + Image(systemName: "photo") |
| 33 | + } |
| 34 | + XCTAssertNotNil(shareLinkButton) |
| 35 | + } |
| 36 | + |
| 37 | + func testCustomActivity() { |
| 38 | + let customActivity = UIActivity() |
| 39 | + let shareLinkButton = ShareLinkButton(item: "Custom Activity", applicationActivities: [customActivity]) { |
| 40 | + Text("Share Custom Activity") |
| 41 | + } |
| 42 | + XCTAssertNotNil(shareLinkButton) |
| 43 | + } |
| 44 | + |
| 45 | + static var allTests = [ |
| 46 | + ("testShareText", testShareText), |
| 47 | + ("testShareURL", testShareURL), |
| 48 | + ("testShareImage", testShareImage), |
| 49 | + ("testCustomActivity", testCustomActivity), |
| 50 | + ] |
| 51 | +} |
0 commit comments