mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
simplify types, make changed char have new format
This commit is contained in:
+287
-418
@@ -5,7 +5,6 @@
|
||||
module MarkdownDiffTests where
|
||||
|
||||
import qualified Data.List.NonEmpty as NE
|
||||
import qualified Data.Sequence as S
|
||||
import Simplex.Chat.Markdown
|
||||
import Simplex.Chat.MarkdownDiff
|
||||
import System.Console.ANSI.Types
|
||||
@@ -17,449 +16,319 @@ markdownDiffTests = do
|
||||
|
||||
formattedEditedTextTests :: Spec
|
||||
formattedEditedTextTests = describe "show edits" do
|
||||
it "empty no change" do
|
||||
diff
|
||||
( LeftSide $
|
||||
S.fromList
|
||||
[]
|
||||
)
|
||||
( RightSide $
|
||||
S.fromList
|
||||
[]
|
||||
)
|
||||
`shouldBe` S.fromList
|
||||
[]
|
||||
|
||||
it "no change" do
|
||||
diff
|
||||
( LeftSide $
|
||||
S.fromList
|
||||
[ FormatChar 'H' Nothing
|
||||
]
|
||||
)
|
||||
( RightSide $
|
||||
S.fromList
|
||||
[ FormatChar 'H' Nothing
|
||||
]
|
||||
)
|
||||
`shouldBe` S.fromList
|
||||
[ DiffChar (FormatChar 'H' Nothing) $ UnchangedChar UnchangedFormat
|
||||
]
|
||||
|
||||
it "add 1 char to empty" do
|
||||
diff
|
||||
( LeftSide $
|
||||
S.fromList
|
||||
[]
|
||||
)
|
||||
( RightSide $
|
||||
S.fromList
|
||||
[ FormatChar 'H' Nothing
|
||||
]
|
||||
)
|
||||
`shouldBe` S.fromList
|
||||
[ DiffChar (FormatChar 'H' Nothing) Inserted
|
||||
]
|
||||
|
||||
it "del the one and only" do
|
||||
diff
|
||||
( LeftSide $
|
||||
S.fromList
|
||||
[ FormatChar 'H' Nothing
|
||||
]
|
||||
)
|
||||
( RightSide $
|
||||
S.fromList
|
||||
[]
|
||||
)
|
||||
`shouldBe` S.fromList
|
||||
[ DiffChar (FormatChar 'H' Nothing) Deleted
|
||||
]
|
||||
|
||||
it "empty no change" $
|
||||
diff [] [] `shouldBe` []
|
||||
it "no change" $
|
||||
diff [FormatChar 'H' Nothing] [FormatChar 'H' Nothing]
|
||||
`shouldBe` [DiffChar (FormatChar 'H' Nothing) Nothing]
|
||||
it "add 1 char to empty" $
|
||||
diff [] [FormatChar 'H' Nothing]
|
||||
`shouldBe` [DiffChar (FormatChar 'H' Nothing) $ Just EAInsert]
|
||||
it "del the one and only" $
|
||||
diff [FormatChar 'H' Nothing] []
|
||||
`shouldBe` [DiffChar (FormatChar 'H' Nothing) $ Just EADelete]
|
||||
it "one character change" do
|
||||
diff
|
||||
( LeftSide $
|
||||
S.fromList
|
||||
[ FormatChar 'H' Nothing,
|
||||
FormatChar 'r' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'o' Nothing
|
||||
]
|
||||
)
|
||||
( RightSide $
|
||||
S.fromList
|
||||
[ FormatChar 'H' Nothing,
|
||||
FormatChar 'e' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'o' Nothing
|
||||
]
|
||||
)
|
||||
`shouldBe` S.fromList
|
||||
[ DiffChar (FormatChar 'H' Nothing) $ UnchangedChar UnchangedFormat,
|
||||
DiffChar (FormatChar 'r' Nothing) Deleted,
|
||||
DiffChar (FormatChar 'e' Nothing) Inserted,
|
||||
DiffChar (FormatChar 'l' Nothing) $ UnchangedChar UnchangedFormat,
|
||||
DiffChar (FormatChar 'l' Nothing) $ UnchangedChar UnchangedFormat,
|
||||
DiffChar (FormatChar 'o' Nothing) $ UnchangedChar UnchangedFormat
|
||||
]
|
||||
[ FormatChar 'H' Nothing,
|
||||
FormatChar 'r' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'o' Nothing
|
||||
]
|
||||
[ FormatChar 'H' Nothing,
|
||||
FormatChar 'e' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'o' Nothing
|
||||
]
|
||||
`shouldBe` [ DiffChar (FormatChar 'H' Nothing) Nothing,
|
||||
DiffChar (FormatChar 'r' Nothing) $ Just EADelete,
|
||||
DiffChar (FormatChar 'e' Nothing) $ Just EAInsert,
|
||||
DiffChar (FormatChar 'l' Nothing) Nothing,
|
||||
DiffChar (FormatChar 'l' Nothing) Nothing,
|
||||
DiffChar (FormatChar 'o' Nothing) Nothing
|
||||
]
|
||||
|
||||
it "more1" do
|
||||
diff
|
||||
( LeftSide $
|
||||
S.fromList
|
||||
[ FormatChar 'H' Nothing,
|
||||
FormatChar 'r' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'o' Nothing
|
||||
]
|
||||
)
|
||||
( RightSide $
|
||||
S.fromList
|
||||
[ FormatChar 'H' Nothing,
|
||||
FormatChar 'e' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'o' Nothing,
|
||||
FormatChar 'x' Nothing,
|
||||
FormatChar 'y' Nothing,
|
||||
FormatChar 'z' Nothing
|
||||
]
|
||||
)
|
||||
`shouldBe` S.fromList
|
||||
[ DiffChar (FormatChar 'H' Nothing) $ UnchangedChar UnchangedFormat,
|
||||
DiffChar (FormatChar 'r' Nothing) Deleted,
|
||||
DiffChar (FormatChar 'e' Nothing) Inserted,
|
||||
DiffChar (FormatChar 'l' Nothing) $ UnchangedChar UnchangedFormat,
|
||||
DiffChar (FormatChar 'l' Nothing) $ UnchangedChar UnchangedFormat,
|
||||
DiffChar (FormatChar 'o' Nothing) $ UnchangedChar UnchangedFormat,
|
||||
DiffChar (FormatChar 'x' Nothing) Inserted,
|
||||
DiffChar (FormatChar 'y' Nothing) Inserted,
|
||||
DiffChar (FormatChar 'z' Nothing) Inserted
|
||||
]
|
||||
[ FormatChar 'H' Nothing,
|
||||
FormatChar 'r' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'o' Nothing
|
||||
]
|
||||
[ FormatChar 'H' Nothing,
|
||||
FormatChar 'e' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'o' Nothing,
|
||||
FormatChar 'x' Nothing,
|
||||
FormatChar 'y' Nothing,
|
||||
FormatChar 'z' Nothing
|
||||
]
|
||||
`shouldBe` [ DiffChar (FormatChar 'H' Nothing) Nothing,
|
||||
DiffChar (FormatChar 'r' Nothing) $ Just EADelete,
|
||||
DiffChar (FormatChar 'e' Nothing) $ Just EAInsert,
|
||||
DiffChar (FormatChar 'l' Nothing) Nothing,
|
||||
DiffChar (FormatChar 'l' Nothing) Nothing,
|
||||
DiffChar (FormatChar 'o' Nothing) Nothing,
|
||||
DiffChar (FormatChar 'x' Nothing) $ Just EAInsert,
|
||||
DiffChar (FormatChar 'y' Nothing) $ Just EAInsert,
|
||||
DiffChar (FormatChar 'z' Nothing) $ Just EAInsert
|
||||
]
|
||||
|
||||
it "more2" do
|
||||
diff
|
||||
( LeftSide $
|
||||
S.fromList
|
||||
[ FormatChar 'H' Nothing,
|
||||
FormatChar 'r' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'o' Nothing
|
||||
]
|
||||
)
|
||||
( RightSide $
|
||||
S.fromList
|
||||
[ FormatChar 'H' Nothing,
|
||||
FormatChar 'e' Nothing,
|
||||
FormatChar 'x' Nothing,
|
||||
FormatChar 'y' Nothing,
|
||||
FormatChar 'z' Nothing,
|
||||
FormatChar 'o' Nothing
|
||||
]
|
||||
)
|
||||
`shouldBe` S.fromList
|
||||
[ DiffChar (FormatChar 'H' Nothing) $ UnchangedChar UnchangedFormat,
|
||||
DiffChar (FormatChar 'r' Nothing) Deleted,
|
||||
DiffChar (FormatChar 'l' Nothing) Deleted,
|
||||
DiffChar (FormatChar 'l' Nothing) Deleted,
|
||||
DiffChar (FormatChar 'e' Nothing) Inserted,
|
||||
DiffChar (FormatChar 'x' Nothing) Inserted,
|
||||
DiffChar (FormatChar 'y' Nothing) Inserted,
|
||||
DiffChar (FormatChar 'z' Nothing) Inserted,
|
||||
DiffChar (FormatChar 'o' Nothing) $ UnchangedChar UnchangedFormat
|
||||
]
|
||||
[ FormatChar 'H' Nothing,
|
||||
FormatChar 'r' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'o' Nothing
|
||||
]
|
||||
[ FormatChar 'H' Nothing,
|
||||
FormatChar 'e' Nothing,
|
||||
FormatChar 'x' Nothing,
|
||||
FormatChar 'y' Nothing,
|
||||
FormatChar 'z' Nothing,
|
||||
FormatChar 'o' Nothing
|
||||
]
|
||||
`shouldBe` [ DiffChar (FormatChar 'H' Nothing) Nothing,
|
||||
DiffChar (FormatChar 'r' Nothing) $ Just EADelete,
|
||||
DiffChar (FormatChar 'l' Nothing) $ Just EADelete,
|
||||
DiffChar (FormatChar 'l' Nothing) $ Just EADelete,
|
||||
DiffChar (FormatChar 'e' Nothing) $ Just EAInsert,
|
||||
DiffChar (FormatChar 'x' Nothing) $ Just EAInsert,
|
||||
DiffChar (FormatChar 'y' Nothing) $ Just EAInsert,
|
||||
DiffChar (FormatChar 'z' Nothing) $ Just EAInsert,
|
||||
DiffChar (FormatChar 'o' Nothing) Nothing
|
||||
]
|
||||
|
||||
it "more3" do
|
||||
diff
|
||||
( LeftSide $
|
||||
S.fromList
|
||||
[ FormatChar 'H' $ Just Bold,
|
||||
FormatChar 'H' $ Just Bold,
|
||||
FormatChar 'r' Nothing,
|
||||
FormatChar 'l' $ Just Secret,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'o' $ Just $ colored Green
|
||||
]
|
||||
)
|
||||
( RightSide $
|
||||
S.fromList
|
||||
[ FormatChar 'H' $ Just Italic,
|
||||
FormatChar 'H' $ Just Bold,
|
||||
FormatChar 'e' $ Just $ colored Cyan,
|
||||
FormatChar 'x' Nothing,
|
||||
FormatChar 'y' Nothing,
|
||||
FormatChar 'z' $ Just Secret,
|
||||
FormatChar 'o' $ Just $ colored Blue
|
||||
]
|
||||
)
|
||||
`shouldBe` S.fromList
|
||||
[ DiffChar (FormatChar 'H' (Just Bold)) $ UnchangedChar $ ChangedToFormat $ Just Italic,
|
||||
DiffChar (FormatChar 'H' (Just Bold)) $ UnchangedChar UnchangedFormat,
|
||||
DiffChar (FormatChar 'r' Nothing) Deleted,
|
||||
DiffChar (FormatChar 'l' (Just Secret)) Deleted,
|
||||
DiffChar (FormatChar 'l' Nothing) Deleted,
|
||||
DiffChar (FormatChar 'e' (Just $ colored Cyan)) Inserted,
|
||||
DiffChar (FormatChar 'x' Nothing) Inserted,
|
||||
DiffChar (FormatChar 'y' Nothing) Inserted,
|
||||
DiffChar (FormatChar 'z' (Just Secret)) Inserted,
|
||||
DiffChar (FormatChar 'o' (Just $ colored Green)) $ UnchangedChar $ ChangedToFormat $ Just $ colored Blue
|
||||
]
|
||||
[ FormatChar 'H' $ Just Bold,
|
||||
FormatChar 'H' $ Just Bold,
|
||||
FormatChar 'r' Nothing,
|
||||
FormatChar 'l' $ Just Secret,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'o' $ Just $ colored Green
|
||||
]
|
||||
[ FormatChar 'H' $ Just Italic,
|
||||
FormatChar 'H' $ Just Bold,
|
||||
FormatChar 'e' $ Just $ colored Cyan,
|
||||
FormatChar 'x' Nothing,
|
||||
FormatChar 'y' Nothing,
|
||||
FormatChar 'z' $ Just Secret,
|
||||
FormatChar 'o' $ Just $ colored Blue
|
||||
]
|
||||
`shouldBe` [ DiffChar (FormatChar 'H' (Just Italic)) (Just EAChangeFormat),
|
||||
DiffChar (FormatChar 'H' (Just Bold)) Nothing,
|
||||
DiffChar (FormatChar 'r' Nothing) $ Just EADelete,
|
||||
DiffChar (FormatChar 'l' (Just Secret)) $ Just EADelete,
|
||||
DiffChar (FormatChar 'l' Nothing) $ Just EADelete,
|
||||
DiffChar (FormatChar 'e' (Just $ colored Cyan)) $ Just EAInsert,
|
||||
DiffChar (FormatChar 'x' Nothing) $ Just EAInsert,
|
||||
DiffChar (FormatChar 'y' Nothing) $ Just EAInsert,
|
||||
DiffChar (FormatChar 'z' (Just Secret)) $ Just EAInsert,
|
||||
DiffChar (FormatChar 'o' (Just $ colored Blue)) (Just EAChangeFormat)
|
||||
]
|
||||
|
||||
it "more4" do
|
||||
diff
|
||||
( LeftSide $
|
||||
S.fromList
|
||||
[ FormatChar 'H' Nothing,
|
||||
FormatChar 'r' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar '~' Nothing,
|
||||
FormatChar '!' Nothing,
|
||||
FormatChar '@' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'o' Nothing
|
||||
]
|
||||
)
|
||||
( RightSide $
|
||||
S.fromList
|
||||
[ FormatChar 'H' Nothing,
|
||||
FormatChar 'e' Nothing,
|
||||
FormatChar 'r' Nothing,
|
||||
FormatChar 'x' Nothing,
|
||||
FormatChar 'y' Nothing,
|
||||
FormatChar '!' Nothing,
|
||||
FormatChar '@' Nothing,
|
||||
FormatChar 'z' Nothing,
|
||||
FormatChar 'o' Nothing,
|
||||
FormatChar '1' Nothing,
|
||||
FormatChar '2' Nothing
|
||||
]
|
||||
)
|
||||
`shouldBe` S.fromList
|
||||
[ DiffChar (FormatChar 'H' Nothing) $ UnchangedChar UnchangedFormat,
|
||||
DiffChar (FormatChar 'e' Nothing) Inserted,
|
||||
DiffChar (FormatChar 'r' Nothing) $ UnchangedChar UnchangedFormat,
|
||||
DiffChar (FormatChar 'l' Nothing) Deleted,
|
||||
DiffChar (FormatChar '~' Nothing) Deleted,
|
||||
DiffChar (FormatChar 'x' Nothing) Inserted,
|
||||
DiffChar (FormatChar 'y' Nothing) Inserted,
|
||||
DiffChar (FormatChar '!' Nothing) $ UnchangedChar UnchangedFormat,
|
||||
DiffChar (FormatChar '@' Nothing) $ UnchangedChar UnchangedFormat,
|
||||
DiffChar (FormatChar 'l' Nothing) Deleted,
|
||||
DiffChar (FormatChar 'z' Nothing) Inserted,
|
||||
DiffChar (FormatChar 'o' Nothing) $ UnchangedChar UnchangedFormat,
|
||||
DiffChar (FormatChar '1' Nothing) Inserted,
|
||||
DiffChar (FormatChar '2' Nothing) Inserted
|
||||
]
|
||||
[ FormatChar 'H' Nothing,
|
||||
FormatChar 'r' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar '~' Nothing,
|
||||
FormatChar '!' Nothing,
|
||||
FormatChar '@' Nothing,
|
||||
FormatChar 'l' Nothing,
|
||||
FormatChar 'o' Nothing
|
||||
]
|
||||
[ FormatChar 'H' Nothing,
|
||||
FormatChar 'e' Nothing,
|
||||
FormatChar 'r' Nothing,
|
||||
FormatChar 'x' Nothing,
|
||||
FormatChar 'y' Nothing,
|
||||
FormatChar '!' Nothing,
|
||||
FormatChar '@' Nothing,
|
||||
FormatChar 'z' Nothing,
|
||||
FormatChar 'o' Nothing,
|
||||
FormatChar '1' Nothing,
|
||||
FormatChar '2' Nothing
|
||||
]
|
||||
`shouldBe` [ DiffChar (FormatChar 'H' Nothing) Nothing,
|
||||
DiffChar (FormatChar 'e' Nothing) $ Just EAInsert,
|
||||
DiffChar (FormatChar 'r' Nothing) Nothing,
|
||||
DiffChar (FormatChar 'l' Nothing) $ Just EADelete,
|
||||
DiffChar (FormatChar '~' Nothing) $ Just EADelete,
|
||||
DiffChar (FormatChar 'x' Nothing) $ Just EAInsert,
|
||||
DiffChar (FormatChar 'y' Nothing) $ Just EAInsert,
|
||||
DiffChar (FormatChar '!' Nothing) Nothing,
|
||||
DiffChar (FormatChar '@' Nothing) Nothing,
|
||||
DiffChar (FormatChar 'l' Nothing) $ Just EADelete,
|
||||
DiffChar (FormatChar 'z' Nothing) $ Just EAInsert,
|
||||
DiffChar (FormatChar 'o' Nothing) Nothing,
|
||||
DiffChar (FormatChar '1' Nothing) $ Just EAInsert,
|
||||
DiffChar (FormatChar '2' Nothing) $ Just EAInsert
|
||||
]
|
||||
|
||||
it "SimplexLink 1" do
|
||||
diff
|
||||
( LeftSide $
|
||||
S.fromList
|
||||
[ FormatChar '>' $
|
||||
Just $
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/2/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host1", "host2", "host3"]
|
||||
}
|
||||
]
|
||||
)
|
||||
( RightSide $
|
||||
S.fromList
|
||||
[ FormatChar '>' $
|
||||
Just
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/3/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host0", "host2", "host3"]
|
||||
}
|
||||
]
|
||||
)
|
||||
`shouldBe` S.fromList
|
||||
[ DiffChar
|
||||
( FormatChar '>' $
|
||||
Just
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/2/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host1", "host2", "host3"]
|
||||
}
|
||||
)
|
||||
$ UnchangedChar
|
||||
$ ChangedToFormat
|
||||
$ Just
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/3/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host0", "host2", "host3"]
|
||||
}
|
||||
]
|
||||
[ FormatChar '>' $
|
||||
Just $
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/2/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host1", "host2", "host3"]
|
||||
}
|
||||
]
|
||||
[ FormatChar '>' $
|
||||
Just
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/3/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host0", "host2", "host3"]
|
||||
}
|
||||
]
|
||||
`shouldBe` [ DiffChar
|
||||
( FormatChar '>' $
|
||||
Just
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/3/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host0", "host2", "host3"]
|
||||
}
|
||||
)
|
||||
(Just EAChangeFormat)
|
||||
]
|
||||
|
||||
it "SimplexLink 2" do
|
||||
diff
|
||||
( LeftSide $
|
||||
S.fromList
|
||||
[ FormatChar '>' $
|
||||
Just $
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/2/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host1", "host2", "host3"]
|
||||
}
|
||||
]
|
||||
)
|
||||
( RightSide $
|
||||
S.fromList
|
||||
[ FormatChar '>' $
|
||||
Just
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/3/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host1", "host2", "host3"]
|
||||
}
|
||||
]
|
||||
)
|
||||
`shouldBe` S.fromList
|
||||
[ DiffChar
|
||||
( FormatChar '>' $
|
||||
Just
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/2/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host1", "host2", "host3"]
|
||||
}
|
||||
)
|
||||
$ UnchangedChar
|
||||
$ ChangedToFormat
|
||||
$ Just
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/3/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host1", "host2", "host3"]
|
||||
}
|
||||
]
|
||||
[ FormatChar '>' $
|
||||
Just $
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/2/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host1", "host2", "host3"]
|
||||
}
|
||||
]
|
||||
[ FormatChar '>' $
|
||||
Just
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/3/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host1", "host2", "host3"]
|
||||
}
|
||||
]
|
||||
`shouldBe` [ DiffChar
|
||||
( FormatChar '>' $
|
||||
Just
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/3/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host1", "host2", "host3"]
|
||||
}
|
||||
)
|
||||
(Just EAChangeFormat)
|
||||
]
|
||||
|
||||
it "SimplexLink 3" do
|
||||
diff
|
||||
( LeftSide $
|
||||
S.fromList
|
||||
[ FormatChar '>' $
|
||||
Just $
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/2/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host1", "host2", "host3"]
|
||||
}
|
||||
]
|
||||
)
|
||||
( RightSide $
|
||||
S.fromList
|
||||
[ FormatChar '>' $
|
||||
Just
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/2/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host0", "host2", "host3"]
|
||||
}
|
||||
]
|
||||
)
|
||||
`shouldBe` S.fromList
|
||||
[ DiffChar
|
||||
( FormatChar '>' $
|
||||
Just
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/2/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host1", "host2", "host3"]
|
||||
}
|
||||
)
|
||||
$ UnchangedChar
|
||||
$ ChangedToFormat
|
||||
$ Just
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/2/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host0", "host2", "host3"]
|
||||
}
|
||||
]
|
||||
[ FormatChar '>' $
|
||||
Just $
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/2/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host1", "host2", "host3"]
|
||||
}
|
||||
]
|
||||
[ FormatChar '>' $
|
||||
Just
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/2/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host0", "host2", "host3"]
|
||||
}
|
||||
]
|
||||
`shouldBe` [ DiffChar
|
||||
( FormatChar '>' $
|
||||
Just
|
||||
SimplexLink
|
||||
{ linkType = XLContact,
|
||||
simplexUri = "https://api.twitter.com/2/tweets/:id",
|
||||
trustedUri = True,
|
||||
smpHosts = NE.fromList ["host0", "host2", "host3"]
|
||||
}
|
||||
)
|
||||
(Just EAChangeFormat)
|
||||
]
|
||||
|
||||
it "plainDiff 1" do
|
||||
plainDiff
|
||||
(LeftSide "https://api.twitter.com/2/tweets/:id")
|
||||
(RightSide "https://api.twitter.com/3/tweets/:id")
|
||||
`shouldBe` S.fromList
|
||||
[ DiffPlainChar 'h' UnchangedP,
|
||||
DiffPlainChar 't' UnchangedP,
|
||||
DiffPlainChar 't' UnchangedP,
|
||||
DiffPlainChar 'p' UnchangedP,
|
||||
DiffPlainChar 's' UnchangedP,
|
||||
DiffPlainChar ':' UnchangedP,
|
||||
DiffPlainChar '/' UnchangedP,
|
||||
DiffPlainChar '/' UnchangedP,
|
||||
DiffPlainChar 'a' UnchangedP,
|
||||
DiffPlainChar 'p' UnchangedP,
|
||||
DiffPlainChar 'i' UnchangedP,
|
||||
DiffPlainChar '.' UnchangedP,
|
||||
DiffPlainChar 't' UnchangedP,
|
||||
DiffPlainChar 'w' UnchangedP,
|
||||
DiffPlainChar 'i' UnchangedP,
|
||||
DiffPlainChar 't' UnchangedP,
|
||||
DiffPlainChar 't' UnchangedP,
|
||||
DiffPlainChar 'e' UnchangedP,
|
||||
DiffPlainChar 'r' UnchangedP,
|
||||
DiffPlainChar '.' UnchangedP,
|
||||
DiffPlainChar 'c' UnchangedP,
|
||||
DiffPlainChar 'o' UnchangedP,
|
||||
DiffPlainChar 'm' UnchangedP,
|
||||
DiffPlainChar '/' UnchangedP,
|
||||
DiffPlainChar '2' DeletedP,
|
||||
DiffPlainChar '3' InsertedP,
|
||||
DiffPlainChar '/' UnchangedP,
|
||||
DiffPlainChar 't' UnchangedP,
|
||||
DiffPlainChar 'w' UnchangedP,
|
||||
DiffPlainChar 'e' UnchangedP,
|
||||
DiffPlainChar 'e' UnchangedP,
|
||||
DiffPlainChar 't' UnchangedP,
|
||||
DiffPlainChar 's' UnchangedP,
|
||||
DiffPlainChar '/' UnchangedP,
|
||||
DiffPlainChar ':' UnchangedP,
|
||||
DiffPlainChar 'i' UnchangedP,
|
||||
DiffPlainChar 'd' UnchangedP
|
||||
]
|
||||
"https://api.twitter.com/2/tweets/:id"
|
||||
"https://api.twitter.com/3/tweets/:id"
|
||||
`shouldBe` [ DiffPlainChar 'h' Nothing,
|
||||
DiffPlainChar 't' Nothing,
|
||||
DiffPlainChar 't' Nothing,
|
||||
DiffPlainChar 'p' Nothing,
|
||||
DiffPlainChar 's' Nothing,
|
||||
DiffPlainChar ':' Nothing,
|
||||
DiffPlainChar '/' Nothing,
|
||||
DiffPlainChar '/' Nothing,
|
||||
DiffPlainChar 'a' Nothing,
|
||||
DiffPlainChar 'p' Nothing,
|
||||
DiffPlainChar 'i' Nothing,
|
||||
DiffPlainChar '.' Nothing,
|
||||
DiffPlainChar 't' Nothing,
|
||||
DiffPlainChar 'w' Nothing,
|
||||
DiffPlainChar 'i' Nothing,
|
||||
DiffPlainChar 't' Nothing,
|
||||
DiffPlainChar 't' Nothing,
|
||||
DiffPlainChar 'e' Nothing,
|
||||
DiffPlainChar 'r' Nothing,
|
||||
DiffPlainChar '.' Nothing,
|
||||
DiffPlainChar 'c' Nothing,
|
||||
DiffPlainChar 'o' Nothing,
|
||||
DiffPlainChar 'm' Nothing,
|
||||
DiffPlainChar '/' Nothing,
|
||||
DiffPlainChar '2' $ Just EADelete,
|
||||
DiffPlainChar '3' $ Just EAInsert,
|
||||
DiffPlainChar '/' Nothing,
|
||||
DiffPlainChar 't' Nothing,
|
||||
DiffPlainChar 'w' Nothing,
|
||||
DiffPlainChar 'e' Nothing,
|
||||
DiffPlainChar 'e' Nothing,
|
||||
DiffPlainChar 't' Nothing,
|
||||
DiffPlainChar 's' Nothing,
|
||||
DiffPlainChar '/' Nothing,
|
||||
DiffPlainChar ':' Nothing,
|
||||
DiffPlainChar 'i' Nothing,
|
||||
DiffPlainChar 'd' Nothing
|
||||
]
|
||||
|
||||
it "plainDiff 2" do
|
||||
plainDiff
|
||||
(LeftSide "Hrl~!@lo")
|
||||
(RightSide "Herxy!@zo12")
|
||||
`shouldBe` S.fromList
|
||||
[ DiffPlainChar 'H' UnchangedP,
|
||||
DiffPlainChar 'e' InsertedP,
|
||||
DiffPlainChar 'r' UnchangedP,
|
||||
DiffPlainChar 'l' DeletedP,
|
||||
DiffPlainChar '~' DeletedP,
|
||||
DiffPlainChar 'x' InsertedP,
|
||||
DiffPlainChar 'y' InsertedP,
|
||||
DiffPlainChar '!' UnchangedP,
|
||||
DiffPlainChar '@' UnchangedP,
|
||||
DiffPlainChar 'l' DeletedP,
|
||||
DiffPlainChar 'z' InsertedP,
|
||||
DiffPlainChar 'o' UnchangedP,
|
||||
DiffPlainChar '1' InsertedP,
|
||||
DiffPlainChar '2' InsertedP
|
||||
]
|
||||
"Hrl~!@lo"
|
||||
"Herxy!@zo12"
|
||||
`shouldBe` [ DiffPlainChar 'H' Nothing,
|
||||
DiffPlainChar 'e' $ Just EAInsert,
|
||||
DiffPlainChar 'r' Nothing,
|
||||
DiffPlainChar 'l' $ Just EADelete,
|
||||
DiffPlainChar '~' $ Just EADelete,
|
||||
DiffPlainChar 'x' $ Just EAInsert,
|
||||
DiffPlainChar 'y' $ Just EAInsert,
|
||||
DiffPlainChar '!' Nothing,
|
||||
DiffPlainChar '@' Nothing,
|
||||
DiffPlainChar 'l' $ Just EADelete,
|
||||
DiffPlainChar 'z' $ Just EAInsert,
|
||||
DiffPlainChar 'o' Nothing,
|
||||
DiffPlainChar '1' $ Just EAInsert,
|
||||
DiffPlainChar '2' $ Just EAInsert
|
||||
]
|
||||
+2
-1
@@ -5,8 +5,8 @@ import ChatTests
|
||||
import ChatTests.Utils (xdescribe'')
|
||||
import Control.Logger.Simple
|
||||
import Data.Time.Clock.System
|
||||
import MarkdownTests
|
||||
import MarkdownDiffTests
|
||||
import MarkdownTests
|
||||
import MobileTests
|
||||
import ProtocolTests
|
||||
import SchemaDump
|
||||
@@ -21,6 +21,7 @@ main = do
|
||||
withGlobalLogging logCfg . hspec $ do
|
||||
describe "Schema dump" schemaDumpTest
|
||||
describe "SimpleX chat markdown" markdownTests
|
||||
fdescribe "SimpleX chat markdown diff" markdownDiffTests
|
||||
describe "SimpleX chat view" viewTests
|
||||
describe "SimpleX chat protocol" protocolTests
|
||||
describe "WebRTC encryption" webRTCTests
|
||||
|
||||
Reference in New Issue
Block a user