Skip to content

Commit

Permalink
Minor documentation fixes + restore 100% test coverage (#13)
Browse files Browse the repository at this point in the history
This change contains minor fixes to documentation wording, removal of
unnecessary whitespace, and restore’s Plot’s 100% unit test coverage.
  • Loading branch information
JohnSundell authored Dec 27, 2019
1 parent 26da0e3 commit 2e55749
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
28 changes: 14 additions & 14 deletions Sources/Plot/API/HTMLAttributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,39 +217,39 @@ public extension Attribute where Context == HTML.InputContext {
}

/// Assign whether the element is required before submitting the form.
/// - parameter isOn: Whether required should set to true.
static func required(_ isOn: Bool) -> Attribute {
isOn ? Attribute(name: "required", value: "true") : .empty
/// - parameter isRequired: Whether the element is required.
static func required(_ isRequired: Bool) -> Attribute {
isRequired ? Attribute(name: "required", value: "true") : .empty
}

/// Assign whether the element should be autofocused when the page loads.
/// - parameter isOn: Whether autofocus should turned on.
/// - parameter isOn: Whether autofocus should be turned on.
static func autofocus(_ isOn: Bool) -> Attribute {
isOn ? Attribute(name: "autofocus", value: "true") : .empty
}
}

public extension Node where Context == HTML.TextAreaContext {
/// Assign the number of text columns to text area.
/// - parameter cols: The number of columns.
static func cols(_ cols: Int) -> Node {
.attribute(named: "cols", value: String(cols))
/// Specify the number of columns that the text area should contain.
/// - parameter columns: The number of columns to specify.
static func cols(_ columns: Int) -> Node {
.attribute(named: "cols", value: String(columns))
}

/// Assign the number of text rows visible to text area.
/// - parameter rows: The number of rows..
/// Specify the number of text rows that should be visible within the text area.
/// - parameter rows: The number of rows to specify.
static func rows(_ rows: Int) -> Node {
.attribute(named: "rows", value: String(rows))
}

/// Assign whether the element is required before submitting the form.
/// - parameter isOn: Whether required should set to true.
static func required(_ isOn: Bool) -> Node {
isOn ? .attribute(named: "required", value: "true") : .empty
/// - parameter isRequired: Whether the element is required.
static func required(_ isRequired: Bool) -> Node {
isRequired ? .attribute(named: "required", value: "true") : .empty
}

/// Assign whether the element should be autofocused when the page loads.
/// - parameter isOn: Whether autofocus should turned on.
/// - parameter isOn: Whether autofocus should be turned on.
static func autofocus(_ isOn: Bool) -> Node {
isOn ? .attribute(named: "autofocus", value: "true") : .empty
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Plot/API/HTMLElements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public extension Node where Context == HTML.FormContext {
static func fieldset(_ nodes: Node<HTML.FormContext>...) -> Node {
.element(named: "fieldset", nodes: nodes)
}

/// Add an `<input/>` HTML element within the current context.
/// - parameter nodes: The element's attributes.
static func input(_ attributes: Attribute<HTML.InputContext>...) -> Node {
Expand Down
2 changes: 2 additions & 0 deletions Tests/PlotTests/HTMLTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ final class HTMLTests: XCTestCase {
.input(.name("c"), .type(.text), .autofocus(false)),
.input(.name("d"), .type(.email), .autocomplete(true), .required(true)),
.textarea(.name("e"), .cols(50), .rows(10), .required(true), .text("Test")),
.textarea(.name("f"), .autofocus(true)),
.input(.type(.submit), .value("Send"))
)
))
Expand All @@ -247,6 +248,7 @@ final class HTMLTests: XCTestCase {
<input name="c" type="text"/>\
<input name="d" type="email" autocomplete="on" required="true"/>\
<textarea name="e" cols="50" rows="10" required="true">Test</textarea>\
<textarea name="f" autofocus="true"></textarea>\
<input type="submit" value="Send"/>\
</form></body>
""")
Expand Down
4 changes: 2 additions & 2 deletions Tests/PlotTests/NodeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import Plot

final class NodeTests: XCTestCase {
func testEscapingText() {
let node = Node<Any>.text("Hello & welcome to <Plot>!")
XCTAssertEqual(node.render(), "Hello &amp; welcome to &lt;Plot&gt;!")
let node = Node<Any>.text("Hello & welcome to <Plot>!;")
XCTAssertEqual(node.render(), "Hello &amp; welcome to &lt;Plot&gt;!;")
}

func testEscapingDoubleAmpersands() {
Expand Down

0 comments on commit 2e55749

Please sign in to comment.