Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
patchthecode committed Dec 19, 2016
1 parent a4f028e commit 33cfae4
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 34 deletions.
2 changes: 1 addition & 1 deletion JTAppleCalendar.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "JTAppleCalendar"
s.version = "6.0.5"
s.version = "6.1.0"
s.summary = "The Unofficial Swift Apple Calendar Library. View. Control. for iOS & tvOS"
s.description = <<-DESC
A highly configurable Apple calendar control. Contains features like boundary dates, month and week view. Very light weight.
Expand Down
20 changes: 10 additions & 10 deletions Tests/JTAppleCalendar_iOSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
//
//

import XCTest // 121
@testable import JTAppleCalendar
import XCTest
@testable import JTAppleCalendar

class JTAppleCalendar_iOSTests: XCTestCase {
class JTAppleCalendar_tvOSTests: XCTestCase {
let calendarView = JTAppleCalendarView()
let formatter: DateFormatter = {
let aFormatter = DateFormatter()
Expand Down Expand Up @@ -76,7 +76,7 @@
assert(val.monthMap[70] == 23, "Last val should be 23")
assert(val.totalSections == 71, "There should be 71 sections")
}
func testLayoutGeneratorOnDefaultss() {
func testLayoutGeneratorOnDefaultsFirst() {
let params = ConfigurationParameters(startDate: startDate, endDate: endDate)
let layoutGenerator = JTAppleDateConfigGenerator()
let val = layoutGenerator.setupMonthInfoDataForStartAndEndDate(params)
Expand All @@ -88,7 +88,7 @@
assert(val.totalDays == 42 * 24 , "Total month cells should be 1008")
}

func testLayoutGeneratorOnThreeRows() {
func testLayoutGeneratorOnThreeRowFirst() {
let params = ConfigurationParameters(startDate: startDate, endDate: endDate, numberOfRows: 3)
let layoutGenerator = JTAppleDateConfigGenerator()
let val = layoutGenerator.setupMonthInfoDataForStartAndEndDate(params)
Expand All @@ -97,23 +97,23 @@
assert(val.monthMap[22] == 11, "Index 22 should be 11")
assert(val.monthMap[23] == 11, "Index 22 should be 11")
}
func testLayoutGeneratorOnTwoRows() {
func testLayoutGeneratorOnTwoRowFirst() {
let params = ConfigurationParameters(startDate: startDate, endDate: endDate, numberOfRows: 2)
let layoutGenerator = JTAppleDateConfigGenerator()
let val = layoutGenerator.setupMonthInfoDataForStartAndEndDate(params)
assert(val.months.count == 24, "There should be 24 months")
assert(val.monthMap[71] == 23, "Last val should be 23")
assert(val.totalSections == 72, "There should be 72 sections")
}
func testLayoutGeneratorWithOffInAndOffOuts() {
func testLayoutGeneratorWithOffInAndOffOutFirst() {
let params = ConfigurationParameters(startDate: startDate, endDate: endDate, numberOfRows: 2, generateInDates: .off, generateOutDates: .off)
let layoutGenerator = JTAppleDateConfigGenerator()
let val = layoutGenerator.setupMonthInfoDataForStartAndEndDate(params)
assert(val.months.count == 24, "There should be 24 months")
assert(val.monthMap[70] == 23, "Last val should be 23")
assert(val.totalSections == 71, "There should be 71 sections")
}
func testConfigurationParametersDefaultBehaviors() {
func testConfigurationParametersDefaultBehaviorFirst() {
print("testing default parameters")
var params = ConfigurationParameters(startDate: Date(), endDate: Date())
assert(params.generateInDates == .forAllMonths, "All months should be default")
Expand All @@ -125,7 +125,7 @@
assert(params.numberOfRows == 1, "Rows should be 1")
assert(params.hasStrictBoundaries == false, "strict should be false")
}
func testConfigurationParametersDefaultBehaviorss() {
func testConfigurationParametersDefaultBehaviorsFirst() {
print("testing default parameters")
var params = ConfigurationParameters(startDate: Date(), endDate: Date())
assert(params.generateInDates == .forAllMonths, "All months should be default")
Expand All @@ -137,7 +137,7 @@
assert(params.numberOfRows == 1, "Rows should be 1")
assert(params.hasStrictBoundaries == false, "strict should be false")
}
func testConfigurationParametersDefaultBehaviorsss() {
func testConfigurationParametersDefaultBehaviorssFirst() {
print("testing default parameters")
var params = ConfigurationParameters(startDate: Date(), endDate: Date())
assert(params.generateInDates == .forAllMonths, "All months should be default")
Expand Down
165 changes: 142 additions & 23 deletions Tests/JTAppleCalendar_tvOSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,146 @@
//

import XCTest
@testable import JTAppleCalendar

// class JTAppleCalendar_tvOSTests: XCTestCase {
// override func setUp() {
// super.setUp()
// // Put setup code here. This method is called before the
// // invocation of each test method in the class.
// }
// override func tearDown() {
// // Put teardown code here. This method is called after the
// // invocation of each test method in the class.
// super.tearDown()
// }
// func testExample() {
// // This is an example of a functional test case.
// // Use XCTAssert and related functions to verify your tests
// // produce the correct results.
// }
// func testPerformanceExample() {
// // This is an example of a performance test case.
// self.measureBlock {
// // Put the code you want to measure the time of here.
// }
// }
// }
class JTAppleCalendar_tvOSTests: XCTestCase {
let calendarView = JTAppleCalendarView()
let formatter: DateFormatter = {
let aFormatter = DateFormatter()
aFormatter.dateFormat = "yyyy MM dd"
return aFormatter
}()

var startDate = Date()
var endDate = Date()


override func setUp() {
startDate = formatter.date(from: "2016 01 01")!
endDate = formatter.date(from: "2017 12 01")!
}

func testConfigurationParametersDefaultBehavior() {
print("testing default parameters")
var params = ConfigurationParameters(startDate: Date(), endDate: Date())
assert(params.generateInDates == .forAllMonths, "All months should be default")
assert(params.generateOutDates == .tillEndOfGrid, "Till Grid should be default should be default")
assert(params.numberOfRows == 6, "Rows should be 6")
assert(params.firstDayOfWeek == .sunday, "First day should be sunday")
assert(params.hasStrictBoundaries == true, "strict should be true")
params = ConfigurationParameters(startDate: Date(), endDate: Date(), numberOfRows: 1)
assert(params.numberOfRows == 1, "Rows should be 1")
assert(params.hasStrictBoundaries == false, "strict should be false")
}

func testLayoutGeneratorOnDefaults() {
let params = ConfigurationParameters(startDate: startDate, endDate: endDate)
let layoutGenerator = JTAppleDateConfigGenerator()
let val = layoutGenerator.setupMonthInfoDataForStartAndEndDate(params)
assert(val.months.count == 24, "There should be 24 months")
assert(val.totalSections == 24, "There should be 24 sections.")
for index in 0...23 {
assert(val.monthMap[index] == index, "value of \(index) should be located in the map")
}
assert(val.totalDays == 42 * 24 , "Total month cells should be 1008")
}

func testLayoutGeneratorOnThreeRow() {
let params = ConfigurationParameters(startDate: startDate, endDate: endDate, numberOfRows: 3)
let layoutGenerator = JTAppleDateConfigGenerator()
let val = layoutGenerator.setupMonthInfoDataForStartAndEndDate(params)
assert(val.months.count == 24, "There should be 24 months")
assert(val.totalSections == 48, "There should be 48 sections")
assert(val.monthMap[22] == 11, "Index 22 should be 11")
assert(val.monthMap[23] == 11, "Index 22 should be 11")
}
func testLayoutGeneratorOnTwoRow() {
let params = ConfigurationParameters(startDate: startDate, endDate: endDate, numberOfRows: 2)
let layoutGenerator = JTAppleDateConfigGenerator()
let val = layoutGenerator.setupMonthInfoDataForStartAndEndDate(params)
assert(val.months.count == 24, "There should be 24 months")
assert(val.monthMap[71] == 23, "Last val should be 23")
assert(val.totalSections == 72, "There should be 72 sections")
}
func testLayoutGeneratorWithOffInAndOffOut() {
let params = ConfigurationParameters(startDate: startDate, endDate: endDate, numberOfRows: 2, generateInDates: .off, generateOutDates: .off)
let layoutGenerator = JTAppleDateConfigGenerator()
let val = layoutGenerator.setupMonthInfoDataForStartAndEndDate(params)
assert(val.months.count == 24, "There should be 24 months")
assert(val.monthMap[70] == 23, "Last val should be 23")
assert(val.totalSections == 71, "There should be 71 sections")
}
func testLayoutGeneratorOnDefaultsFirst() {
let params = ConfigurationParameters(startDate: startDate, endDate: endDate)
let layoutGenerator = JTAppleDateConfigGenerator()
let val = layoutGenerator.setupMonthInfoDataForStartAndEndDate(params)
assert(val.months.count == 24, "There should be 24 months")
assert(val.totalSections == 24, "There should be 24 sections.")
for index in 0...23 {
assert(val.monthMap[index] == index, "value of \(index) should be located in the map")
}
assert(val.totalDays == 42 * 24 , "Total month cells should be 1008")
}

func testLayoutGeneratorOnThreeRowFirst() {
let params = ConfigurationParameters(startDate: startDate, endDate: endDate, numberOfRows: 3)
let layoutGenerator = JTAppleDateConfigGenerator()
let val = layoutGenerator.setupMonthInfoDataForStartAndEndDate(params)
assert(val.months.count == 24, "There should be 24 months")
assert(val.totalSections == 48, "There should be 48 sections")
assert(val.monthMap[22] == 11, "Index 22 should be 11")
assert(val.monthMap[23] == 11, "Index 22 should be 11")
}
func testLayoutGeneratorOnTwoRowFirst() {
let params = ConfigurationParameters(startDate: startDate, endDate: endDate, numberOfRows: 2)
let layoutGenerator = JTAppleDateConfigGenerator()
let val = layoutGenerator.setupMonthInfoDataForStartAndEndDate(params)
assert(val.months.count == 24, "There should be 24 months")
assert(val.monthMap[71] == 23, "Last val should be 23")
assert(val.totalSections == 72, "There should be 72 sections")
}
func testLayoutGeneratorWithOffInAndOffOutFirst() {
let params = ConfigurationParameters(startDate: startDate, endDate: endDate, numberOfRows: 2, generateInDates: .off, generateOutDates: .off)
let layoutGenerator = JTAppleDateConfigGenerator()
let val = layoutGenerator.setupMonthInfoDataForStartAndEndDate(params)
assert(val.months.count == 24, "There should be 24 months")
assert(val.monthMap[70] == 23, "Last val should be 23")
assert(val.totalSections == 71, "There should be 71 sections")
}
func testConfigurationParametersDefaultBehaviorFirst() {
print("testing default parameters")
var params = ConfigurationParameters(startDate: Date(), endDate: Date())
assert(params.generateInDates == .forAllMonths, "All months should be default")
assert(params.generateOutDates == .tillEndOfGrid, "Till Grid should be default should be default")
assert(params.numberOfRows == 6, "Rows should be 6")
assert(params.firstDayOfWeek == .sunday, "First day should be sunday")
assert(params.hasStrictBoundaries == true, "strict should be true")
params = ConfigurationParameters(startDate: Date(), endDate: Date(), numberOfRows: 1)
assert(params.numberOfRows == 1, "Rows should be 1")
assert(params.hasStrictBoundaries == false, "strict should be false")
}
func testConfigurationParametersDefaultBehaviorsFirst() {
print("testing default parameters")
var params = ConfigurationParameters(startDate: Date(), endDate: Date())
assert(params.generateInDates == .forAllMonths, "All months should be default")
assert(params.generateOutDates == .tillEndOfGrid, "Till Grid should be default should be default")
assert(params.numberOfRows == 6, "Rows should be 6")
assert(params.firstDayOfWeek == .sunday, "First day should be sunday")
assert(params.hasStrictBoundaries == true, "strict should be true")
params = ConfigurationParameters(startDate: Date(), endDate: Date(), numberOfRows: 1)
assert(params.numberOfRows == 1, "Rows should be 1")
assert(params.hasStrictBoundaries == false, "strict should be false")
}
func testConfigurationParametersDefaultBehaviorssFirst() {
print("testing default parameters")
var params = ConfigurationParameters(startDate: Date(), endDate: Date())
assert(params.generateInDates == .forAllMonths, "All months should be default")
assert(params.generateOutDates == .tillEndOfGrid, "Till Grid should be default should be default")
assert(params.numberOfRows == 6, "Rows should be 6")
assert(params.firstDayOfWeek == .sunday, "First day should be sunday")
assert(params.hasStrictBoundaries == true, "strict should be true")
params = ConfigurationParameters(startDate: Date(), endDate: Date(), numberOfRows: 1)
assert(params.numberOfRows == 1, "Rows should be 1")
assert(params.hasStrictBoundaries == false, "strict should be false")
}
}

0 comments on commit 33cfae4

Please sign in to comment.