]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/html/templates/chloe/chloe-tests.factor
html.templates: reverse order of style and scripts
[factor.git] / basis / html / templates / chloe / chloe-tests.factor
index 891e32826a0c8f8442b82de20905c95183c0fc1e..1ba5aaaa7a005285417dac4a50ecd0efcbd1388d 100644 (file)
@@ -10,7 +10,7 @@ IN: html.templates.chloe.tests
 
 : run-template ( quot -- string )
     with-string-writer [ "\r\n\t" member? ] reject
-    "?>" split1 nip ; inline
+    [ CHAR: \s = ] trim ; inline
 
 : test-template ( name -- template )
     "vocab:html/templates/chloe/test/"
@@ -32,7 +32,7 @@ IN: html.templates.chloe.tests
     ] with-scope
 ] unit-test
 
-{ "<html><head><title>Hello world</title></head><body>Blah blah</body></html>" } [
+{ "<!DOCTYPE html><html><head><title>Hello world</title></head><body>Blah blah</body></html>" } [
     [
         [
             "test2" test-template call-template
@@ -97,7 +97,7 @@ M: link-test link-href drop "http://www.apple.com/foo&bar" ;
 { "<ul><li>1</li><li>2</li><li>3</li></ul>" } [
     [
         "test7" test-template call-template
-    ] run-template [ blank? ] reject
+    ] run-template [ ascii:blank? ] reject
 ] unit-test
 
 TUPLE: person first-name last-name ;
@@ -112,7 +112,7 @@ TUPLE: person first-name last-name ;
 { "<table><tr><td>RBaxter</td><td>Unknown</td></tr><tr><td>Doug</td><td>Coleman</td></tr></table>" } [
     [
         "test8" test-template call-template
-    ] run-template [ blank? ] reject
+    ] run-template [ ascii:blank? ] reject
 ] unit-test
 
 { } [
@@ -125,7 +125,7 @@ TUPLE: person first-name last-name ;
 { "<table><tr><td>RBaxter</td><td>Unknown</td></tr><tr><td>Doug</td><td>Coleman</td></tr></table>" } [
     [
         "test8" test-template call-template
-    ] run-template [ blank? ] reject
+    ] run-template [ ascii:blank? ] reject
 ] unit-test
 
 { } [ 1 "id" set-value ] unit-test
@@ -153,7 +153,7 @@ TUPLE: person first-name last-name ;
 { "<table><tr><td>RBaxter</td><td>Unknown</td></tr></table>" } [
     [
         "test11" test-template call-template
-    ] run-template [ blank? ] reject
+    ] run-template [ ascii:blank? ] reject
 ] unit-test
 
 { } [
@@ -194,3 +194,21 @@ TUPLE: person first-name last-name ;
         ] run-template
     ] with-scope
 ] [ error>> tag-not-allowed-here? ] must-fail-with
+
+{ "This is     <style type=\"text/css\"> * { font-family: monospace; } </style>" } [
+    V{ } clone style [
+        [ "test16" test-template call-template ] run-template
+    ] with-variable
+] unit-test
+
+{ "<script type=\"text/javascript\">/* <![CDATA[*/function testAlerts() {    window.alert(\"Hello, world!\");}/*]]> */</script>" } [
+    V{ } clone script [
+        [ "test17" test-template call-template ] run-template
+    ] with-variable
+] unit-test
+
+{ "<meta name=\"author\" content=\"John Doe\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/>" } [
+    V{ } clone meta [
+        [ "test18" test-template call-template ] run-template
+    ] with-variable
+] unit-test