deep-linking-sample/Apps/Wikipedia/WikipediaUnitTests/Code/WMFDatabaseHousekeeperTests.swift
Javier Cicchelli 9bcdaa697b [Setup] Basic project structure (#1)
This PR contains all the work related to setting up this project as required to implement the [Assignment](https://repo.rock-n-code.com/rock-n-code/deep-linking-assignment/wiki/Assignment) on top, as intended.

To summarise this work:
- [x] created a new **Xcode** project;
- [x] cloned the `Wikipedia` app and inserted it into the **Xcode** project;
- [x] created the `Locations` app and also, its `Libraries` package;
- [x] created the `Shared` package to share dependencies between the apps;
- [x] added a `Makefile` file and implemented some **environment** and **help** commands.

Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Reviewed-on: rock-n-code/deep-linking-assignment#1
2023-04-08 18:37:13 +00:00

39 lines
1.3 KiB
Swift

import XCTest
import WMF
class WMFDatabaseHousekeeperTests: XCTestCase {
func testDaysBefore() {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy/MM/dd HH:mm ZZZ"
formatter.timeZone = TimeZone(abbreviation: "UTC")
let localFormatter = DateFormatter()
localFormatter.dateFormat = "yyyy/MM/dd HH:mm"
localFormatter.timeZone = TimeZone.current
guard let d1 = localFormatter.date(from: "2017/03/01 00:00") as NSDate? else {
XCTFail("Failure parsing date")
return
}
guard let d1_30 = d1.wmf_midnightUTCDateFromLocalDate(byAddingDays:-30) else {
XCTFail("Failure parsing date")
return
}
XCTAssertEqual("2017/01/30 00:00 +0000", formatter.string(from: d1_30))
guard let d1_1 = d1.wmf_midnightUTCDateFromLocalDate(byAddingDays:-1) else {
XCTFail("Failure parsing date")
return
}
XCTAssertEqual("2017/02/28 00:00 +0000", formatter.string(from: d1_1))
guard let d1_plus1 = d1.wmf_midnightUTCDateFromLocalDate(byAddingDays:1) else {
XCTFail("Failure parsing date")
return
}
XCTAssertEqual("2017/03/02 00:00 +0000", formatter.string(from: d1_plus1))
}
}