]> Git — Sourcephile - gargantext.git/blob - test/Spec.hs
[READING]
[gargantext.git] / test / Spec.hs
1 {-# LANGUAGE OverloadedStrings #-}
2
3 import Test.Hspec
4 import Test.QuickCheck
5 import Control.Exception (evaluate)
6
7
8 import Data.Text (Text)
9 import Data.Hastext.Parsers.Occurrences (parse)
10
11 main :: IO ()
12 main = print "hspec $ do"
13 describe "Parser for occurrences" $ do
14
15 let txt = "internet"
16
17 it "returns the result of one parsing" $ do
18 parse "internet" "internet" `shouldBe` Right ((txt, 1) :: (Text, Int))
19
20 -- | Context of Text should be toLower
21 it "returns the result of one parsing not case sensitive" $ do
22 let txtCase = "Internet"
23 parse txtCase "internet" `shouldBe` Right ((txtCase, 1) :: (Text, Int))
24
25 it "returns the result of one parsing after space" $ do
26 parse txt " internet"
27 `shouldBe` Right ((txt, 1) :: (Text, Int))
28
29 it "returns the result of one parsing after chars" $ do
30 parse txt "l'internet"
31 `shouldBe` (Right ((txt, 1) :: (Text, Int)))
32
33 it "returns the result of multiple parsing" $ do
34 parse txt "internet internet of things"
35 `shouldBe` (Right ((txt, 2) :: (Text, Int)))
36
37 it "returns the result of multiple parsing separated by text" $ do
38 parse txt "internet in the internet of things"
39 `shouldBe` (Right ((txt, 2) :: (Text, Int)))
40
41 it "returns the result of multiple parsing separated by punctuation" $ do
42 parse txt "internet. In the internet of things, internet like; internet?"
43 `shouldBe` (Right ((txt, 4) :: (Text, Int)))
44
45
46
47