Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ target/
.settings/
/node_modules
/package-lock.json
/DefinitelyTyped
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.scalajs.tools.tsimporter

import java.io.File

import org.scalatest.FunSpec

class DefinitelyTypedImportSpec extends FunSpec {

val typesDir = new File("DefinitelyTyped/types")

describe("DefinitelyTyped") {
it("should be present into the root of the directory") {
assert(typesDir.exists(), "DefinitelyTyped not present. Please clone https://github.com/DefinitelyTyped/DefinitelyTyped")
}
}

describe("scala-js-ts-importer") {

case class DTProject(name: String, file: File)

val dtProjects = Option(typesDir.listFiles())
.getOrElse(Array.empty)
.filter(_.isDirectory)
.map(dir => DTProject(dir.getName, dir.toPath.resolve("index.d.ts").toFile))
.filter(_.file.isFile)

val tempOutputFile = File.createTempFile("scala-js-ts-importer-test-", ".scala")
tempOutputFile.deleteOnExit()
val tempOutputFileName = tempOutputFile.getAbsolutePath

for (DTProject(name, file) <- dtProjects) it(s"should import '$name'") {
val fileName = file.getCanonicalPath
Main.importTsFile(fileName, tempOutputFileName, "test") match {
case Left(errorMessage) =>
fail(s"failed importing $fileName: $errorMessage")
case Right(()) =>
}
}
}
}
3 changes: 3 additions & 0 deletions update_definitelyTyped.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/sh
rm -rf DefinitelyTyped
git clone --depth=1 https://github.com/DefinitelyTyped/DefinitelyTyped