1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 14:54:16 +03:00
semantic/test/Rendering/Imports/Spec.hs

38 lines
1.5 KiB
Haskell
Raw Normal View History

module Rendering.Imports.Spec (spec) where
2018-03-13 20:32:25 +03:00
import Analysis.Declaration (declarationAlgebra)
2018-03-26 22:49:52 +03:00
import Analysis.PackageDef (packageDefAlgebra)
import Rendering.Imports
2018-03-13 20:59:06 +03:00
import SpecHelpers
spec :: Spec
spec = parallel $ do
describe "renderToImports" $ do
2018-03-09 00:02:39 +03:00
it "works for Ruby" $ do
output <- parseToImports rubyParser "test/fixtures/ruby/import-graph/app.rb"
expected <- readFileVerbatim "test/fixtures/ruby/import-graph/app.json"
toVerbatimOutput output `shouldBe` expected
it "works for Python" $ do
output <- parseToImports pythonParser "test/fixtures/python/import-graph/main.py"
expected <- readFileVerbatim "test/fixtures/python/import-graph/main.json"
toVerbatimOutput output `shouldBe` expected
2018-03-09 00:01:13 +03:00
it "works for Go" $ do
output <- parseToImports goParser "test/fixtures/go/import-graph/main.go"
expected <- readFileVerbatim "test/fixtures/go/import-graph/main.json"
toVerbatimOutput output `shouldBe` expected
it "works for TypeScript" $ do
output <- parseToImports typescriptParser "test/fixtures/typescript/import-graph/app.ts"
expected <- readFileVerbatim "test/fixtures/typescript/import-graph/app.json"
toVerbatimOutput output `shouldBe` expected
where
toVerbatimOutput = verbatim . toOutput
parseToImports parser path = do
2018-03-13 20:32:25 +03:00
blob <- file path
2018-03-26 22:49:52 +03:00
runTask (parse parser blob >>= decorate (declarationAlgebra blob) >>= decorate (packageDefAlgebra blob) >>= render (renderToImports blob))