]> Git — Sourcephile - gargantext.git/blob - test/Spec.hs
[DRAFT/SPECS] For rights.
[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 = print "hspec $ do
12 describe "Parser for occurrences" $ do
13
14 let txt = "internet"
15
16 it "returns the result of one parsing" $ do
17 parse "internet" "internet" `shouldBe` Right ((txt, 1) :: (Text, Int))
18
19 -- | Context of Text should be toLower
20 it "returns the result of one parsing not case sensitive" $ do
21 let txtCase = "Internet"
22 parse txtCase "internet" `shouldBe` Right ((txtCase, 1) :: (Text, Int))
23
24 it "returns the result of one parsing after space" $ do
25 parse txt " internet"
26 `shouldBe` Right ((txt, 1) :: (Text, Int))
27
28 it "returns the result of one parsing after chars" $ do
29 parse txt "l'internet"
30 `shouldBe` (Right ((txt, 1) :: (Text, Int)))
31
32 it "returns the result of multiple parsing" $ do
33 parse txt "internet internet of things"
34 `shouldBe` (Right ((txt, 2) :: (Text, Int)))
35
36 it "returns the result of multiple parsing separated by text" $ do
37 parse txt "internet in the internet of things"
38 `shouldBe` (Right ((txt, 2) :: (Text, Int)))
39
40 it "returns the result of multiple parsing separated by punctuation" $ do
41 parse txt "internet. In the internet of things, internet like; internet?"
42 `shouldBe` (Right ((txt, 4) :: (Text, Int)))
43
44
45
46 main :: IO ()
47