Commit 25a14cb2 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge remote-tracking branch 'origin/adinapoli/issue-ps-632-phylo-unicode' into dev

parents 574631df 1a1ff4a9
...@@ -896,6 +896,7 @@ test-suite garg-test-tasty ...@@ -896,6 +896,7 @@ test-suite garg-test-tasty
, fmt , fmt
, gargantext , gargantext
, gargantext-prelude , gargantext-prelude
, graphviz ^>= 2999.20.1.0
, hspec ^>= 2.7.10 , hspec ^>= 2.7.10
, hspec-core , hspec-core
, hspec-expectations >= 0.8 && < 0.9 , hspec-expectations >= 0.8 && < 0.9
...@@ -942,6 +943,7 @@ test-suite garg-test-tasty ...@@ -942,6 +943,7 @@ test-suite garg-test-tasty
, tree-diff , tree-diff
, unordered-containers ^>= 0.2.16.0 , unordered-containers ^>= 0.2.16.0
, validity ^>= 0.11.0.1 , validity ^>= 0.11.0.1
, vector ^>= 0.12.3.0
, wai , wai
, wai-extra , wai-extra
, warp , warp
......
...@@ -125,7 +125,7 @@ groupToDotNode fdt g bId = ...@@ -125,7 +125,7 @@ groupToDotNode fdt g bId =
, toAttr "sourceFull" (show (g ^. phylo_groupSources)) , toAttr "sourceFull" (show (g ^. phylo_groupSources))
, toAttr "density" (show (g ^. phylo_groupDensity)) , toAttr "density" (show (g ^. phylo_groupDensity))
, toAttr "cooc" (show (g ^. phylo_groupCooc)) , toAttr "cooc" (show (g ^. phylo_groupCooc))
, toAttr "lbl" (show (ngramsToLabel fdt (g ^. phylo_groupNgrams))) , toAttr "lbl" (Lazy.fromStrict $ ngramsToLabel fdt (g ^. phylo_groupNgrams))
, toAttr "foundation" (show (idxToLabel (g ^. phylo_groupNgrams))) , toAttr "foundation" (show (idxToLabel (g ^. phylo_groupNgrams)))
, toAttr "role" (show (idxToLabel' ((g ^. phylo_groupMeta) ! "dynamics"))) , toAttr "role" (show (idxToLabel' ((g ^. phylo_groupMeta) ! "dynamics")))
, toAttr "frequence" (show (idxToLabel' ((g ^. phylo_groupMeta) ! "frequence"))) , toAttr "frequence" (show (idxToLabel' ((g ^. phylo_groupMeta) ! "frequence")))
......
...@@ -5,14 +5,18 @@ ...@@ -5,14 +5,18 @@
module Test.Offline.Phylo (tests) where module Test.Offline.Phylo (tests) where
import Data.GraphViz.Attributes.Complete qualified as Graphviz
import Data.Vector qualified as V
import Gargantext.Core.Viz.Phylo import Gargantext.Core.Viz.Phylo
import Gargantext.Core.Viz.Phylo.API.Tools (readPhylo, writePhylo) import Gargantext.Core.Viz.Phylo.API.Tools (readPhylo, writePhylo)
import Gargantext.Core.Viz.Phylo.PhyloExport
import Gargantext.Core.Viz.Phylo.PhyloMaker (toPhylo) import Gargantext.Core.Viz.Phylo.PhyloMaker (toPhylo)
import Gargantext.Core.Viz.Phylo.PhyloTools import Gargantext.Core.Viz.Phylo.PhyloTools
import Prelude import Prelude
import Test.Tasty import Test.Tasty
import Test.Tasty.HUnit import Test.Tasty.HUnit
import Test.Tasty.QuickCheck import Test.Tasty.QuickCheck
import Data.Text.Lazy as TL
import Paths_gargantext import Paths_gargantext
...@@ -43,6 +47,10 @@ phyloConfig = PhyloConfig { ...@@ -43,6 +47,10 @@ phyloConfig = PhyloConfig {
tests :: TestTree tests :: TestTree
tests = testGroup "Phylo" [ tests = testGroup "Phylo" [
-- testCase "returns expected data" testSmallPhyloExpectedOutput -- testCase "returns expected data" testSmallPhyloExpectedOutput
testGroup "Export" [
testCase "ngramsToLabel respects encoding" test_ngramsToLabel_01
, testCase "ngramsToLabel is rendered correctly in CustomAttribute" test_ngramsToLabel_02
]
] ]
testSmallPhyloExpectedOutput :: Assertion testSmallPhyloExpectedOutput :: Assertion
...@@ -51,3 +59,13 @@ testSmallPhyloExpectedOutput = do ...@@ -51,3 +59,13 @@ testSmallPhyloExpectedOutput = do
expected <- readPhylo =<< getDataFileName "test-data/phylo/issue-290-small.golden.json" expected <- readPhylo =<< getDataFileName "test-data/phylo/issue-290-small.golden.json"
let actual = toPhylo issue290PhyloSmall let actual = toPhylo issue290PhyloSmall
expected @?= actual expected @?= actual
test_ngramsToLabel_01 :: Assertion
test_ngramsToLabel_01 =
let ngrams = V.fromList [ "évaluation", "méthodologique" ]
in ngramsToLabel ngrams [0,1] @?= "évaluation | méthodologique"
test_ngramsToLabel_02 :: Assertion
test_ngramsToLabel_02 =
let ngrams = V.fromList [ "钱", "狗" ]
in (Graphviz.customValue $ toAttr "lbl" $ TL.fromStrict $ ngramsToLabel ngrams [0,1]) @?= "钱 | 狗"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment