-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,38 @@ | ||
{-# LANGUAGE PartialTypeSignatures #-} | ||
{-# LANGUAGE OverloadedLists, PartialTypeSignatures #-} | ||
module Nirum.Targets.JavaScriptSpec ( spec ) where | ||
|
||
import qualified Data.Map.Strict as M | ||
import qualified Data.SemVer as SV | ||
import Text.Toml.Types ( emptyTable ) | ||
import Test.Hspec.Meta | ||
|
||
import qualified Nirum.Constructs.DeclarationSet as DS | ||
import Nirum.Constructs.Module ( Module (..) ) | ||
import Nirum.Targets.JavaScript | ||
import Nirum.Package.Metadata ( MetadataError ( FieldError ) | ||
import Nirum.Package.Metadata ( Metadata (..) | ||
, MetadataError ( FieldError ) | ||
, Package (..) | ||
, parseTarget ) | ||
import qualified Nirum.Package.ModuleSet as MS | ||
|
||
|
||
emptyModule :: Module | ||
emptyModule = Module { types = DS.empty, docs = Nothing } | ||
|
||
|
||
spec :: Spec | ||
spec = | ||
spec = do | ||
describe "compilePackage'" $ | ||
it "should produce JavaScript files per corresponding module" $ do | ||
let Right modules' = MS.fromList [(["fruits"], emptyModule)] | ||
let package = Package { metadata = Metadata { version = SV.version 0 0 1 [] [] | ||
, authors = [] | ||
, target = JavaScript { packageName = "dummy" } | ||
} | ||
, modules = modules' | ||
} | ||
let m = compilePackage' package | ||
M.keysSet m `shouldBe` ["package.json", "src/fruits.js"] | ||
describe "parseTarget" $ | ||
it "should require \"name\" field" $ | ||
(parseTarget emptyTable :: Either MetadataError JavaScript) `shouldBe` Left (FieldError "name") |