restructure
Some checks failed
CI - Multi-Platform Native / Build iOS (RSSuper) (push) Has been cancelled
CI - Multi-Platform Native / Build macOS (push) Has been cancelled
CI - Multi-Platform Native / Build Android (push) Has been cancelled
CI - Multi-Platform Native / Build Linux (push) Has been cancelled
CI - Multi-Platform Native / Build Summary (push) Has been cancelled
Some checks failed
CI - Multi-Platform Native / Build iOS (RSSuper) (push) Has been cancelled
CI - Multi-Platform Native / Build macOS (push) Has been cancelled
CI - Multi-Platform Native / Build Android (push) Has been cancelled
CI - Multi-Platform Native / Build Linux (push) Has been cancelled
CI - Multi-Platform Native / Build Summary (push) Has been cancelled
This commit is contained in:
79
iOS/RSSuperTests/ReadingPreferencesTests.swift
Normal file
79
iOS/RSSuperTests/ReadingPreferencesTests.swift
Normal file
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// ReadingPreferencesTests.swift
|
||||
// RSSuperTests
|
||||
//
|
||||
// Created by Mike Freno on 3/29/26.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import RSSuper
|
||||
|
||||
final class ReadingPreferencesTests: XCTestCase {
|
||||
|
||||
func testReadingPreferencesEncodingDecoding() throws {
|
||||
let prefs = ReadingPreferences(
|
||||
fontSize: .large,
|
||||
lineHeight: .loose,
|
||||
showTableOfContents: true,
|
||||
showReadingTime: false,
|
||||
showAuthor: true,
|
||||
showDate: false
|
||||
)
|
||||
|
||||
let data = try JSONEncoder().encode(prefs)
|
||||
let decoded = try JSONDecoder().decode(ReadingPreferences.self, from: data)
|
||||
|
||||
XCTAssertEqual(decoded.fontSize, prefs.fontSize)
|
||||
XCTAssertEqual(decoded.lineHeight, prefs.lineHeight)
|
||||
XCTAssertEqual(decoded.showTableOfContents, prefs.showTableOfContents)
|
||||
XCTAssertEqual(decoded.showReadingTime, prefs.showReadingTime)
|
||||
XCTAssertEqual(decoded.showAuthor, prefs.showAuthor)
|
||||
XCTAssertEqual(decoded.showDate, prefs.showDate)
|
||||
}
|
||||
|
||||
func testReadingPreferencesDefaults() {
|
||||
let prefs = ReadingPreferences()
|
||||
|
||||
XCTAssertEqual(prefs.fontSize, .medium)
|
||||
XCTAssertEqual(prefs.lineHeight, .relaxed)
|
||||
XCTAssertEqual(prefs.showTableOfContents, false)
|
||||
XCTAssertEqual(prefs.showReadingTime, true)
|
||||
XCTAssertEqual(prefs.showAuthor, true)
|
||||
XCTAssertEqual(prefs.showDate, true)
|
||||
}
|
||||
|
||||
func testFontSizePointValue() {
|
||||
XCTAssertEqual(ReadingPreferences.FontSize.small.pointValue, 14)
|
||||
XCTAssertEqual(ReadingPreferences.FontSize.medium.pointValue, 16)
|
||||
XCTAssertEqual(ReadingPreferences.FontSize.large.pointValue, 18)
|
||||
XCTAssertEqual(ReadingPreferences.FontSize.xlarge.pointValue, 20)
|
||||
}
|
||||
|
||||
func testLineHeightMultiplier() {
|
||||
XCTAssertEqual(ReadingPreferences.LineHeight.normal.multiplier, 1.2)
|
||||
XCTAssertEqual(ReadingPreferences.LineHeight.relaxed.multiplier, 1.5)
|
||||
XCTAssertEqual(ReadingPreferences.LineHeight.loose.multiplier, 1.8)
|
||||
}
|
||||
|
||||
func testReadingPreferencesEquality() {
|
||||
let prefs1 = ReadingPreferences(fontSize: .large, lineHeight: .loose)
|
||||
let prefs2 = ReadingPreferences(fontSize: .large, lineHeight: .loose)
|
||||
let prefs3 = ReadingPreferences(fontSize: .medium, lineHeight: .normal)
|
||||
|
||||
XCTAssertEqual(prefs1, prefs2)
|
||||
XCTAssertNotEqual(prefs1, prefs3)
|
||||
}
|
||||
|
||||
func testReadingPreferencesDebugDescription() {
|
||||
let prefs = ReadingPreferences(
|
||||
fontSize: .xlarge,
|
||||
lineHeight: .normal,
|
||||
showTableOfContents: true
|
||||
)
|
||||
|
||||
let debugDesc = prefs.debugDescription
|
||||
XCTAssertTrue(debugDesc.contains("xlarge"))
|
||||
XCTAssertTrue(debugDesc.contains("normal"))
|
||||
XCTAssertTrue(debugDesc.contains("true"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user