JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
update .gitignore
[peach-html5-editor.git] / test.coffee
index 55470ce..fabb61b 100644 (file)
@@ -26,8 +26,8 @@
 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #
-# The rest of this file was written by Jason Woofenden in 2015, and is released
-# under the terms of the CC0 license:
+# The rest of this file was written by Jason Woofenden in 2015-2016, and is
+# released under the terms of the CC0 license:
 # http://creativecommons.org/publicdomain/zero/1.0/ and into the public domain
 
 tests = [
@@ -1681,14 +1681,12 @@ tests = [
                name: "plain-text-unsafe.dat #2"
                html: "<html>\u0000<frameset></frameset>"
                errors: 4
-               #orig: expected: "| <html>\n|   <head>\n|   <frameset>\n"
-               expected: "| <html>\n|   <head>\n|   <body>\n|     \"\ufffd\"\n"
+               expected: "| <html>\n|   <head>\n|   <frameset>\n"
        }, {
                name: "plain-text-unsafe.dat #3"
                html: "<html> \u0000 <frameset></frameset>"
                errors: 4
-               # orig: expected: "| <html>\n|   <head>\n|   <frameset>\n"
-               expected: "| <html>\n|   <head>\n|   <body>\n|     \"\ufffd \"\n"
+               expected: "| <html>\n|   <head>\n|   <frameset>\n"
        }, {
                name: "plain-text-unsafe.dat #4"
                html: "<html>a\u0000a<frameset></frameset>"
@@ -7933,10 +7931,10 @@ tests = [
        }
 ]
 
-if window?.wheic?
-       wheic = window.wheic
+if typeof module isnt 'undefined' and module.exports?
+       wheic = require './parse-html.coffee'
 else
-       wheic = require './wheic.js'
+       wheic = window.wheic
 
 serialize_els = (els, prefix = '| ') ->
        ret = ''
@@ -7974,24 +7972,14 @@ serialize_els = (els, prefix = '| ') ->
                                ret += "#{prefix}UNKNOWN TAG TYPE #{el.type}"
        return ret
 
-test_results = passed: 0, failed: 0, fragment: 0, pending: 0, broken: 0
+test_results = passed: 0, failed: 0
 test_parser = (args) ->
-       if args.fragment? # hide fragment tests for now
-               test_results.fragment += 1
-               return
-       if args.name.substr(0, 20) is "pending-spec-changes" # hide for now
-               test_results.pending += 1
-               return
-       if args.html.indexOf("\u0000") > -1 and args.expected.indexOf("\ufffd") is -1
-               # these tests seem to think that \u0000 doesn't become \uffff in_body
-               test_results.broken += 1
-               return
        wheic.debug_log_reset()
        parse_errors = []
        args.error_cb = (i) ->
                parse_errors.push i
        prev_node_id = 0 # reset counter
-       parsed = wheic.parse_html args
+       parsed = wheic.parse_html args.html, args
        serialized = serialize_els parsed
        if serialized isnt args.expected
                test_results.failed += 1
@@ -8012,7 +8000,7 @@ test_parser = (args) ->
                test_results.passed += 1
                # console.log "passed \"#{args.name}\""
 test_summary = ->
-       console.log "Tests passed: #{test_results.passed}, Failed: #{test_results.failed}, fragment: #{test_results.fragment}, pending: #{test_results.pending}, broken: #{test_results.broken}"
+       console.log "Tests passed: #{test_results.passed}, Failed: #{test_results.failed}"
 
 
 next_test = 0