@@ -51,10 +51,52 @@ class readium_opds1_1_test: XCTestCase {
5151 }
5252
5353 func testLinks( ) {
54- XCTAssertEqual ( feed. links. count, 4 )
55- XCTAssertEqual ( feed. links [ 0 ] . rels, [ " related " ] )
56- XCTAssertEqual ( feed. links [ 1 ] . mediaType, MediaType ( " application/atom+xml;profile=opds-catalog;kind=acquisition " ) !)
57- XCTAssertEqual ( feed. links [ 2 ] . href, " http://test.com/opds-catalogs/root.xml " )
54+ XCTAssertEqual ( feed. links. count, 5 )
55+
56+ // Has a "related" link
57+ let expectedRelatedLink = Link (
58+ href: " http://test.com/opds-catalogs/vampire.farming.xml " ,
59+ mediaType: MediaType ( " application/atom+xml;profile=opds-catalog;kind=acquisition " ) !,
60+ rels: [ " related " ]
61+ )
62+ let relatedLink = feed? . links. first { $0. rels. contains ( " related " ) }
63+ XCTAssertEqual ( relatedLink, expectedRelatedLink)
64+
65+ // Has a "self" link
66+ let expectedSelfLink = Link (
67+ href: " http://test.com/opds-catalogs/unpopular.xml " ,
68+ mediaType: MediaType ( " application/atom+xml;profile=opds-catalog;kind=acquisition " ) !,
69+ rels: [ " self " ]
70+ )
71+ let selfLink = feed? . links. first { $0. rels. contains ( " self " ) }
72+ XCTAssertEqual ( selfLink, expectedSelfLink)
73+
74+ // Has a "start" link
75+ let expectedStartLink = Link (
76+ href: " http://test.com/opds-catalogs/root.xml " ,
77+ mediaType: MediaType ( " application/atom+xml;profile=opds-catalog;kind=navigation " ) !,
78+ rels: [ " start " ]
79+ )
80+ let startLink = feed? . links. first { $0. rels. contains ( " start " ) }
81+ XCTAssertEqual ( startLink, expectedStartLink)
82+
83+ // Has an "up" link
84+ let expectedUpLink = Link (
85+ href: " http://test.com/opds-catalogs/root.xml " ,
86+ mediaType: MediaType ( " application/atom+xml;profile=opds-catalog;kind=navigation " ) !,
87+ rels: [ " up " ]
88+ )
89+ let upLink = feed? . links. first { $0. rels. contains ( " up " ) }
90+ XCTAssertEqual ( upLink, expectedUpLink)
91+
92+ // Has an "icon" link
93+ let expectedIconLink = Link (
94+ href: " http://test.com/images/favicon.ico?t=1516986276 " ,
95+ rels: [ " icon " ]
96+ )
97+ let iconLink = feed? . links. first { $0. rels. contains ( " icon " ) }
98+ XCTAssertEqual ( iconLink, expectedIconLink)
99+
58100 // TODO: add more tests...
59101 }
60102
0 commit comments