Download this file
| 1 | import Foundation |
| 2 | import XCTest |
| 3 | @testable import DocsKit |
| 4 | |
| 5 | /// Every heading the style menu offers has a translation in every language |
| 6 | /// Docs ships, under the exact key the menu looks up. |
| 7 | final class EditorToolbarStringsTests: XCTestCase { |
| 8 | func testEveryHeadingKeyResolvesInEveryLanguage() throws { |
| 9 | let languages = DocsResources.bundle.localizations.filter { $0 != "Base" } |
| 10 | XCTAssertFalse(languages.isEmpty) |
| 11 | for language in languages { |
| 12 | let path = try XCTUnwrap(DocsResources.bundle.path(forResource: language, ofType: "lproj"), language) |
| 13 | let bundle = try XCTUnwrap(Bundle(path: path), language) |
| 14 | for level in 1...3 { |
| 15 | let key = EditorToolbar.headingKey(level) |
| 16 | let value = bundle.localizedString(forKey: key, value: nil, table: nil) |
| 17 | XCTAssertNotEqual(value, key, "\(language): \(key) has no translation") |
| 18 | XCTAssertFalse(value.contains("%"), "\(language): \(key) is a format, not a label") |
| 19 | } |
| 20 | } |
| 21 | } |
| 22 | } |
| 23 | |