Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(470)

Unified Diff: javatests/org/chromium/distiller/DomUtilTest.java

Issue 1705123002: Add support for Schema.org/Recipe Base URL: https://github.com/chromium/dom-distiller.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: javatests/org/chromium/distiller/DomUtilTest.java
diff --git a/javatests/org/chromium/distiller/DomUtilTest.java b/javatests/org/chromium/distiller/DomUtilTest.java
index 4e21612db2e50e8169b058041870d822b0fbe39c..1d004a074afdf9a647d7269d06e56f83c5b5a28b 100644
--- a/javatests/org/chromium/distiller/DomUtilTest.java
+++ b/javatests/org/chromium/distiller/DomUtilTest.java
@@ -11,6 +11,7 @@ import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
+import java.util.ArrayList;
import java.util.Map;
import java.util.List;
@@ -377,4 +378,52 @@ public class DomUtilTest extends DomDistillerJsTestCase {
DomUtil.stripImageElements(mBody);
assertEquals(expected, mBody.getInnerHTML());
}
+
+ public void testJoin() {
+ List<String> wordsToJoin = new ArrayList<String>();
+ wordsToJoin.add("some");
+ wordsToJoin.add("words");
+ wordsToJoin.add("to");
+ wordsToJoin.add("join");
+ String result = DomUtil.join(wordsToJoin.toArray(), " - ");
+ String expected = "some - words - to - join";
+ assertEquals(expected, result);
+ }
+
+ public void testFormatDuration() {
+ String result = DomUtil.formatDuration("P3Y6M4DT12H30M5S");
+ String expected = "3 year(s) 6 month(s) 4 day(s) " +
+ "12 hour(s) 30 minute(s) 5 second(s)";
+ assertEquals(expected,result);
+
+ result = DomUtil.formatDuration("P23DT23H");
+ expected = "23 day(s) 23 hour(s)";
+ assertEquals(expected, result);
+
+ result = DomUtil.formatDuration("P4Y");
+ expected = "4 year(s)";
+ assertEquals(expected, result);
+
+ result = DomUtil.formatDuration("PT36H");
+ expected = "36 hour(s)";
+ assertEquals(expected, result);
+
+ result = DomUtil.formatDuration("PT15M");
+ expected = "15 minute(s)";
+ assertEquals(expected, result);
+
+ result = DomUtil.formatDuration("P23T23M");
+ expected = "";
+ assertEquals(expected,result);
+
+ result = DomUtil.formatDuration("PT15");
+ expected = "";
+ assertEquals(expected, result);
+
+ result = DomUtil.formatDuration("20M");
+ expected = "";
+ assertEquals(expected, result);
+ }
+
+
}

Powered by Google App Engine
This is Rietveld 408576698