Skip to content

Commit 6e0b6e6

Browse files
committed
Removed unused code
1 parent 41edc9e commit 6e0b6e6

File tree

2 files changed

+33
-78
lines changed

2 files changed

+33
-78
lines changed

WooCommerce/Classes/ViewRelated/Products/ProductDetailsFactory.swift

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,6 @@ import Yosemite
33
import WooFoundation
44

55
struct ProductDetailsFactory {
6-
/// Creates a product details view controller asynchronously based on the app settings.
7-
/// - Parameters:
8-
/// - product: product model.
9-
/// - presentationStyle: how the product details are presented.
10-
/// - currencySettings: site currency settings.
11-
/// - forceReadOnly: force the product detail to be presented in read only mode
12-
/// - onDeleteCompletion: called when the product deletion completes in the product form.
13-
/// - onCompletion: called when the view controller is created and ready for display.
14-
static func productDetails(product: Product,
15-
presentationStyle: ProductFormPresentationStyle,
16-
currencySettings: CurrencySettings = ServiceLocator.currencySettings,
17-
forceReadOnly: Bool,
18-
productImageUploader: ProductImageUploaderProtocol = ServiceLocator.productImageUploader,
19-
onDeleteCompletion: @escaping () -> Void = {},
20-
onCompletion: @escaping (UIViewController) -> Void) {
21-
let vc = productDetails(product: product,
22-
presentationStyle: presentationStyle,
23-
currencySettings: currencySettings,
24-
isEditProductsEnabled: forceReadOnly ? false: true,
25-
productImageUploader: productImageUploader,
26-
onDeleteCompletion: onDeleteCompletion)
27-
onCompletion(vc)
28-
}
29-
306
/// Creates a product details view controller asynchronously based on the app settings.
317
/// - Parameters:
328
/// - product: product model.

WooCommerce/WooCommerceTests/ViewRelated/Products/ProductDetailsFactoryTests.swift

Lines changed: 33 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -10,70 +10,57 @@ final class ProductDetailsFactoryTests: XCTestCase {
1010
// Arrange
1111
let product = Product.fake().copy(productTypeKey: ProductType.simple.rawValue)
1212

13-
let exp = expectation(description: #function)
1413
// Action
15-
ProductDetailsFactory.productDetails(product: product,
16-
presentationStyle: .navigationStack,
17-
forceReadOnly: false) { viewController in
18-
// Assert
19-
XCTAssertTrue(viewController is ProductFormViewController<ProductFormViewModel>)
20-
exp.fulfill()
21-
}
22-
waitForExpectations(timeout: Constants.expectationTimeout, handler: nil)
14+
let viewController = ProductDetailsFactory.productDetails(product: product,
15+
presentationStyle: .navigationStack,
16+
forceReadOnly: false)
17+
18+
// Assert
19+
XCTAssertTrue(viewController is ProductFormViewController<ProductFormViewModel>)
2320
}
2421

2522
// MARK: External/affiliate product type
2623

2724
func test_factory_creates_product_form_for_affiliate_product() {
2825
// Arrange
2926
let product = Product.fake().copy(productTypeKey: ProductType.affiliate.rawValue)
30-
let exp = expectation(description: #function)
3127

3228
// Action
33-
ProductDetailsFactory.productDetails(product: product,
34-
presentationStyle: .navigationStack,
35-
forceReadOnly: false) { viewController in
36-
// Assert
37-
XCTAssertTrue(viewController is ProductFormViewController<ProductFormViewModel>)
38-
exp.fulfill()
39-
}
40-
waitForExpectations(timeout: Constants.expectationTimeout, handler: nil)
29+
let viewController = ProductDetailsFactory.productDetails(product: product,
30+
presentationStyle: .navigationStack,
31+
forceReadOnly: false)
32+
33+
// Assert
34+
XCTAssertTrue(viewController is ProductFormViewController<ProductFormViewModel>)
4135
}
4236

4337
// MARK: Grouped product type
4438

4539
func test_factory_creates_product_form_for_grouped_product() {
4640
// Arrange
4741
let product = Product.fake().copy(productTypeKey: ProductType.grouped.rawValue)
48-
let exp = expectation(description: #function)
4942

5043
// Action
51-
ProductDetailsFactory.productDetails(product: product,
52-
presentationStyle: .navigationStack,
53-
forceReadOnly: false) { viewController in
54-
// Assert
55-
XCTAssertTrue(viewController is ProductFormViewController<ProductFormViewModel>)
56-
exp.fulfill()
57-
}
58-
waitForExpectations(timeout: Constants.expectationTimeout, handler: nil)
44+
let viewController = ProductDetailsFactory.productDetails(product: product,
45+
presentationStyle: .navigationStack,
46+
forceReadOnly: false)
47+
// Assert
48+
XCTAssertTrue(viewController is ProductFormViewController<ProductFormViewModel>)
5949
}
6050

6151
// MARK: Variable product type
6252

6353
func test_factory_creates_product_form_for_variable_product() {
6454
// Arrange
6555
let product = Product.fake().copy(productTypeKey: ProductType.variable.rawValue)
66-
let exp = expectation(description: #function)
6756

6857
// Action
69-
ProductDetailsFactory.productDetails(product: product,
70-
presentationStyle: .navigationStack,
71-
forceReadOnly: false) { viewController in
72-
// Assert
73-
XCTAssertTrue(viewController is ProductFormViewController<ProductFormViewModel>)
74-
exp.fulfill()
75-
}
76-
waitForExpectations(timeout: Constants.expectationTimeout, handler: nil)
58+
let viewController = ProductDetailsFactory.productDetails(product: product,
59+
presentationStyle: .navigationStack,
60+
forceReadOnly: false)
61+
62+
// Assert
63+
XCTAssertTrue(viewController is ProductFormViewController<ProductFormViewModel>)
7764
}
7865

7966
// MARK: Non-core product type
@@ -83,30 +70,22 @@ final class ProductDetailsFactoryTests: XCTestCase {
8370
let product = Product.fake().copy(productTypeKey: "other")
8471

8572
// Action
86-
waitForExpectation { expectation in
87-
ProductDetailsFactory.productDetails(product: product,
88-
presentationStyle: .navigationStack,
89-
forceReadOnly: false) { viewController in
90-
// Assert
91-
XCTAssertTrue(viewController is ProductFormViewController<ProductFormViewModel>)
92-
expectation.fulfill()
93-
}
94-
}
73+
let viewController = ProductDetailsFactory.productDetails(product: product,
74+
presentationStyle: .navigationStack,
75+
forceReadOnly: false)
76+
// Assert
77+
XCTAssertTrue(viewController is ProductFormViewController<ProductFormViewModel>)
9578
}
9679

9780
func test_factory_creates_readonly_product_details_for_product_when_forceReadOnly_is_on() {
9881
// Arrange
9982
let product = Product.fake().copy(productTypeKey: ProductType.simple.rawValue)
10083

10184
// Action
102-
waitForExpectation { expectation in
103-
ProductDetailsFactory.productDetails(product: product,
104-
presentationStyle: .navigationStack,
105-
forceReadOnly: true) { viewController in
106-
// Assert
107-
XCTAssertTrue(viewController is ProductFormViewController<ProductFormViewModel>)
108-
expectation.fulfill()
109-
}
110-
}
85+
let viewController = ProductDetailsFactory.productDetails(product: product,
86+
presentationStyle: .navigationStack,
87+
forceReadOnly: true)
88+
// Assert
89+
XCTAssertTrue(viewController is ProductFormViewController<ProductFormViewModel>)
11190
}
11291
}

0 commit comments

Comments
 (0)