mirror of
https://github.com/github/semantic.git
synced 2024-12-29 09:55:52 +03:00
Fix DiffSummary tests
now that parentAnnotations are Categories
This commit is contained in:
parent
9dfd271186
commit
c229d43934
@ -1,7 +1,6 @@
|
||||
module DiffSummarySpec where
|
||||
|
||||
import Prologue
|
||||
import Data.String
|
||||
import Test.Hspec
|
||||
import Diff
|
||||
import Info
|
||||
@ -17,22 +16,22 @@ arrayInfo = Info (rangeAt 0) ArrayLiteral 2 0
|
||||
literalInfo :: Info
|
||||
literalInfo = Info (rangeAt 1) StringLiteral 1 0
|
||||
|
||||
testDiff :: Diff String Info
|
||||
testDiff :: Diff Text Info
|
||||
testDiff = free $ Free (pure arrayInfo :< Indexed [ free $ Pure (Insert (cofree $ literalInfo :< Leaf "a")) ])
|
||||
|
||||
testSummary :: DiffSummary DiffInfo
|
||||
testSummary = DiffSummary { patch = Insert (DiffInfo "string" (Just "a")), parentAnnotations = [] }
|
||||
testSummary = DiffSummary { patch = Insert (DiffInfo "string" "a"), parentAnnotations = [] }
|
||||
|
||||
replacementSummary :: DiffSummary DiffInfo
|
||||
replacementSummary = DiffSummary { patch = Replace (DiffInfo "string" (Just "a")) (DiffInfo "symbol" (Just "b")), parentAnnotations = [ (DiffInfo "array" (Just "switch {}")) ] }
|
||||
replacementSummary = DiffSummary { patch = Replace (DiffInfo "string" "a") (DiffInfo "symbol" "b"), parentAnnotations = [ ArrayLiteral ] }
|
||||
|
||||
spec :: Spec
|
||||
spec = parallel $ do
|
||||
describe "diffSummary" $ do
|
||||
it "outputs a diff summary" $ do
|
||||
diffSummary testDiff `shouldBe` [ DiffSummary { patch = Insert (DiffInfo "string" (Just "a")), parentAnnotations = [ DiffInfo "array" Nothing ] } ]
|
||||
diffSummary testDiff `shouldBe` [ DiffSummary { patch = Insert (DiffInfo "string" "a"), parentAnnotations = [ ArrayLiteral ] } ]
|
||||
describe "show" $ do
|
||||
it "should print adds" $
|
||||
show testSummary `shouldBe` ("Added the 'a' string" :: String)
|
||||
show testSummary `shouldBe` ("Added the 'a' string" :: Text)
|
||||
it "prints a replacement" $ do
|
||||
show replacementSummary `shouldBe` ("Replaced the 'a' string with the 'b' symbol in the array context" :: String)
|
||||
show replacementSummary `shouldBe` ("Replaced the 'a' string with the 'b' symbol in the array context" :: Text)
|
||||
|
Loading…
Reference in New Issue
Block a user