|
| 1 | +@testable import SwiftPlantUMLFramework |
| 2 | +import XCTest |
| 3 | + |
| 4 | +final class PageTextsTests: XCTestCase { |
| 5 | + func testNone() throws { |
| 6 | + let texts = PageTexts() |
| 7 | + XCTAssertNil(texts.plantuml()) |
| 8 | + } |
| 9 | + |
| 10 | + func testHeader() throws { |
| 11 | + let headerText = """ |
| 12 | + <u>Simple</u> header example |
| 13 | + on <i>several</i> lines and using <font color=red>html</font> |
| 14 | + """ |
| 15 | + |
| 16 | + let texts = PageTexts(header: headerText) |
| 17 | + let result = texts.plantuml() |
| 18 | + |
| 19 | + let expected = """ |
| 20 | +
|
| 21 | + header |
| 22 | + \(headerText) |
| 23 | + end header |
| 24 | + """ |
| 25 | + XCTAssertEqual(result, expected) |
| 26 | + } |
| 27 | + |
| 28 | + func testTitle() throws { |
| 29 | + let titleText = """ |
| 30 | + <u>Simple</u> title example |
| 31 | + on <i>several</i> lines and using <font color=red>html</font> |
| 32 | + """ |
| 33 | + |
| 34 | + let texts = PageTexts(title: titleText) |
| 35 | + let result = texts.plantuml() |
| 36 | + |
| 37 | + let expected = """ |
| 38 | +
|
| 39 | + title |
| 40 | + \(titleText) |
| 41 | + end title |
| 42 | + """ |
| 43 | + XCTAssertEqual(result, expected) |
| 44 | + } |
| 45 | + |
| 46 | + func testLegend() throws { |
| 47 | + let legendText = """ |
| 48 | + <u>Simple</u> legend example |
| 49 | + on <i>several</i> lines and using <font color=red>html</font> |
| 50 | + """ |
| 51 | + |
| 52 | + let texts = PageTexts(legend: legendText) |
| 53 | + let result = texts.plantuml() |
| 54 | + |
| 55 | + let expected = """ |
| 56 | +
|
| 57 | + legend |
| 58 | + \(legendText) |
| 59 | + end legend |
| 60 | + """ |
| 61 | + XCTAssertEqual(result, expected) |
| 62 | + } |
| 63 | + |
| 64 | + func testCaption() throws { |
| 65 | + let captionText = """ |
| 66 | + <u>Simple</u> caption example |
| 67 | + on <i>several</i> lines and using <font color=red>html</font> |
| 68 | + """ |
| 69 | + |
| 70 | + let texts = PageTexts(caption: captionText) |
| 71 | + let result = texts.plantuml() |
| 72 | + |
| 73 | + let expected = """ |
| 74 | +
|
| 75 | + caption |
| 76 | + \(captionText) |
| 77 | + end caption |
| 78 | + """ |
| 79 | + XCTAssertEqual(result, expected) |
| 80 | + } |
| 81 | + |
| 82 | + func testFooter() throws { |
| 83 | + let footerText = """ |
| 84 | + <u>Simple</u> footer example |
| 85 | + on <i>several</i> lines and using <font color=red>html</font> |
| 86 | + """ |
| 87 | + |
| 88 | + let texts = PageTexts(footer: footerText) |
| 89 | + let result = texts.plantuml() |
| 90 | + |
| 91 | + let expected = """ |
| 92 | +
|
| 93 | + footer |
| 94 | + \(footerText) |
| 95 | + end footer |
| 96 | + """ |
| 97 | + XCTAssertEqual(result, expected) |
| 98 | + } |
| 99 | + |
| 100 | + func testAll() throws { |
| 101 | + let texts = PageTexts(header: "1", title: "2", legend: "3", caption: "4", footer: "5") |
| 102 | + let result = try XCTUnwrap(texts.plantuml()) |
| 103 | + XCTAssertTrue(result.contains("1")) |
| 104 | + XCTAssertTrue(result.contains("2")) |
| 105 | + XCTAssertTrue(result.contains("3")) |
| 106 | + XCTAssertTrue(result.contains("4")) |
| 107 | + XCTAssertTrue(result.contains("5")) |
| 108 | + } |
| 109 | +} |
0 commit comments