File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,16 +87,17 @@ final class ExporterTests: XCTestCase {
8787 XCTAssertTrue ( colors. isEmpty)
8888 }
8989
90- func test_paletteToJSON_outputIsPrettyPrintedAndSorted( ) {
90+ func test_paletteToJSON_outputIsPrettyPrintedAndSorted( ) throws {
9191 // The implementation asks JSONSerialization for both `.prettyPrinted`
9292 // and `.sortedKeys`. Preserve that contract so CLI diffs of exported
9393 // palettes stay stable.
9494 let pair = makePair ( fg: " #ff0000 " , bg: " #00ff00 " , date: Date ( timeIntervalSince1970: 0 ) )
9595 let json = Exporter . paletteToJSON ( pairs: [ pair] , name: " Brand " )
9696 XCTAssertTrue ( json. contains ( " \n " ) , " Output should be pretty-printed across multiple lines " )
9797 // `colors` sorts alphabetically before `name` when sortedKeys is on.
98- let colorsIndex = json. range ( of: " \" colors \" " ) !. lowerBound
99- let nameIndex = json. range ( of: " \" name \" " ) !. lowerBound
100- XCTAssertLessThan ( colorsIndex, nameIndex, " Keys should be alphabetically sorted " )
98+ let colorsRange = try XCTUnwrap ( json. range ( of: " \" colors \" " ) )
99+ let nameRange = try XCTUnwrap ( json. range ( of: " \" name \" " ) )
100+ XCTAssertLessThan ( colorsRange. lowerBound, nameRange. lowerBound,
101+ " Keys should be alphabetically sorted " )
101102 }
102103}
You can’t perform that action at this time.
0 commit comments