@@ -10,11 +10,8 @@ final class DefaultProductFormTableViewModel_EditProductsM3Tests: XCTestCase {
1010
1111 private let mockFeatureFlagService = MockFeatureFlagService ( isEditProductsRelease2On: true , isEditProductsRelease3On: true )
1212
13- func testViewModelForSimplePhysicalProductWithoutImages( ) {
14- let product = MockProduct ( ) . product ( downloadable: false ,
15- name: " woo " ,
16- productType: . simple,
17- virtual: false )
13+ func testViewModelForPhysicalSimpleProductWithoutImages( ) {
14+ let product = Fixtures . physicalSimpleProductWithoutImages
1815 let viewModel = DefaultProductFormTableViewModel ( product: product,
1916 currency: " $ " ,
2017 featureFlagService: mockFeatureFlagService)
@@ -51,11 +48,7 @@ final class DefaultProductFormTableViewModel_EditProductsM3Tests: XCTestCase {
5148 }
5249
5350 func testViewModelForPhysicalSimpleProductWithImages( ) {
54- let product = MockProduct ( ) . product ( downloadable: false ,
55- name: " woo " ,
56- productType: . simple,
57- virtual: true ,
58- images: sampleImages ( ) )
51+ let product = Fixtures . physicalSimpleProductWithImages
5952 let viewModel = DefaultProductFormTableViewModel ( product: product,
6053 currency: " $ " ,
6154 featureFlagService: mockFeatureFlagService)
@@ -69,29 +62,30 @@ final class DefaultProductFormTableViewModel_EditProductsM3Tests: XCTestCase {
6962 let settingFieldsSection = viewModel. sections [ 1 ]
7063 switch settingFieldsSection {
7164 case . settings( let rows) :
72- XCTAssertEqual ( rows. count, 4 )
65+ XCTAssertEqual ( rows. count, 5 )
7366
7467 if case . price( _) = rows [ 0 ] { } else {
7568 XCTFail ( " Unexpected setting section: \( rows [ 0 ] ) " )
7669 }
77- if case . inventory ( _) = rows [ 1 ] { } else {
70+ if case . shipping ( _) = rows [ 1 ] { } else {
7871 XCTFail ( " Unexpected setting section: \( rows [ 1 ] ) " )
7972 }
80- if case . categories ( _) = rows [ 2 ] { } else {
73+ if case . inventory ( _) = rows [ 2 ] { } else {
8174 XCTFail ( " Unexpected setting section: \( rows [ 2 ] ) " )
8275 }
83- if case . briefDescription ( _) = rows [ 3 ] { } else {
76+ if case . categories ( _) = rows [ 3 ] { } else {
8477 XCTFail ( " Unexpected setting section: \( rows [ 3 ] ) " )
8578 }
79+ if case . briefDescription( _) = rows [ 4 ] { } else {
80+ XCTFail ( " Unexpected setting section: \( rows [ 4 ] ) " )
81+ }
8682 default :
8783 XCTFail ( " Unexpected section: \( settingFieldsSection) " )
8884 }
8985 }
9086
9187 func testViewModelForDownloadableSimpleProduct( ) {
92- let product = MockProduct ( ) . product ( downloadable: true ,
93- name: " woo " ,
94- productType: . simple)
88+ let product = Fixtures . downloadableSimpleProduct
9589 let viewModel = DefaultProductFormTableViewModel ( product: product,
9690 currency: " $ " ,
9791 featureFlagService: mockFeatureFlagService)
@@ -124,10 +118,7 @@ final class DefaultProductFormTableViewModel_EditProductsM3Tests: XCTestCase {
124118 }
125119
126120 func testViewModelForVirtualSimpleProduct( ) {
127- let product = MockProduct ( ) . product ( downloadable: false ,
128- name: " woo " ,
129- productType: . simple,
130- virtual: true )
121+ let product = Fixtures . virtualSimpleProduct
131122 let viewModel = DefaultProductFormTableViewModel ( product: product,
132123 currency: " $ " ,
133124 featureFlagService: mockFeatureFlagService)
@@ -161,13 +152,37 @@ final class DefaultProductFormTableViewModel_EditProductsM3Tests: XCTestCase {
161152}
162153
163154private extension DefaultProductFormTableViewModel_EditProductsM3Tests {
164- func sampleImages( ) -> [ ProductImage ] {
165- let image1 = ProductImage ( imageID: 19 ,
166- dateCreated: Date ( ) ,
167- dateModified: Date ( ) ,
168- src: " https://photo.jpg " ,
169- name: " Tshirt " ,
170- alt: " " )
171- return [ image1]
155+ enum Fixtures {
156+ static let category = ProductCategory ( categoryID: 1 , siteID: 2 , parentID: 6 , name: " " , slug: " " )
157+ static let image = ProductImage ( imageID: 19 ,
158+ dateCreated: Date ( ) ,
159+ dateModified: Date ( ) ,
160+ src: " https://photo.jpg " ,
161+ name: " Tshirt " ,
162+ alt: " " )
163+ // downloadable: false, virtual: false, with inventory/shipping/categories/brief description
164+ static let physicalSimpleProductWithoutImages = MockProduct ( ) . product ( downloadable: false , briefDescription: " desc " , productType: . simple,
165+ manageStock: true , sku: " uks " , stockQuantity: nil ,
166+ dimensions: ProductDimensions ( length: " " , width: " " , height: " " ) , weight: " 2 " ,
167+ virtual: false ,
168+ categories: [ category] , images: [ ] )
169+ // downloadable: false, virtual: true, with inventory/shipping/categories/brief description
170+ static let physicalSimpleProductWithImages = MockProduct ( ) . product ( downloadable: false , briefDescription: " desc " , productType: . simple,
171+ manageStock: true , sku: " uks " , stockQuantity: nil ,
172+ dimensions: ProductDimensions ( length: " " , width: " " , height: " " ) , weight: " 2 " ,
173+ virtual: false ,
174+ categories: [ category] , images: [ image] )
175+ // downloadable: false, virtual: true, with inventory/shipping/categories/brief description
176+ static let virtualSimpleProduct = MockProduct ( ) . product ( downloadable: false , briefDescription: " desc " , productType: . simple,
177+ manageStock: true , sku: " uks " , stockQuantity: nil ,
178+ dimensions: ProductDimensions ( length: " " , width: " " , height: " " ) , weight: " 2 " ,
179+ virtual: true ,
180+ categories: [ category] )
181+ // downloadable: true, virtual: true, missing inventory/shipping/categories/brief description
182+ static let downloadableSimpleProduct = MockProduct ( ) . product ( downloadable: true , briefDescription: " desc " , productType: . simple,
183+ manageStock: true , sku: " uks " , stockQuantity: nil ,
184+ dimensions: ProductDimensions ( length: " " , width: " " , height: " " ) , weight: " 3 " ,
185+ virtual: true ,
186+ categories: [ category] )
172187 }
173188}
0 commit comments