Spec.purs 1.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
module Gargantext.Components.NgramsTable.Spec where

import Prelude
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..))
import Gargantext.Components.NgramsTable (highlightNgrams, NgramsElement(..), NgramsTable(..))
import Gargantext.Types  (TermList(..))
import Test.Spec (Spec, describe, it)
import Test.Spec.Assertions (shouldEqual)
-- import Test.Spec.QuickCheck (quickCheck')
import Data.Map as Map
import Data.Set as Set

spec :: Spec Unit
spec =
  describe "NgramsTable.highlightNgrams" do
    it "partially works" do
      let ne ngrams list =
            NgramsElement
              { ngrams
              , list
              , occurrences: 0
              , parent:   Nothing
              , root:     Nothing
              , children: Set.empty
              }
          tne ngrams list = Tuple ngrams (ne ngrams list)
          table = NgramsTable
                    (Map.fromFoldable [tne "graph"     GraphTerm
                                      ,tne "stop"      StopTerm
                                      ,tne "candidate" CandidateTerm
                                      ])
          input = "this is a biography which stops at every candidate"
          output = [Tuple "this is a bio" Nothing
                   ,Tuple "graph" (Just GraphTerm)
                   ,Tuple "y which " Nothing
                   ,Tuple "stop" (Just StopTerm)
                   ,Tuple "s at every " Nothing
                   ,Tuple "candidate" (Just CandidateTerm)]
      highlightNgrams table input `shouldEqual` output