Skip to content

Commit

Permalink
feat(tests): update CollectionViewModelTests using ReportData
Browse files Browse the repository at this point in the history
  • Loading branch information
Gio2018 committed Jul 1, 2024
1 parent d711ae5 commit c6c0c1a
Showing 1 changed file with 2 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,8 @@ class CollectionViewModelTests: XCTestCase {
viewModel.fetch()

let reportExpectation = expectation(description: "expected item to be reported")
viewModel.$reportedCollectionUrl.dropFirst().sink { url in
XCTAssertNotEqual("", url)
viewModel.$reportedCollection.dropFirst().sink { reportData in
XCTAssertNotEqual("", reportData?.urlString)
reportExpectation.fulfill()
}.store(in: &subscriptions)

Expand Down Expand Up @@ -648,39 +648,6 @@ class CollectionViewModelTests: XCTestCase {
wait(for: [readableExpectation], timeout: 1)
}

// MARK: - Story Actions
@MainActor
func test_reportAction_forStories_updatesSelectedStoryToReport() throws {
let item = space.buildItem()
let story = space.buildCollectionStory(item: item)

source.stubFetchItem { url in
return item
}
let collection = space.buildCollection(stories: [story], item: item)

source.stubMakeCollectionStoriesController {
self.collectionController
}

source.stubFetchCollection { _ in }

let viewModel = subject(slug: collection.slug)

let reportExpectation = expectation(description: "expected to update selected story to report")
viewModel.$reportedStoryUrl.dropFirst().sink { url in
XCTAssertNotEqual("", url)
reportExpectation.fulfill()
}.store(in: &subscriptions)

let storyViewModel = viewModel.storyViewModel(for: story)
let action = storyViewModel.overflowActions?.first { $0.identifier == .report }
XCTAssertNotNil(action)
action?.handler?(nil)

wait(for: [reportExpectation], timeout: 1)
}

@MainActor
func test_shareAction_forStories_updatesSelectedStoryToShare() throws {
let item = space.buildItem()
Expand Down

0 comments on commit c6c0c1a

Please sign in to comment.