-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test URLComponentsParser with convenience parsers
- Loading branch information
1 parent
4e430d7
commit 7379b32
Showing
6 changed files
with
48 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import URLSchemer | ||
|
||
struct Passthrough<Input: Action>: ActionParser { | ||
func parse(_ input: Input) throws -> Input { | ||
input | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import URLSchemer | ||
import XCTest | ||
|
||
final class URLComponentsParserTests: XCTestCase { | ||
func testParse() throws { | ||
let components = try XCTUnwrap(URLComponents(string: "example://module/subject/verb")) | ||
XCTAssertEqual(try URLComponentsParser().parse(components), StringAction(module: "module", subject: "subject", verb: "verb")) | ||
} | ||
|
||
func testParseWithFlatMap() throws { | ||
let components = try XCTUnwrap(URLComponents(string: "myapp://amazing/action/execute/withpower?intensity=9000")) | ||
let result = try components.parse { | ||
Passthrough<StringAction>() | ||
} | ||
XCTAssertEqual(result, StringAction(module: "amazing", subject: "action", verb: "execute", object: "withpower", payload: ["intensity":"9000"])) | ||
} | ||
} |