Skip to content

Commit 132e668

Browse files
author
Jesse Haigh
committed
add unit test for copyToClipboard
1 parent b0a87b0 commit 132e668

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,26 @@ class RenderContentCompilerTests: XCTestCase {
223223
XCTAssertEqual(documentThematicBreak, thematicBreak)
224224
}
225225
}
226+
227+
func testCopyToClipboard() throws {
228+
let (bundle, context) = try testBundleAndContext()
229+
var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift))
230+
231+
let source = #"""
232+
```swift, copy
233+
let x = 1
234+
```
235+
"""#
236+
let document = Document(parsing: source)
237+
238+
let result = document.children.flatMap { compiler.visit($0) }
239+
240+
let renderCodeBlock = try XCTUnwrap(result[0] as? RenderBlockContent)
241+
guard case let .codeListing(codeListing) = renderCodeBlock else {
242+
XCTFail("Expected RenderBlockContent.codeListing")
243+
return
244+
}
245+
246+
XCTAssertEqual(codeListing.copyToClipboard, true)
247+
}
226248
}

0 commit comments

Comments
 (0)