]> Git — Sourcephile - gargantext.git/blob - src-test/Ngrams/Lang/Occurrences.hs
[TESTS][FIX] No Implicit Prelude for Tests too.
[gargantext.git] / src-test / Ngrams / Lang / Occurrences.hs
1 {-# LANGUAGE OverloadedStrings #-}
2 {-# LANGUAGE ScopedTypeVariables #-}
3
4 module Ngrams.Lang.Occurrences where
5
6 import Test.Hspec
7
8 import Data.Either (Either(Right))
9
10 import Gargantext.Prelude
11 import Gargantext.Ngrams.Occurrences (parseOccurrences)
12
13 parsersTest :: IO ()
14 parsersTest = hspec $ do
15 describe "Parser for occurrences" $ do
16
17 let txt = "internet"
18
19 it "returns the result of one parsing" $ do
20 parseOccurrences "internet" "internet" `shouldBe` Right 1
21
22 -- | Context of Text should be toLower
23 it "returns the result of one parsing not case sensitive" $ do
24 let txtCase = "Internet"
25 parseOccurrences txtCase "internet" `shouldBe` Right 1
26
27 it "returns the result of one parsing after space" $ do
28 parseOccurrences txt " internet"
29 `shouldBe` Right 1
30
31 it "returns the result of one parsing after chars" $ do
32 parseOccurrences txt "l'internet"
33 `shouldBe` Right 1
34
35 it "returns the result of multiple parsing" $ do
36 parseOccurrences txt "internet internet of things"
37 `shouldBe` Right 2
38
39 it "returns the result of multiple parsing separated by text" $ do
40 parseOccurrences txt "internet in the internet of things"
41 `shouldBe` Right 2
42
43 it "returns the result of multiple parsing separated by punctuation" $ do
44 parseOccurrences txt "internet. In the internet of things, internet like; internet?"
45 `shouldBe` Right 4
46
47 -- describe "Parser for nodes" $ do
48 -- it "returns the result of one parsing after space" $ do
49 -- occOfCorpus 249509 "sciences" `shouldReturn` 7
50