wasp/waspc/test/Generator/JsImportTest.hs
2024-02-14 11:13:25 +01:00

29 lines
1.1 KiB
Haskell

module Generator.JsImportTest where
import StrongPath (Dir, Path, Posix, Rel)
import qualified StrongPath as SP
import Test.Tasty.Hspec
import Wasp.AppSpec.ExtImport
import Wasp.Generator.ExternalCodeGenerator.Common (GeneratedExternalCodeDir)
import Wasp.Generator.JsImport
import Wasp.Generator.ServerGenerator.Common (ServerSrcDir)
import Wasp.JsImport as JI
spec_GeneratorJsImportTest :: Spec
spec_GeneratorJsImportTest = do
describe "extImportToJsImport" $ do
let pathToExtCodeDir = [SP.reldirP|ext-src|] :: (Path Posix (Rel ServerSrcDir) (Dir GeneratedExternalCodeDir))
pathFromImportLocationToExtCodeDir = [SP.reldirP|../|]
extImport =
ExtImport
{ name = ExtImportModule "test",
path = [SP.relfileP|folder/test.js|]
}
it "makes a JsImport from ExtImport" $ do
extImportToJsImport pathToExtCodeDir pathFromImportLocationToExtCodeDir extImport
`shouldBe` JI.JsImport
{ JI._path = JI.RelativeImportPath [SP.relfileP|../ext-src/folder/test.js|],
JI._name = JsImportModule "test",
JI._importAlias = Nothing
}