From d08a2d109fbc8e6ea7aa018d2a9dd2e452f00fbb Mon Sep 17 00:00:00 2001 From: Jermolene Date: Thu, 17 Apr 2014 14:43:24 +0100 Subject: [PATCH] Fix html parser tests --- .../test/tiddlers/tests/test-html-parser.js | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/editions/test/tiddlers/tests/test-html-parser.js b/editions/test/tiddlers/tests/test-html-parser.js index c3e68a022..00aa8d4b2 100644 --- a/editions/test/tiddlers/tests/test-html-parser.js +++ b/editions/test/tiddlers/tests/test-html-parser.js @@ -23,127 +23,127 @@ describe("HTML tag new parser tests", function() { var parser = new FakeParser(); it("should parse whitespace", function() { - expect(parser.parseWhiteSpace("p ",0)).toEqual( + expect($tw.utils.parseWhiteSpace("p ",0)).toEqual( null ); - expect(parser.parseWhiteSpace("p ",1)).toEqual( + expect($tw.utils.parseWhiteSpace("p ",1)).toEqual( { type : 'whitespace', start : 1, end : 3 } ); }); it("should parse string tokens", function() { - expect(parser.parseTokenString("p= ",0,"=")).toEqual( + expect($tw.utils.parseTokenString("p= ",0,"=")).toEqual( null ); - expect(parser.parseTokenString("p= ",1,"=")).toEqual( + expect($tw.utils.parseTokenString("p= ",1,"=")).toEqual( { type : 'token', value : '=', start : 1, end : 2 } ); }); it("should parse regexp tokens", function() { - expect(parser.parseTokenRegExp("p=' ",0,/(=(?:'|"))/)).toEqual( + expect($tw.utils.parseTokenRegExp("p=' ",0,/(=(?:'|"))/)).toEqual( null ); - expect(parser.parseTokenRegExp("p=' ",1,/(=(?:'|"))/g).match[0]).toEqual( + expect($tw.utils.parseTokenRegExp("p=' ",1,/(=(?:'|"))/g).match[0]).toEqual( '=\'' ); - expect(parser.parseTokenRegExp("p=blah ",2,/([^\s>]+)/g).match[0]).toEqual( + expect($tw.utils.parseTokenRegExp("p=blah ",2,/([^\s>]+)/g).match[0]).toEqual( 'blah' ); }); it("should parse string literals", function() { - expect(parser.parseStringLiteral("p='blah' ",0)).toEqual( + expect($tw.utils.parseStringLiteral("p='blah' ",0)).toEqual( null ); - expect(parser.parseStringLiteral("p='blah' ",2)).toEqual( + expect($tw.utils.parseStringLiteral("p='blah' ",2)).toEqual( { type : 'string', start : 2, value : 'blah', end : 8 } ); - expect(parser.parseStringLiteral("p='' ",2)).toEqual( + expect($tw.utils.parseStringLiteral("p='' ",2)).toEqual( { type : 'string', start : 2, value : '', end : 4 } ); - expect(parser.parseStringLiteral("p=\"blah' ",2)).toEqual( + expect($tw.utils.parseStringLiteral("p=\"blah' ",2)).toEqual( null ); - expect(parser.parseStringLiteral("p=\"\" ",2)).toEqual( + expect($tw.utils.parseStringLiteral("p=\"\" ",2)).toEqual( { type : 'string', start : 2, value : '', end : 4 } ); }); it("should parse macro parameters", function() { - expect(parser.parseMacroParameter("me",0)).toEqual( + expect($tw.utils.parseMacroParameter("me",0)).toEqual( { type : 'macro-parameter', start : 0, value : 'me', end : 2 } ); - expect(parser.parseMacroParameter("me:one",0)).toEqual( + expect($tw.utils.parseMacroParameter("me:one",0)).toEqual( { type : 'macro-parameter', start : 0, value : 'one', name : 'me', end : 6 } ); - expect(parser.parseMacroParameter("me:'one two three'",0)).toEqual( + expect($tw.utils.parseMacroParameter("me:'one two three'",0)).toEqual( { type : 'macro-parameter', start : 0, value : 'one two three', name : 'me', end : 18 } ); - expect(parser.parseMacroParameter("'one two three'",0)).toEqual( + expect($tw.utils.parseMacroParameter("'one two three'",0)).toEqual( { type : 'macro-parameter', start : 0, value : 'one two three', end : 15 } ); - expect(parser.parseMacroParameter("me:[[one two three]]",0)).toEqual( + expect($tw.utils.parseMacroParameter("me:[[one two three]]",0)).toEqual( { type : 'macro-parameter', start : 0, value : 'one two three', name : 'me', end : 20 } ); - expect(parser.parseMacroParameter("[[one two three]]",0)).toEqual( + expect($tw.utils.parseMacroParameter("[[one two three]]",0)).toEqual( { type : 'macro-parameter', start : 0, value : 'one two three', end : 17 } ); - expect(parser.parseMacroParameter("myparam>",0)).toEqual( + expect($tw.utils.parseMacroParameter("myparam>",0)).toEqual( { type : 'macro-parameter', start : 0, value : 'myparam', end : 7 } ); }); it("should parse macro invocations", function() { - expect(parser.parseMacroInvocation("<>",0)).toEqual( + expect($tw.utils.parseMacroInvocation("<>",0)).toEqual( { type : 'macrocall', start : 0, params : [ ], name : 'mymacro', end : 11 } ); - expect(parser.parseMacroInvocation("<>",0)).toEqual( + expect($tw.utils.parseMacroInvocation("<>",0)).toEqual( { type : 'macrocall', start : 0, params : [ { type : 'macro-parameter', start : 9, value : 'one', end : 13 }, { type : 'macro-parameter', start : 13, value : 'two', end : 17 }, { type : 'macro-parameter', start : 17, value : 'three', end : 23 } ], name : 'mymacro', end : 25 } ); - expect(parser.parseMacroInvocation("<>",0)).toEqual( + expect($tw.utils.parseMacroInvocation("<>",0)).toEqual( { type : 'macrocall', start : 0, params : [ { type : 'macro-parameter', start : 9, value : 'one', name : 'p', end : 15 }, { type : 'macro-parameter', start : 15, value : 'two', name : 'q', end : 21 }, { type : 'macro-parameter', start : 21, value : 'three', end : 27 } ], name : 'mymacro', end : 29 } ); - expect(parser.parseMacroInvocation("<>",0)).toEqual( + expect($tw.utils.parseMacroInvocation("<>",0)).toEqual( { type : 'macrocall', start : 0, params : [ { type : 'macro-parameter', start : 9, value : 'one two three', end : 25 } ], name : 'mymacro', end : 27 } ); - expect(parser.parseMacroInvocation("<>",0)).toEqual( + expect($tw.utils.parseMacroInvocation("<>",0)).toEqual( { type : 'macrocall', start : 0, params : [ { type : 'macro-parameter', start : 9, value : 'one two three', name : 'r', end : 27 } ], name : 'mymacro', end : 29 } ); - expect(parser.parseMacroInvocation("<>",0)).toEqual( + expect($tw.utils.parseMacroInvocation("<>",0)).toEqual( { type : 'macrocall', start : 0, params : [ { type : 'macro-parameter', start : 9, value : 'two', name : 'one', end : 17 }, { type : 'macro-parameter', start : 17, value : 'four and five', name : 'three', end : 39 } ], name : 'myMacro', end : 41 } ); }); it("should parse HTML attributes", function() { - expect(parser.parseAttribute("p='blah' ",1)).toEqual( + expect($tw.utils.parseAttribute("p='blah' ",1)).toEqual( null ); - expect(parser.parseAttribute("p='blah' ",0)).toEqual( + expect($tw.utils.parseAttribute("p='blah' ",0)).toEqual( { type : 'string', start : 0, name : 'p', value : 'blah', end : 8 } ); - expect(parser.parseAttribute("p=\"blah\" ",0)).toEqual( + expect($tw.utils.parseAttribute("p=\"blah\" ",0)).toEqual( { type : 'string', start : 0, name : 'p', value : 'blah', end : 8 } ); - expect(parser.parseAttribute("p=blah ",0)).toEqual( + expect($tw.utils.parseAttribute("p=blah ",0)).toEqual( { type : 'string', start : 0, name : 'p', value : 'blah', end : 6 } ); - expect(parser.parseAttribute("p =blah ",0)).toEqual( + expect($tw.utils.parseAttribute("p =blah ",0)).toEqual( { type : 'string', start : 0, name : 'p', value : 'blah', end : 7 } ); - expect(parser.parseAttribute("p= blah ",0)).toEqual( + expect($tw.utils.parseAttribute("p= blah ",0)).toEqual( { type : 'string', start : 0, name : 'p', value : 'blah', end : 7 } ); - expect(parser.parseAttribute("p = blah ",0)).toEqual( + expect($tw.utils.parseAttribute("p = blah ",0)).toEqual( { type : 'string', start : 0, name : 'p', value : 'blah', end : 8 } ); - expect(parser.parseAttribute("p = >blah ",0)).toEqual( + expect($tw.utils.parseAttribute("p = >blah ",0)).toEqual( { type : 'string', value : 'true', start : 0, name : 'p', end : 4 } ); - expect(parser.parseAttribute(" attrib1>",0)).toEqual( + expect($tw.utils.parseAttribute(" attrib1>",0)).toEqual( { type : 'string', value : 'true', start : 0, name : 'attrib1', end : 8 } ); });