import XCTest @testable import AIMenubarUsage final class ClaudeProviderTests: XCTestCase { func testDecodeOAuthUsageFixture() throws { let data = try loadFixture(named: "claude-oauth-usage") let usage = try JSONDecoder().decode(ClaudeOAuthUsageResponse.self, from: data) XCTAssertEqual(usage.fiveHour?.utilization ?? 0, 0.42, accuracy: 0.001) XCTAssertEqual(usage.sevenDay?.utilization ?? 0, 0.15, accuracy: 0.001) } func testSnapshotMapping() throws { let data = try loadFixture(named: "claude-oauth-usage") let usage = try JSONDecoder().decode(ClaudeOAuthUsageResponse.self, from: data) let snapshot = ClaudeAPI.snapshot(from: usage, fetchedAt: Date(), isStale: false) XCTAssertEqual(snapshot.providerID, .claude) XCTAssertEqual(snapshot.formatted(.claudeFiveHourUtilization), "42%") XCTAssertEqual(snapshot.formatted(.claudeSevenDayUtilization), "15%") } private func loadFixture(named name: String) throws -> Data { let url = URL(fileURLWithPath: #filePath) .deletingLastPathComponent() .appendingPathComponent("Fixtures") .appendingPathComponent("\(name).json") return try Data(contentsOf: url) } }