From 868df603ab45505b87a601e39f66b3891f8fabe9 Mon Sep 17 00:00:00 2001
From: Yorick Peterse <yorickpeterse@gmail.com>
Date: Wed, 3 Sep 2014 00:26:24 +0200
Subject: [PATCH] Added spec for inline JS + comments.

---
 spec/oga/xml/lexer/inline_javascript_spec.rb | 26 +++++++++++---------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/spec/oga/xml/lexer/inline_javascript_spec.rb b/spec/oga/xml/lexer/inline_javascript_spec.rb
index 381bdc8..8a510e8 100644
--- a/spec/oga/xml/lexer/inline_javascript_spec.rb
+++ b/spec/oga/xml/lexer/inline_javascript_spec.rb
@@ -3,23 +3,25 @@ require 'spec_helper'
 describe Oga::XML::Lexer do
   context 'lexing inline Javascript' do
     before do
-      @javascript = <<-EOF.strip
-(function()
-{
-  if ( some_number < 10 )
-  {
-    console.log('Hello');
-  }
-})();
-      EOF
+      @javascript = 'if ( number < 10 ) { }'
     end
 
     example 'lex inline Javascript' do
-      lex("<script>\n#{@javascript}\n</script>").should == [
+      lex("<script>#{@javascript}</script>").should == [
         [:T_ELEM_START, nil, 1],
         [:T_ELEM_NAME, 'script', 1],
-        [:T_TEXT, "\n#{@javascript}\n", 1],
-        [:T_ELEM_END, nil, 9]
+        [:T_TEXT, @javascript, 1],
+        [:T_ELEM_END, nil, 1]
+      ]
+    end
+
+    example 'lex inline Javascript containing an XML comment' do
+      lex("<script>#{@javascript}<!--foo--></script>").should == [
+        [:T_ELEM_START, nil, 1],
+        [:T_ELEM_NAME, 'script', 1],
+        [:T_TEXT, @javascript, 1],
+        [:T_ELEM_END, nil, 1],
+        [:T_COMMENT, 'foo', 1]
       ]
     end
   end