text: /*
   * Copyright (c) 2012-2015 S-Core Co., Ltd.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *     http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  describe("inline-event-handlers", function() {
  
    var log
  
    function onComplete(reports) {
      log = []
      reports.forEach(function(report) {
        log.push(report)
      })
    }
  
    it("warns when inline event handlers are found on elements", function() {
      var html = parseHTML(''
            + '<div onresize="alert(\'bad!\')">'
            + '  <p>Foo</p>'
            + '  <p>Bar <a href="#" onclick="alert(\'bad!\')">click me</em></p>'
            + '</div>'
          )
  
      HTMLInspector.inspect({
        useRules: ["inline-event-handlers"],
        domRoot: html,
        onComplete: onComplete
      })
  
      expect(log.length).to.equal(2)
      expect(log[0].message).to.equal("An 'onresize' attribute was found in the HTML. Use external scripts for event binding instead.")
      expect(log[1].message).to.equal("An 'onclick' attribute was found in the HTML. Use external scripts for event binding instead.")
      expect(log[0].context).to.deep.equal(html)
      expect(log[1].context).to.deep.equal(html.querySelector("a"))
  
    })
  
    it("doesn't warn there are no inline event handlers", function() {
      var html = parseHTML(''
            + '<div>'
            + '  <p>Foo</p>'
            + '  <p>Bar <a href="#">click me</em></p>'
            + '</div>'
          )
  
      HTMLInspector.inspect({
        useRules: ["inline-event-handlers"],
        domRoot: html,
        onComplete: onComplete
      })
  
      expect(log.length).to.equal(0)
    })
  
  })
  