[CM-900] Organized test files
This commit is contained in:
parent
a8c2da4dba
commit
174bd7ed3e
|
@ -1,114 +0,0 @@
|
|||
//
|
||||
// catalogCategoryTest.swift
|
||||
//
|
||||
// Created by Y Media Labs on 08/09/22.
|
||||
//
|
||||
import XCTest
|
||||
@testable import YComponentBrowser
|
||||
|
||||
final class CatalogCategoryTest: XCTestCase {
|
||||
var controller = UIViewController()
|
||||
func testCatalogCategory() {
|
||||
let category = CatalogCategory(
|
||||
name: "category",
|
||||
subcategories:
|
||||
[
|
||||
Demo(
|
||||
destination: Demodestination(
|
||||
present: .detail,
|
||||
title: "color",
|
||||
controller: controller
|
||||
)
|
||||
)
|
||||
]
|
||||
)
|
||||
XCTAssertEqual("category", category.destination.navigationTitle)
|
||||
XCTAssertEqual(.detail, category.destination.presentationStyle)
|
||||
}
|
||||
|
||||
func testSubcategoryDestination() {
|
||||
let subcategory = SubcategoryDetailDestination(
|
||||
presentationStyle: .detail,
|
||||
navigationTitle: "title",
|
||||
subcategories:
|
||||
[
|
||||
Demo(
|
||||
destination: Demodestination(
|
||||
present: .detail,
|
||||
title: "color",
|
||||
controller: controller
|
||||
)
|
||||
)
|
||||
]
|
||||
)
|
||||
XCTAssertEqual("title", subcategory.navigationTitle)
|
||||
XCTAssertEqual(.detail, subcategory.subcategories[0].presentationStyle)
|
||||
XCTAssertEqual(
|
||||
type(
|
||||
of: subcategory.getDestinationController()
|
||||
) == ClassificationViewController<ClassificationDataSource>.self,
|
||||
true
|
||||
)
|
||||
}
|
||||
|
||||
func testCatalogDestination() {
|
||||
let catalogDestination = CatalogDetailDestination<DemoView>(
|
||||
presentationStyle: .detail,
|
||||
navigationTitle: "title",
|
||||
models: [DemoModel()]
|
||||
)
|
||||
XCTAssertEqual(.detail, catalogDestination.presentationStyle)
|
||||
XCTAssertNotNil(catalogDestination.getDestinationController())
|
||||
}
|
||||
|
||||
func testClassificationDataSource() {
|
||||
let tableview = UITableView()
|
||||
let classificationDataSource = ClassificationDataSource(navigationTitle: "title", classification:
|
||||
[
|
||||
Demo(
|
||||
destination: Demodestination(
|
||||
present: .detail,
|
||||
title: "color",
|
||||
controller: controller
|
||||
)
|
||||
)
|
||||
])
|
||||
XCTAssertEqual(
|
||||
1,
|
||||
classificationDataSource.tableView(
|
||||
UITableView(),
|
||||
numberOfRowsInSection: classificationDataSource.categories.count
|
||||
)
|
||||
)
|
||||
|
||||
tableview.register(
|
||||
ClassificationDataSource.cell,
|
||||
forCellReuseIdentifier: ClassificationDataSource.cellIdentifier
|
||||
)
|
||||
let tableCell = classificationDataSource.tableView(tableview, cellForRowAt: [0, 0])
|
||||
XCTAssertNotNil(tableCell)
|
||||
}
|
||||
}
|
||||
|
||||
class Demo: Classification {
|
||||
var name: String = ""
|
||||
var destination: Destination
|
||||
public init(destination: Destination) {
|
||||
self.destination = destination
|
||||
}
|
||||
}
|
||||
|
||||
class Demodestination: Destination {
|
||||
func getDestinationController() -> UIViewController {
|
||||
return controller
|
||||
}
|
||||
|
||||
var presentationStyle: Presentation
|
||||
var navigationTitle: String?
|
||||
var controller: UIViewController
|
||||
public init(present: Presentation, title: String, controller: UIViewController) {
|
||||
presentationStyle = present
|
||||
navigationTitle = title
|
||||
self.controller = controller
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
//
|
||||
// ClassificationDataSourceTests.swift
|
||||
//
|
||||
// Created by Panchami Shenoy on 06/10/22.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import YComponentBrowser
|
||||
|
||||
final class ClassificationDataSourceTests: XCTestCase {
|
||||
var controller = UIViewController()
|
||||
|
||||
func testClassificationDataSource() {
|
||||
let tableview = UITableView()
|
||||
let classificationDataSource = ClassificationDataSource(
|
||||
navigationTitle: "title",
|
||||
classification: [
|
||||
Demo(
|
||||
destination: Demodestination(
|
||||
present: .detail,
|
||||
title: "color",
|
||||
controller: controller
|
||||
)
|
||||
)
|
||||
]
|
||||
)
|
||||
XCTAssertEqual(
|
||||
1,
|
||||
classificationDataSource.tableView(
|
||||
UITableView(),
|
||||
numberOfRowsInSection: classificationDataSource.categories.count
|
||||
)
|
||||
)
|
||||
|
||||
tableview.register(
|
||||
ClassificationDataSource.cell,
|
||||
forCellReuseIdentifier: ClassificationDataSource.cellIdentifier
|
||||
)
|
||||
let tableCell = classificationDataSource.tableView(tableview, cellForRowAt: [0, 0])
|
||||
XCTAssertNotNil(tableCell)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
//
|
||||
// catalogCategoryTest.swift
|
||||
//
|
||||
// Created by Y Media Labs on 08/09/22.
|
||||
//
|
||||
import XCTest
|
||||
@testable import YComponentBrowser
|
||||
|
||||
final class CatalogCategoryTest: XCTestCase {
|
||||
var controller = UIViewController()
|
||||
func testCatalogCategory() {
|
||||
let category = CatalogCategory(
|
||||
name: "category",
|
||||
subcategories:
|
||||
[
|
||||
Demo(
|
||||
destination: Demodestination(
|
||||
present: .detail,
|
||||
title: "color",
|
||||
controller: controller
|
||||
)
|
||||
)
|
||||
]
|
||||
)
|
||||
XCTAssertEqual("category", category.destination.navigationTitle)
|
||||
XCTAssertEqual(.detail, category.destination.presentationStyle)
|
||||
}
|
||||
}
|
||||
|
||||
class Demo: Classification {
|
||||
var name: String = ""
|
||||
var destination: Destination
|
||||
public init(destination: Destination) {
|
||||
self.destination = destination
|
||||
}
|
||||
}
|
||||
|
||||
class Demodestination: Destination {
|
||||
func getDestinationController() -> UIViewController {
|
||||
return controller
|
||||
}
|
||||
|
||||
var presentationStyle: Presentation
|
||||
var navigationTitle: String?
|
||||
var controller: UIViewController
|
||||
public init(present: Presentation, title: String, controller: UIViewController) {
|
||||
presentationStyle = present
|
||||
navigationTitle = title
|
||||
self.controller = controller
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
//
|
||||
// CatalogDestinationTests.swift
|
||||
//
|
||||
// Created by Panchami Shenoy on 06/10/22.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import YComponentBrowser
|
||||
|
||||
final class CatalogDestinationTests: XCTestCase {
|
||||
func testCatalogDestination() {
|
||||
let catalogDestination = CatalogDetailDestination<DemoView>(
|
||||
presentationStyle: .detail,
|
||||
navigationTitle: "title",
|
||||
models: [DemoModel()]
|
||||
)
|
||||
XCTAssertEqual(.detail, catalogDestination.presentationStyle)
|
||||
XCTAssertNotNil(catalogDestination.getDestinationController())
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
//
|
||||
// SubcategoryDestinationTests.swift
|
||||
//
|
||||
// Created by Panchami Shenoy on 06/10/22.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import YComponentBrowser
|
||||
|
||||
final class SubcategoryDestinationTests: XCTestCase {
|
||||
var controller = UIViewController()
|
||||
func testSubcategoryDestination() {
|
||||
let subcategory = SubcategoryDetailDestination(
|
||||
presentationStyle: .detail,
|
||||
navigationTitle: "title",
|
||||
subcategories:
|
||||
[
|
||||
Demo(
|
||||
destination: Demodestination(
|
||||
present: .detail,
|
||||
title: "color",
|
||||
controller: controller
|
||||
)
|
||||
)
|
||||
]
|
||||
)
|
||||
XCTAssertEqual("title", subcategory.navigationTitle)
|
||||
XCTAssertEqual(.detail, subcategory.subcategories[0].presentationStyle)
|
||||
XCTAssertEqual(
|
||||
type(
|
||||
of: subcategory.getDestinationController()
|
||||
) == ClassificationViewController<ClassificationDataSource>.self,
|
||||
true
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue