File tree Expand file tree Collapse file tree 3 files changed +8
-8
lines changed
Classes/ViewRelated/Products Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import Yosemite
44import Experiments
55
66protocol ProductsListViewModelProtocol {
7- func scanToUpdateInventoryButtonShouldBeVisible( completion: @escaping ( Bool ) -> ( Void ) )
7+ func scanToUpdateInventoryButtonShouldBeVisible( isCameraAvailable : Bool , completion: @escaping ( Bool ) -> ( Void ) )
88}
99
1010/// View model for `ProductsViewController`. Has stores logic related to Bulk Editing and Woo Subscriptions.
@@ -201,14 +201,14 @@ final class ProductListViewModel: ProductsListViewModelProtocol {
201201 // The feature breaks if the Square plugin is active, since modifies inventory management logic
202202 // If the plugin is active, we'll hide the inventory scanner button
203203 // More details: https://wp.me/pdfdoF-2Nq
204- func scanToUpdateInventoryButtonShouldBeVisible( completion: @escaping ( Bool ) -> ( Void ) ) {
204+ func scanToUpdateInventoryButtonShouldBeVisible( isCameraAvailable: Bool = UIImagePickerController . isSourceTypeAvailable ( . camera) ,
205+ completion: @escaping ( Bool ) -> ( Void ) ) {
205206 let isPluginActive = isPluginActive ( . wooSquare)
206207 switch isPluginActive {
207208 case true :
208209 completion ( false )
209210 case false :
210- guard featureFlagService. isFeatureFlagEnabled ( . scanToUpdateInventory) ,
211- UIImagePickerController . isSourceTypeAvailable ( . camera) else {
211+ guard featureFlagService. isFeatureFlagEnabled ( . scanToUpdateInventory) , isCameraAvailable else {
212212 return completion ( false )
213213 }
214214 // If all conditions are met, scan to update inventory should be visible:
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ final class MockProductListViewModel: ProductsListViewModelProtocol {
1111 self . featureFlagService = featureFlagService
1212 }
1313
14- func scanToUpdateInventoryButtonShouldBeVisible( completion: @escaping ( Bool ) -> ( Void ) ) {
14+ func scanToUpdateInventoryButtonShouldBeVisible( isCameraAvailable : Bool = true , completion: @escaping ( Bool ) -> ( Void ) ) {
1515 guard self . featureFlagService. isFeatureFlagEnabled ( . scanToUpdateInventory) else {
1616 scanToUpdateInventoryShouldBeVisible = false
1717 return completion ( false )
Original file line number Diff line number Diff line change @@ -360,7 +360,7 @@ final class ProductListViewModelTests: XCTestCase {
360360
361361 // When
362362 let result = waitFor { promise in
363- viewModel. scanToUpdateInventoryButtonShouldBeVisible { result in
363+ viewModel. scanToUpdateInventoryButtonShouldBeVisible ( isCameraAvailable : true ) { result in
364364 promise ( result)
365365 }
366366 }
@@ -388,7 +388,7 @@ final class ProductListViewModelTests: XCTestCase {
388388
389389 // When
390390 let result = waitFor { promise in
391- viewModel. scanToUpdateInventoryButtonShouldBeVisible { result in
391+ viewModel. scanToUpdateInventoryButtonShouldBeVisible ( isCameraAvailable : true ) { result in
392392 promise ( result)
393393 }
394394 }
@@ -412,7 +412,7 @@ final class ProductListViewModelTests: XCTestCase {
412412
413413 // When
414414 let result = waitFor { promise in
415- viewModel. scanToUpdateInventoryButtonShouldBeVisible { result in
415+ viewModel. scanToUpdateInventoryButtonShouldBeVisible ( isCameraAvailable : true ) { result in
416416 promise ( result)
417417 }
418418 }
You can’t perform that action at this time.
0 commit comments