@@ -4,69 +4,77 @@ import { isValidAttrValue, isValidStatement } from "..";
44describe ( "validation helpers" , ( ) => {
55 describe ( "isValidStatement" , ( ) => {
66 it ( "accepts single-line expressions" , ( ) => {
7- assert . equal ( isValidStatement ( "foo + bar" ) , true ) ;
7+ assert . equal ( isValidStatement ( "foo + bar" ) , 2 ) ;
88 } ) ;
99
1010 it ( "accepts indented continuation lines" , ( ) => {
11- assert . equal ( isValidStatement ( "foo\n + bar" ) , true ) ;
11+ assert . equal ( isValidStatement ( "foo\n + bar" ) , 1 ) ;
1212 } ) ;
1313
1414 it ( "rejects unindented continuation lines" , ( ) => {
15- assert . equal ( isValidStatement ( "foo\nbar" ) , false ) ;
15+ assert . equal ( isValidStatement ( "foo\nbar" ) , 0 ) ;
1616 } ) ;
1717
1818 it ( "accepts indented ternary continuation" , ( ) => {
19- assert . equal ( isValidStatement ( "foo ?\n bar : baz" ) , true ) ;
19+ assert . equal ( isValidStatement ( "foo ?\n bar : baz" ) , 2 ) ;
2020 } ) ;
2121
2222 it ( "rejects unterminated groups" , ( ) => {
23- assert . equal ( isValidStatement ( "(foo" ) , false ) ;
23+ assert . equal ( isValidStatement ( "(foo" ) , 0 ) ;
2424 } ) ;
2525
2626 it ( "rejects mismatched closing groups" , ( ) => {
27- assert . equal ( isValidStatement ( ")" ) , false ) ;
27+ assert . equal ( isValidStatement ( ")" ) , 0 ) ;
2828 } ) ;
2929 } ) ;
3030
3131 describe ( "isValidAttrValue" , ( ) => {
3232 it ( "accepts html attr values with operators" , ( ) => {
33- assert . equal ( isValidAttrValue ( "foo + bar" , false ) , true ) ;
33+ assert . equal ( isValidAttrValue ( "foo + bar" , false ) , 2 ) ;
3434 } ) ;
3535
3636 it ( "accepts html attr values containing =>" , ( ) => {
37- assert . equal ( isValidAttrValue ( "foo=>bar" , false ) , true ) ;
37+ assert . equal ( isValidAttrValue ( "foo=>bar" , false ) , 2 ) ;
3838 } ) ;
3939
4040 it ( "rejects html attr values terminated by >" , ( ) => {
41- assert . equal ( isValidAttrValue ( "foo >" , false ) , false ) ;
41+ assert . equal ( isValidAttrValue ( "foo >" , false ) , 0 ) ;
4242 } ) ;
4343
4444 it ( "accepts concise attr values with >" , ( ) => {
45- assert . equal ( isValidAttrValue ( "foo > bar" , true ) , true ) ;
45+ assert . equal ( isValidAttrValue ( "foo > bar" , true ) , 2 ) ;
4646 } ) ;
4747
4848 it ( "rejects html attr values terminated by commas" , ( ) => {
49- assert . equal ( isValidAttrValue ( "foo, bar" , false ) , false ) ;
49+ assert . equal ( isValidAttrValue ( "foo, bar" , false ) , 0 ) ;
5050 } ) ;
5151
5252 it ( "accepts html attr values containing semicolons" , ( ) => {
53- assert . equal ( isValidAttrValue ( "foo;" , false ) , true ) ;
53+ assert . equal ( isValidAttrValue ( "foo;" , false ) , 2 ) ;
5454 } ) ;
5555
5656 it ( "rejects concise attr values terminated by semicolons" , ( ) => {
57- assert . equal ( isValidAttrValue ( "foo;" , true ) , false ) ;
57+ assert . equal ( isValidAttrValue ( "foo;" , true ) , 0 ) ;
5858 } ) ;
5959
6060 it ( "accepts html attr values with decrement operator" , ( ) => {
61- assert . equal ( isValidAttrValue ( "foo --" , false ) , true ) ;
61+ assert . equal ( isValidAttrValue ( "foo --" , false ) , 2 ) ;
6262 } ) ;
6363
6464 it ( "rejects concise attr values with decrement operator" , ( ) => {
65- assert . equal ( isValidAttrValue ( "foo --" , true ) , false ) ;
65+ assert . equal ( isValidAttrValue ( "foo --" , true ) , 0 ) ;
6666 } ) ;
6767
6868 it ( "rejects attr values separated only by whitespace" , ( ) => {
69- assert . equal ( isValidAttrValue ( "foo bar" , false ) , false ) ;
69+ assert . equal ( isValidAttrValue ( "foo bar" , false ) , 0 ) ;
70+ } ) ;
71+
72+ it ( "accepts continued multiline logical expression" , ( ) => {
73+ assert . equal ( isValidAttrValue ( "a &&\nb" , true ) , 1 ) ;
74+ } ) ;
75+
76+ it ( "accepts continued multiline enclosed logical expression" , ( ) => {
77+ assert . equal ( isValidAttrValue ( "a && (\nb\n)" , true ) , 2 ) ;
7078 } ) ;
7179 } ) ;
7280} ) ;
0 commit comments