Skip to content

Commit a493f69

Browse files
add test to ensure that highlights don't happen when overloads are disabled
1 parent 396d5c6 commit a493f69

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Tests/SwiftDocCTests/Rendering/DeclarationsRenderSectionTests.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,42 @@ class DeclarationsRenderSectionTests: XCTestCase {
224224
],
225225
])
226226
}
227+
228+
func testDontHighlightWhenOverloadsAreDisabled() throws {
229+
let symbolGraphFile = Bundle.module.url(
230+
forResource: "FancyOverloads",
231+
withExtension: "symbols.json",
232+
subdirectory: "Test Resources"
233+
)!
234+
235+
let tempURL = try createTempFolder(content: [
236+
Folder(name: "unit-test.docc", content: [
237+
InfoPlist(displayName: "FancyOverloads", identifier: "com.test.example"),
238+
CopyOfFile(original: symbolGraphFile),
239+
])
240+
])
241+
242+
let (_, bundle, context) = try loadBundle(from: tempURL)
243+
244+
for hash in ["1dd3k", "4alrf"] {
245+
let reference = ResolvedTopicReference(
246+
bundleIdentifier: bundle.identifier,
247+
path: "/documentation/FancyOverloads/MyClass/myFunc(param:)-\(hash)",
248+
sourceLanguage: .swift
249+
)
250+
let symbol = try XCTUnwrap(context.entity(with: reference).semantic as? Symbol)
251+
var translator = RenderNodeTranslator(
252+
context: context,
253+
bundle: bundle,
254+
identifier: reference,
255+
source: nil
256+
)
257+
let renderNode = try XCTUnwrap(translator.visitSymbol(symbol) as? RenderNode)
258+
let declarationsSection = try XCTUnwrap(renderNode.primaryContentSections.compactMap({ $0 as? DeclarationsRenderSection }).first)
259+
XCTAssertEqual(declarationsSection.declarations.count, 1)
260+
let declarations = try XCTUnwrap(declarationsSection.declarations.first)
261+
262+
XCTAssert(declarations.tokens.allSatisfy({ $0.highlight == nil }))
263+
}
264+
}
227265
}

0 commit comments

Comments
 (0)