Skip to content

added spec to test all DefinitelyTyped packages #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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