aboutsummaryrefslogtreecommitdiffstats
path: root/scalding/src/test/scala/sandcrawler/ScorableTest.scala
diff options
context:
space:
mode:
authorEllen Spertus <ellen.spertus@gmail.com>2018-08-12 18:08:51 -0700
committerEllen Spertus <ellen.spertus@gmail.com>2018-08-12 18:08:51 -0700
commit31354b1a6062c5c56a30610f68fa48c82a7e83f0 (patch)
treea730150c3f29ea76579ee6928a7c2db9e5b22eac /scalding/src/test/scala/sandcrawler/ScorableTest.scala
parent728e50a33cec921c9a624439f2e1c8561a6e12ce (diff)
downloadsandcrawler-31354b1a6062c5c56a30610f68fa48c82a7e83f0.tar.gz
sandcrawler-31354b1a6062c5c56a30610f68fa48c82a7e83f0.zip
Tests pass.
Diffstat (limited to 'scalding/src/test/scala/sandcrawler/ScorableTest.scala')
-rw-r--r--scalding/src/test/scala/sandcrawler/ScorableTest.scala28
1 files changed, 18 insertions, 10 deletions
diff --git a/scalding/src/test/scala/sandcrawler/ScorableTest.scala b/scalding/src/test/scala/sandcrawler/ScorableTest.scala
index 2f80492..95faacc 100644
--- a/scalding/src/test/scala/sandcrawler/ScorableTest.scala
+++ b/scalding/src/test/scala/sandcrawler/ScorableTest.scala
@@ -54,28 +54,36 @@ class ScorableTest extends FlatSpec with Matchers {
"annex": null
}
"""
+ private def titleToSlug(s : String) : String = {
+ Scorable.mapToSlug(Scorable.toScorableMap(title = s))
+ }
- "titleToSlug()" should "extract the parts of titles before a colon" in {
- Scorable.titleToSlug("HELLO:there") shouldBe "hello"
+ "mapToSlug()" should "extract the parts of titles before a colon" in {
+ titleToSlug("HELLO:there") shouldBe "hello"
}
it should "extract an entire colon-less string" in {
- Scorable.titleToSlug("hello THERE") shouldBe "hello there"
+ titleToSlug("hello THERE") shouldBe "hellothere"
}
it should "return Scorable.NoSlug if given empty string" in {
- Scorable.titleToSlug("") shouldBe Scorable.NoSlug
+ titleToSlug("") shouldBe Scorable.NoSlug
}
it should "return Scorable.NoSlug if given null" in {
- Scorable.titleToSlug(null) shouldBe Scorable.NoSlug
+ titleToSlug(null) shouldBe Scorable.NoSlug
+ }
+
+ it should "strip punctuation" in {
+ titleToSlug("HELLO!:the:re") shouldBe "hello"
+ titleToSlug("a:b:c") shouldBe "a"
+ titleToSlug(
+ "If you're happy and you know it, clap your hands!") shouldBe "ifyourehappyandyouknowitclapyourhands"
}
- "titleToSlug()" should "strip punctuation" in {
- Scorable.titleToSlug("HELLO!:the:re") shouldBe "hello"
- Scorable.titleToSlug("a:b:c") shouldBe "a"
- Scorable.titleToSlug(
- "If you're happy and you know it, clap your hands!") shouldBe "if youre happy and you know it clap your hands"
+ it should "remove whitespace" in {
+ titleToSlug("foo bar : baz ::") shouldBe "foobar"
+ titleToSlug("\na\t:b:c") shouldBe "a"
}
"jsonToMap()" should "return a map, given a legal JSON string" in {