Commit 4e207779 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[test] fix test-ps

parent f910cd90
...@@ -192,6 +192,14 @@ yarn css # for manual setup ...@@ -192,6 +192,14 @@ yarn css # for manual setup
A guide to getting set up with the IDE integration is coming soon, I hope. A guide to getting set up with the IDE integration is coming soon, I hope.
### Testing
To run unit tests, just run:
``` shell
test-ps
```
### Note to contributors ### Note to contributors
Please follow CONTRIBUTING.md Please follow CONTRIBUTING.md
......
...@@ -35,7 +35,8 @@ let ...@@ -35,7 +35,8 @@ let
build-purs build-purs
echo "Testing" echo "Testing"
# yarn pulp browserify --skip-compile -t dist/bundle.js --src-path output # yarn pulp browserify --skip-compile -t dist/bundle.js --src-path output
yarn pulp test --src-path output --test-path output # yarn pulp test --src-path output --test-path output
NODE_PATH=output node -e "require('Test.Main').main();"
''; '';
in in
pkgs.mkShell { pkgs.mkShell {
......
...@@ -55,13 +55,12 @@ spec = do ...@@ -55,13 +55,12 @@ spec = do
] ]
, ngrams_scores: Map.fromFoldable [] } , ngrams_scores: Map.fromFoldable [] }
input = "this is a graph about a biography which stops at every candidate" input = "this is a graph about a biography which stops at every candidate"
output = [Tuple "this is a " Nothing output = [ Tuple "this is a graph about a biography " Nothing
,Tuple " about a biography " Nothing , Tuple "which" (Just StopTerm)
,Tuple "which" (Just StopTerm) , Tuple " " Nothing
,Tuple " " Nothing , Tuple "stops" (Just StopTerm)
,Tuple "stops" (Just StopTerm) , Tuple " at every " Nothing
,Tuple " at every " Nothing , Tuple "candidate" (Just CandidateTerm)
,Tuple "candidate" (Just CandidateTerm)
] ]
highlightNgrams CTabTerms table input `shouldEqual` output highlightNgrams CTabTerms table input `shouldEqual` output
...@@ -74,18 +73,13 @@ spec = do ...@@ -74,18 +73,13 @@ spec = do
] ]
, ngrams_scores: Map.fromFoldable [] } , ngrams_scores: Map.fromFoldable [] }
input = "This is a new state of the" input = "This is a new state of the"
output = [Tuple "This " Nothing output = [ Tuple "This " Nothing
,Tuple "is" (Just StopTerm) , Tuple "is" (Just StopTerm)
,Tuple " " Nothing , Tuple " " Nothing
,Tuple "a" (Just StopTerm) , Tuple "a" (Just StopTerm)
,Tuple " " Nothing , Tuple " new state " Nothing
,Tuple "new" Nothing , Tuple "of" (Just StopTerm)
,Tuple " " Nothing , Tuple " the" Nothing
,Tuple "state" Nothing
,Tuple " " Nothing
,Tuple "of" (Just StopTerm)
,Tuple " " Nothing
,Tuple "the" Nothing
] ]
highlightNgrams CTabTerms table input `shouldEqual` output highlightNgrams CTabTerms table input `shouldEqual` output
...@@ -98,10 +92,24 @@ spec = do ...@@ -98,10 +92,24 @@ spec = do
] ]
, ngrams_scores: Map.fromFoldable [] } , ngrams_scores: Map.fromFoldable [] }
input = "This is from space images" input = "This is from space images"
output = [Tuple "This is " Nothing output = [ Tuple "This is " Nothing
,Tuple "from" (Just CandidateTerm) , Tuple "from" (Just CandidateTerm)
,Tuple " space " Nothing , Tuple " space " Nothing
,Tuple "images" (Just CandidateTerm) , Tuple "images" (Just CandidateTerm)
]
highlightNgrams CTabTerms table input `shouldEqual` output
it "works when pattern overlaps 3" do
let ngramType = CTabSources
let table = NgramsTable
{ ngrams_repo_elements: Map.fromFoldable [ tnre "fusion" MapTerm ngramType
, tnre "calculate fusion" CandidateTerm ngramType
]
, ngrams_scores: Map.fromFoldable [] }
input = "Model has been used to calculate fusion cross sections"
output = [ Tuple "Model has been used to " Nothing
, Tuple "calculate fusion" (Just CandidateTerm)
, Tuple " sections " Nothing
] ]
highlightNgrams CTabTerms table input `shouldEqual` output highlightNgrams CTabTerms table input `shouldEqual` output
...@@ -111,8 +119,8 @@ spec = do ...@@ -111,8 +119,8 @@ spec = do
{ ngrams_repo_elements: Map.fromFoldable [ tnre "graph" CandidateTerm ngramType ] { ngrams_repo_elements: Map.fromFoldable [ tnre "graph" CandidateTerm ngramType ]
, ngrams_scores: Map.fromFoldable [] } , ngrams_scores: Map.fromFoldable [] }
input = "before graph, after" input = "before graph, after"
output = [Tuple "before " Nothing output = [ Tuple "before " Nothing
,Tuple "graph" (Just CandidateTerm) , Tuple "graph" (Just CandidateTerm)
,Tuple ", after" Nothing , Tuple ", after" Nothing
] ]
highlightNgrams CTabTerms table input `shouldEqual` output highlightNgrams CTabTerms table input `shouldEqual` output
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