forked from LunarBar-app/LunarBar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HolidayManagerTests.swift
36 lines (30 loc) · 1.04 KB
/
HolidayManagerTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// HolidayManagerTests.swift
// LunarBarMacTests
//
// Created by cyan on 2023/12/29.
//
import XCTest
@testable import LunarBar
final class HolidayManagerTests: XCTestCase {
func testDataOf2024() {
let manager = HolidayManager.default
XCTAssertEqual(manager.typeOf(year: 2024, monthDay: "0101"), .holiday)
XCTAssertEqual(manager.typeOf(year: 2024, monthDay: "0204"), .workday)
}
func testUserDefinedData() {
let manager = HolidayManager.default
let directory = URL.documentsDirectory.appending(path: "Holidays", directoryHint: .isDirectory)
try? FileManager.default.createDirectory(
at: directory,
withIntermediateDirectories: false
)
try? JSONSerialization.data(withJSONObject: ["2025": ["0101": 2]]).write(
to: directory.appending(path: "custom.json", directoryHint: .notDirectory),
options: .atomic
)
manager.reloadUserDefinedFiles()
XCTAssertEqual(manager.userDefinedFiles, ["custom.json"])
XCTAssertEqual(manager.typeOf(year: 2025, monthDay: "0101"), .holiday)
}
}