Skip to content

Commit c90e26e

Browse files
committed
add: parse local cards
1 parent e16b8ea commit c90e26e

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Service/BlogDashboardService.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ class BlogDashboardService {
4040

4141
}
4242

43+
} else {
44+
let section = DashboardCardSection(id: card.rawValue)
45+
let item = DashboardCardModel(id: card)
46+
47+
snapshot.appendSections([section])
48+
snapshot.appendItems([item], toSection: section)
4349
}
4450

4551
}

WordPress/WordPressTest/Dashboard/BlogDashboardServiceTests.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,27 @@ class BlogDashboardServiceTests: XCTestCase {
9595

9696
waitForExpectations(timeout: 3, handler: nil)
9797
}
98+
99+
func testLocalCards() {
100+
let expect = expectation(description: "Return local cards stats")
101+
remoteServiceMock.respondWith = .withDraftAndSchedulePosts
102+
103+
service.fetch(wpComID: 123456) { snapshot in
104+
// Quick Actions exists
105+
let quickActionsSection = snapshot.sectionIdentifiers.filter { $0.id == "quickActions" }
106+
XCTAssertEqual(quickActionsSection.count, 1)
107+
108+
// The item identifier id is quick actions
109+
XCTAssertEqual(snapshot.itemIdentifiers(inSection: quickActionsSection.first!).first?.id, .quickActions)
110+
111+
// It doesn't have a data source
112+
XCTAssertNil(snapshot.itemIdentifiers(inSection: quickActionsSection.first!).first?.cellViewModel)
113+
114+
expect.fulfill()
115+
}
116+
117+
waitForExpectations(timeout: 3, handler: nil)
118+
}
98119
}
99120

100121
class DashboardServiceRemoteMock: DashboardServiceRemote {

0 commit comments

Comments
 (0)