-
-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathImportTSTests.swift
More file actions
34 lines (31 loc) · 1.33 KB
/
Copy pathImportTSTests.swift
File metadata and controls
34 lines (31 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Testing
import Foundation
@testable import BridgeJSCore
@testable import TS2Skeleton
@Suite struct ImportTSTests {
static let inputsDirectory = URL(fileURLWithPath: #filePath).deletingLastPathComponent().appendingPathComponent(
"Inputs"
)
static func collectInputs() -> [String] {
let fileManager = FileManager.default
let inputs = try! fileManager.contentsOfDirectory(atPath: Self.inputsDirectory.path)
return inputs.filter { $0.hasSuffix(".d.ts") }
}
@Test(arguments: collectInputs())
func snapshot(input: String) throws {
var api = ImportTS(progress: .silent, moduleName: "Check")
let url = Self.inputsDirectory.appendingPathComponent(input)
let nodePath = try #require(which("node"))
let tsconfigPath = url.deletingLastPathComponent().appendingPathComponent("tsconfig.json")
try api.addSourceFile(url.path, tsconfigPath: tsconfigPath.path, nodePath: nodePath)
let outputSwift = try #require(try api.finalize())
let name = url.deletingPathExtension().deletingPathExtension().deletingPathExtension().lastPathComponent
try assertSnapshot(
name: name,
filePath: #filePath,
function: #function,
input: outputSwift.data(using: .utf8)!,
fileExtension: "swift"
)
}
}