1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@testable import Grain
import XCTest
final class FeedEndpointModelTests: GrainTestCase {
// MARK: - PinnedFeed.feedName
func testFeedNameForCameraType() {
let feed = PinnedFeed(id: "camera:Sony A7III", label: "Sony A7III", type: "camera", path: "/feeds/camera")
XCTAssertEqual(feed.feedName, "camera")
}
func testFeedNameForLocationType() {
let feed = PinnedFeed(id: "location:tokyo", label: "Tokyo", type: "location", path: "/feeds/location")
XCTAssertEqual(feed.feedName, "location")
}
func testFeedNameForHashtagType() {
let feed = PinnedFeed(id: "hashtag:streetphoto", label: "#streetphoto", type: "hashtag", path: "/feeds/hashtag")
XCTAssertEqual(feed.feedName, "hashtag")
}
func testFeedNameDefaultsToId() {
let feed = PinnedFeed(id: "following", label: "Following", type: "feed", path: "/feeds/following")
XCTAssertEqual(feed.feedName, "following")
}
// MARK: - PinnedFeed.feedValue
func testFeedValueExtractsAfterColon() {
let feed = PinnedFeed(id: "camera:Sony A7III", label: "Sony A7III", type: "camera", path: "/")
XCTAssertEqual(feed.feedValue, "Sony A7III")
}
func testFeedValueNilWithoutColon() {
let feed = PinnedFeed(id: "recent", label: "Recent", type: "feed", path: "/")
XCTAssertNil(feed.feedValue)
}
func testFeedValueHandlesMultipleColons() {
let feed = PinnedFeed(id: "tag:key:value", label: "Test", type: "tag", path: "/")
XCTAssertEqual(feed.feedValue, "key:value")
}
// MARK: - PinnedFeed.defaults
func testDefaultsContainsThreeFeeds() {
XCTAssertEqual(PinnedFeed.defaults.count, 3)
XCTAssertEqual(PinnedFeed.defaults[0].id, "recent")
XCTAssertEqual(PinnedFeed.defaults[1].id, "following")
XCTAssertEqual(PinnedFeed.defaults[2].id, "foryou")
}
}