Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
scottkicks committed Sep 20, 2023
1 parent 1d4a330 commit 63012ba
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ final class Project_FetchProjectQueryDataTests: XCTestCase {
// Project Send Capi Events
XCTAssertEqual(project.sendMetaCapiEvents, true)

// Project Flagging
XCTAssertEqual(project.flagging, false)

/// Project User
XCTAssertEqual(
project.creator.avatar.large,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ final class Project_ProjectFragmentTests: XCTestCase {

let project = Project.project(
from: fragment,
flagging: false,
currentUserChosenCurrency: nil
)

Expand Down Expand Up @@ -60,6 +61,7 @@ final class Project_ProjectFragmentTests: XCTestCase {
XCTAssertTrue(project.staffPick)
XCTAssertTrue(project.prelaunchActivated!)
XCTAssertFalse(project.displayPrelaunch!)
XCTAssertEqual(project.flagging, false)
XCTAssertNil(project.personalization.backing)
XCTAssertNil(project.rewardData.addOns)
XCTAssertEqual(project.sendMetaCapiEvents, false)
Expand Down
2 changes: 1 addition & 1 deletion Library/ViewModels/ProjectPageViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public protocol ProjectPageViewModelOutputs {
/// Emits `[ImageViewElement]` when the project has campaign data to download for an image row as soon as the urls are available.
var prefetchImageURLsOnFirstLoad: Signal<[ImageViewElement], Never> { get }

/// Emits a `Bool`when a project is flagged.
/// Emits a `Bool` when a project is flagged.
var projectFlagged: Signal<Bool, Never> { get }

/// Emits a signal when an orientation change happens if the currently selected tab is campaign.
Expand Down
20 changes: 20 additions & 0 deletions Library/ViewModels/ProjectPageViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ final class ProjectPageViewModelTests: TestCase {
private let prefetchImageURLsFirstLoad = TestObserver<[ImageViewElement], Never>()
private let precreateAudioVideoURLs = TestObserver<(AudioVideoViewElement, IndexPath), Never>()
private let precreateAudioVideoURLsFirstLoad = TestObserver<[AudioVideoViewElement], Never>()
private let projectFlagged = TestObserver<Bool, Never>()
private let reloadCampaignData = TestObserver<(), Never>()
private let showHelpWebViewController = TestObserver<HelpType, Never>()
private let updateDataSourceNavigationSection = TestObserver<NavigationSection, Never>()
Expand Down Expand Up @@ -116,6 +117,7 @@ final class ProjectPageViewModelTests: TestCase {
self.vm.outputs.precreateAudioVideoURLsOnFirstLoad.observe(self.precreateAudioVideoURLsFirstLoad.observer)
self.vm.outputs.prefetchImageURLs.observe(self.prefetchImageURLs.observer)
self.vm.outputs.prefetchImageURLsOnFirstLoad.observe(self.prefetchImageURLsFirstLoad.observer)
self.vm.outputs.projectFlagged.observe(self.projectFlagged.observer)
self.vm.outputs.reloadCampaignData.observe(self.reloadCampaignData.observer)
self.vm.outputs.showHelpWebViewController.observe(self.showHelpWebViewController.observer)
self.vm.outputs.updateDataSource.map { $0.0 }
Expand Down Expand Up @@ -1387,6 +1389,24 @@ final class ProjectPageViewModelTests: TestCase {

self.presentMessageDialog.assertValues([.template])
}

func testOutput_ProjectFlagged_False() {
self.vm.inputs.configureWith(projectOrParam: .left(.template), refTag: nil)
self.vm.inputs.viewDidLoad()

self.projectFlagged.assertValue(false)
}

func testOutput_ProjectFlagged_True() {
var project = Project.template
project.flagging = true

self.vm.inputs.configureWith(projectOrParam: .left(project), refTag: nil)
self.vm.inputs.viewDidLoad()

self.projectFlagged.assertValue(true)
}


func testOutput_ShowHelpWebViewController() {
self.vm.inputs.configureWith(projectOrParam: .left(.template), refTag: nil)
Expand Down

0 comments on commit 63012ba

Please sign in to comment.