55
66it ('can read an html file and output a tokens array ' , function () {
77 $ html = getFixture ('basic.html ' );
8- $ lexer = new Lexer ($ html );
8+ $ lexer = new Lexer ($ html );
99 expect ($ lexer ->lex ())->toHaveCount (69 );
1010});
1111
1212it ('has the same output no matter format of the input ' , function () {
1313 $ html = getFixture ('basic.html ' );
14- $ lexer = Lexer::fromString ($ html );
14+ $ lexer = Lexer::fromString ($ html );
1515 $ tokens1 = $ lexer ->lex ();
1616
1717 $ html = getFixture ('basic-scrambled.html ' );
18- $ lexer = Lexer::fromString ($ html );
18+ $ lexer = Lexer::fromString ($ html );
1919 $ tokens2 = $ lexer ->lex ();
2020 expect ($ tokens1 )->toEqual ($ tokens2 );
2121});
2222
2323it ('can read get open and closing div tags ' , function () {
2424 $ html = getFixture ('basic.html ' );
25- $ lexer = new Lexer ($ html );
25+ $ lexer = new Lexer ($ html );
2626 $ tokens = $ lexer ->lex ();
2727
2828 //Opening div tag
4242
4343it ('can read get open and closing script tags ' , function () {
4444 $ html = getFixture ('complex.html ' );
45- $ lexer = new Lexer ($ html );
45+ $ lexer = new Lexer ($ html );
4646 $ tokens = $ lexer ->lex ();
4747
4848 //Opening script tag
5858 expect ($ tokens [62 ])
5959 ->toHaveKey ('value ' , 'script ' )
6060 ->toHaveKey ('type ' , TokenType::TAG_CLOSE );
61+ });
62+
63+ it ('can handle comments ' , function () {
64+ $ lexer = Lexer::fromString (getFixture ('comments.html ' ));
65+
66+ $ tokens = $ lexer ->lex ();
67+
68+ expect ($ tokens [7 ])
69+ ->toHaveKey ('type ' , TokenType::COMMENT )
70+ ->toHaveKey ('value ' , ' title tag ' );
71+
72+ expect ($ tokens [13 ])
73+ ->toHaveKey ('type ' , TokenType::COMMENT )
74+ ->toHaveKey ('value ' , ' Body ' );
6175});
0 commit comments