This repository has been archived by the owner on Mar 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
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
11 changed files
with
163 additions
and
36 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
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 was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
|
||
module Cmt.Parser.ConfigTest where | ||
|
||
import ClassyPrelude | ||
|
||
import Test.Tasty | ||
import Test.Tasty.HUnit | ||
|
||
import Data.FileEmbed (embedFile) | ||
|
||
import Cmt.Parser.Config (config) | ||
import Cmt.Types.Config | ||
|
||
basic :: Text | ||
basic = decodeUtf8 $(embedFile "test/data/.cmt") | ||
|
||
basicConfig :: Config | ||
basicConfig = | ||
Config [Part "Week" Line] [Named "Week", Literal ":", Literal " ", Named "*", Literal "\n"] | ||
|
||
angular :: Text | ||
angular = decodeUtf8 $(embedFile "test/data/.cmt-angular") | ||
|
||
comments :: Text | ||
comments = decodeUtf8 $(embedFile "test/data/.cmt-comments") | ||
|
||
angularConfig :: Config | ||
angularConfig = | ||
Config | ||
[ Part "Type" (Options ["feat", "fix", "docs", "style", "refactor", "test", "chore"]) | ||
, Part "Scope" Line | ||
, Part "Short Message" Line | ||
, Part "Body" Lines | ||
] | ||
[ Named "Type" | ||
, Literal " " | ||
, Literal "(" | ||
, Named "Scope" | ||
, Literal ")" | ||
, Literal ":" | ||
, Literal " " | ||
, Named "Short Message" | ||
, Literal "\n" | ||
, Literal "\n" | ||
, Named "Body" | ||
, Literal "\n" | ||
] | ||
|
||
-- import Test.Tasty.HUnit | ||
test_config :: TestTree | ||
test_config = | ||
testGroup | ||
"Cmt.Parser.Config" | ||
[ testCase | ||
"basic" | ||
(assertEqual "Gives back correct format" (Right basicConfig) (config basic)) | ||
, testCase | ||
"angular" | ||
(assertEqual "Gives back correct format" (Right angularConfig) (config angular)) | ||
, testCase | ||
"comments" | ||
(assertEqual "Gives back correct format" (Right angularConfig) (config comments)) | ||
] |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
{-# OPTIONS_GHC -F -pgmF tasty-discover #-} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"Week" = @ | ||
} | ||
|
||
${Week}: ${*} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"Type" = [ | ||
"feat", | ||
"fix", | ||
"docs", | ||
"style", | ||
"refactor", | ||
"test", | ||
"chore" | ||
] | ||
"Scope" = @ | ||
"Short Message" = @ | ||
"Body" = !@ | ||
} | ||
|
||
${Type} (${Scope}): ${Short Message} | ||
|
||
${Body} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# The input parts | ||
# Blah blah blah | ||
# | ||
# Blah blah blah | ||
|
||
# Blah blah blah | ||
{ # A comment | ||
# A list of stuff | ||
"Type" = [ # A list of options | ||
"feat", | ||
"fix", | ||
"docs", | ||
"style", | ||
"refactor", ## A comment here too | ||
"test", | ||
"chore" | ||
] # A comment | ||
# The scope | ||
"Scope" = @ # Another comment | ||
"Short Message" = @ # All the comments all the time | ||
"Body" = !@ # So many comments! | ||
} # Another comment | ||
|
||
# Blah blah blah | ||
# Blah blah blah | ||
${Type} (${Scope}): ${Short Message} | ||
|
||
${Body} |