mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
tests covering token types
This commit is contained in:
@@ -1,8 +1,36 @@
|
||||
Tinytest.add("html5-tokenizer - basic", function (test) {
|
||||
|
||||
test.equal(HTML5Tokenizer.tokenize('<p>foo'),
|
||||
[ { type: 'StartTag', name: 'p', data: [] },
|
||||
{ type: 'Characters', data: 'foo' },
|
||||
{ type: 'EOF', data: 'End of File' } ]);
|
||||
var run = function (input, expectedTokens) {
|
||||
test.equal(HTML5Tokenizer.tokenize(input),
|
||||
expectedTokens);
|
||||
};
|
||||
|
||||
run('<p>foo',
|
||||
[ { type: 'StartTag', name: 'p', data: [] },
|
||||
{ type: 'Characters', data: 'foo' },
|
||||
{ type: 'EOF', data: 'End of File' } ]);
|
||||
|
||||
run('<!DOCTYPE html>',
|
||||
[ { type: 'Doctype', name: 'html', correct: true,
|
||||
publicId: null, systemId: null },
|
||||
{ type: 'EOF', data: 'End of File' } ]);
|
||||
|
||||
run('<a b c=d> </a>',
|
||||
[ { type: 'StartTag', name: 'a',
|
||||
data: [{nodeName: 'b', nodeValue: ''},
|
||||
{nodeName: 'c', nodeValue: 'd'}] },
|
||||
{ type: 'SpaceCharacters', data: ' ' },
|
||||
{ type: 'EndTag', name: 'a', data: [] },
|
||||
{ type: 'EOF', data: 'End of File' } ]);
|
||||
|
||||
run('<3',
|
||||
[{ type: 'ParseError', data: 'expected-tag-name' },
|
||||
{ type: 'Characters', data: '<' },
|
||||
{ type: 'Characters', data: '3' },
|
||||
{ type: 'EOF', data: 'End of File' } ]);
|
||||
|
||||
run('<!--foo-->',
|
||||
[{ type: 'Comment', data: 'foo' },
|
||||
{ type: 'EOF', data: 'End of File' } ]);
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user