Skip to content

Commit aef2bec

Browse files
committed
Add test for underscore hack
Additional validation in star hack
1 parent a9c6f1b commit aef2bec

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

build/parserlib-tests.js

+18
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,7 @@
15051505
parser.addListener("property", function(event){
15061506
Assert.areEqual("*color", event.property.toString());
15071507
Assert.areEqual("color", event.property.text);
1508+
Assert.areEqual("*", event.property.hack.toString(), "Property should be marked as with star hack");
15081509
Assert.areEqual("#fff", event.value.toString());
15091510
Assert.areEqual(5, event.property.col, "Property column should be 5.");
15101511
Assert.areEqual(2, event.property.line, "Property line should be 2.");
@@ -1516,6 +1517,23 @@
15161517
var result = parser.parse(".foo {\n *color: #fff;\n}");
15171518
},
15181519

1520+
"Test rule with underscore hack property": function(){
1521+
var parser = new Parser({ strict: true, underscoreHack: true});
1522+
parser.addListener("property", function(event){
1523+
Assert.areEqual("_color", event.property.toString());
1524+
Assert.areEqual("color", event.property.text);
1525+
Assert.areEqual("_", event.property.hack.toString(), "Property should be marked as with underscore hack");
1526+
Assert.areEqual("#fff", event.value.toString());
1527+
Assert.areEqual(5, event.property.col, "Property column should be 5.");
1528+
Assert.areEqual(2, event.property.line, "Property line should be 2.");
1529+
Assert.areEqual(5, event.col, "Event column should be 5.");
1530+
Assert.areEqual(2, event.line, "Event line should be 2.");
1531+
Assert.areEqual(13, event.value.parts[0].col, "First part column should be 13.");
1532+
Assert.areEqual(2, event.value.parts[0].line, "First part line should be 2.");
1533+
});
1534+
var result = parser.parse(".foo {\n _color: #fff;\n}");
1535+
},
1536+
15191537
"Test rule with space after property name": function(){
15201538
var parser = new Parser({ strict: true});
15211539
parser.addListener("property", function(event){

tests/css/Parser.js

+18
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,7 @@
15051505
parser.addListener("property", function(event){
15061506
Assert.areEqual("*color", event.property.toString());
15071507
Assert.areEqual("color", event.property.text);
1508+
Assert.areEqual("*", event.property.hack.toString(), "Property should be marked as with star hack");
15081509
Assert.areEqual("#fff", event.value.toString());
15091510
Assert.areEqual(5, event.property.col, "Property column should be 5.");
15101511
Assert.areEqual(2, event.property.line, "Property line should be 2.");
@@ -1516,6 +1517,23 @@
15161517
var result = parser.parse(".foo {\n *color: #fff;\n}");
15171518
},
15181519

1520+
"Test rule with underscore hack property": function(){
1521+
var parser = new Parser({ strict: true, underscoreHack: true});
1522+
parser.addListener("property", function(event){
1523+
Assert.areEqual("_color", event.property.toString());
1524+
Assert.areEqual("color", event.property.text);
1525+
Assert.areEqual("_", event.property.hack.toString(), "Property should be marked as with underscore hack");
1526+
Assert.areEqual("#fff", event.value.toString());
1527+
Assert.areEqual(5, event.property.col, "Property column should be 5.");
1528+
Assert.areEqual(2, event.property.line, "Property line should be 2.");
1529+
Assert.areEqual(5, event.col, "Event column should be 5.");
1530+
Assert.areEqual(2, event.line, "Event line should be 2.");
1531+
Assert.areEqual(13, event.value.parts[0].col, "First part column should be 13.");
1532+
Assert.areEqual(2, event.value.parts[0].line, "First part line should be 2.");
1533+
});
1534+
var result = parser.parse(".foo {\n _color: #fff;\n}");
1535+
},
1536+
15191537
"Test rule with space after property name": function(){
15201538
var parser = new Parser({ strict: true});
15211539
parser.addListener("property", function(event){

0 commit comments

Comments
 (0)