@@ -1434,4 +1434,50 @@ class ExternalReferenceResolverTests: XCTestCase {
1434
1434
}
1435
1435
XCTAssertEqual ( externalLinkCount, 2 , " Did not resolve the 2 expected external links. " )
1436
1436
}
1437
+
1438
+ func testPossibleValuesWithExternalLink( ) throws {
1439
+
1440
+ // Create some example documentation using the symbol graph file located under
1441
+ // Tests/SwiftDocCTests/Test Bundles/DictionaryData.docc, and the following
1442
+ // documentation extension markup.
1443
+ let documentationExtension = TextFile (
1444
+ name: " Genre.md " ,
1445
+ utf8Content: """
1446
+ # ``DictionaryData/Genre``
1447
+
1448
+ Genre object.
1449
+
1450
+ The artist's genre.
1451
+
1452
+ - PossibleValues:
1453
+ - Classic Rock: Something about classic rock with a link: <doc://com.external.testbundle/something/related/to/this/allowed/value>.
1454
+ - Folk: Something about folk music with a link: <doc://com.external.testbundle/something/related/to/this/allowed/value>.
1455
+ """ )
1456
+ let symbol = try exampleDocumentation (
1457
+ copying: " DictionaryData " ,
1458
+ documentationExtension: documentationExtension,
1459
+ path: " /documentation/DictionaryData/Genre "
1460
+ )
1461
+
1462
+ let section = try XCTUnwrap ( symbol. possibleValuesSectionVariants. firstValue)
1463
+ XCTAssertEqual ( section. possibleValues. count, 3 )
1464
+
1465
+ // Check that the two keys with external links in the markup above were found
1466
+ // and processed by the test external reference resolver.
1467
+ var externalLinkCount = 0
1468
+ for possibleValue in section. possibleValues {
1469
+ let value = possibleValue. contents. first? . format ( ) . trimmingCharacters ( in: . whitespaces)
1470
+ if possibleValue. value == " Classic Rock " {
1471
+ let stringValue = try XCTUnwrap ( value)
1472
+ XCTAssertEqual ( stringValue, " Something about classic rock with a link: <doc://com.external.testbundle/externally/resolved/path>. " )
1473
+ externalLinkCount += 1
1474
+ } else if possibleValue. value == " Folk " {
1475
+ let stringValue = try XCTUnwrap ( value)
1476
+ XCTAssertEqual ( stringValue, " Something about folk music with a link: <doc://com.external.testbundle/externally/resolved/path>. " )
1477
+ externalLinkCount += 1
1478
+ }
1479
+ }
1480
+ XCTAssertEqual ( externalLinkCount, 2 , " Did not resolve the 2 expected external links. " )
1481
+ }
1482
+
1437
1483
}
0 commit comments