2023-02-13 18:57:31 +03:00
|
|
|
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
|
2024-02-14 13:13:25 +03:00
|
|
|
{ JI._path = JI.RelativeImportPath [SP.relfileP|../ext-src/folder/test.js|],
|
2023-02-13 18:57:31 +03:00
|
|
|
JI._name = JsImportModule "test",
|
|
|
|
JI._importAlias = Nothing
|
|
|
|
}
|