|
| 1 | +// |
| 2 | +// ShapeTests.swift |
| 3 | +// |
| 4 | +// |
| 5 | +// Created by Carson Katri on 1/18/23. |
| 6 | +// |
| 7 | + |
| 8 | +import XCTest |
| 9 | +import SwiftUI |
| 10 | +@testable import LiveViewNative |
| 11 | + |
| 12 | +@MainActor |
| 13 | +final class ShapeTests: XCTestCase { |
| 14 | + func testRectangle() throws { |
| 15 | + try assertMatch(#"<rectangle />"#) { |
| 16 | + Rectangle() |
| 17 | + } |
| 18 | + } |
| 19 | + |
| 20 | + func testRoundedRectangle() throws { |
| 21 | + try assertMatch(#"<roundedrectangle corner-radius="5" />"#, size: .init(width: 100, height: 50)) { |
| 22 | + RoundedRectangle(cornerRadius: 5) |
| 23 | + } |
| 24 | + try assertMatch(#"<roundedrectangle corner-width="5" corner-height="10" />"#, size: .init(width: 100, height: 50)) { |
| 25 | + RoundedRectangle(cornerSize: .init(width: 5, height: 10)) |
| 26 | + } |
| 27 | + try assertMatch(#"<roundedrectangle corner-width="5" corner-radius="15" />"#, size: .init(width: 100, height: 50)) { |
| 28 | + RoundedRectangle(cornerSize: .init(width: 5, height: 15)) |
| 29 | + } |
| 30 | + try assertMatch(#"<roundedrectangle corner-height="5" corner-radius="15" />"#, size: .init(width: 100, height: 50)) { |
| 31 | + RoundedRectangle(cornerSize: .init(width: 15, height: 5)) |
| 32 | + } |
| 33 | + try assertMatch(#"<roundedrectangle corner-radius="10" style="continuous" />"#, size: .init(width: 100, height: 50)) { |
| 34 | + RoundedRectangle(cornerRadius: 10, style: .continuous) |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | + func testCircle() throws { |
| 39 | + try assertMatch(#"<circle />"#) { |
| 40 | + Circle() |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + func testEllipse() throws { |
| 45 | + try assertMatch(#"<ellipse />"#, size: .init(width: 100, height: 50)) { |
| 46 | + Ellipse() |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + func testCapsule() throws { |
| 51 | + try assertMatch(#"<capsule />"#, size: .init(width: 100, height: 50)) { |
| 52 | + Capsule() |
| 53 | + } |
| 54 | + try assertMatch(#"<capsule />"#, size: .init(width: 50, height: 100)) { |
| 55 | + Capsule() |
| 56 | + } |
| 57 | + try assertMatch(#"<capsule style="continuous" />"#, size: .init(width: 100, height: 50)) { |
| 58 | + Capsule(style: .continuous) |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | + func testContainerRelativeShape() throws { |
| 63 | + try assertMatch(#"<containerrelativeshape />"#) { |
| 64 | + ContainerRelativeShape() |
| 65 | + } |
| 66 | + } |
| 67 | +} |
0 commit comments