Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
- Fix incorrect docs & variable name on CSSManager-test._expectParseE…
Browse files Browse the repository at this point in the history
…rror()

- Add more expected failures for the additional cases Randy found in issue #343
  • Loading branch information
peterflynn committed Mar 1, 2012
1 parent a1d96df commit 1217b32
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions test/spec/CSSManager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,10 @@ define(function (require, exports, module) {


/**
* Test helper function: expects CSS parsing to fail on the given 1-based line number with
* the given message.
* Test helper function: expects CSS parsing to fail at the given 0-based offset within the
* cssCode string, with the given error message.
*/
var _expectParseError = function (cssCode, lineNumber, errorString) {
var _expectParseError = function (cssCode, expectedCodeOffset, expectedErrorMessage) {
try {
manager = new CSSManager._CSSManager();
manager._loadString(cssCode);
Expand All @@ -408,8 +408,8 @@ define(function (require, exports, module) {
this.fail("Expected parse error: " + cssCode);

} catch (error) {
expect(error.index).toBe(lineNumber);
expect(error.message).toBe(errorString);
expect(error.index).toBe(expectedCodeOffset);
expect(error.message).toBe(expectedErrorMessage);
}
};

Expand Down Expand Up @@ -715,6 +715,15 @@ define(function (require, exports, module) {
result = matchAgain({ tag: "h4" });
expect(result.length).toBe(0);

// Quotes AND braces nested inside string
// TODO (issue #343): these should get parsed correctly
expectParseError("div::after { content: \"\\\"}\\\"\"; }", 13, "Syntax Error on line 1");
expectParseError("div::after { content: \"\\\"{\"; }", undefined, "Missing closing `}`");

css = "@import \"null?\\\"{\"; \n" + // this is a real-world CSS hack that is a case of the above
"div { color: red }";
expectParseError(css, undefined, "Missing closing `}`");

// Newline inside string (escaped)
result = match("li::before { content: 'foo\\nbar'; } \n div { color:red }", { tag: "div" });
expect(result.length).toBe(1);
Expand Down

0 comments on commit 1217b32

Please sign in to comment.