import Testing @testable import HUDKit // A gallery photo's own info, as the server resolved it: its lines, those // with words, in order; none where it has none. And its two badges' words // shown one at a time. @Suite struct PhotoInfo { @Test func eachPhotoKeepsItsOwnLines() { let first: JSON = ["src": .null, "info": [["text": "Fujifilm X100V"], ["text": "35mm · ƒ/2 · ISO 400"]]] let second: JSON = ["src": .null, "info": [["text": "Leica M6"], ["text": ""], ["x": 1]]] #expect(PhotoBadges.lines(first) == ["Fujifilm X100V", "35mm · ƒ/2 · ISO 400"]) #expect(PhotoBadges.lines(second) == ["Leica M6"]) #expect(PhotoBadges.lines(["src": .null]).isEmpty) } @Test func openingOneBadgeClosesTheOther() { #expect(PhotoBadges.toggled(nil, .alt) == .alt) #expect(PhotoBadges.toggled(.alt, .info) == .info) #expect(PhotoBadges.toggled(.info, .alt) == .alt) #expect(PhotoBadges.toggled(.info, .info) == nil) } }