<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>QUnit LoadHide</title>
    <link rel="stylesheet" href="resources/qunit.css" />
  </head>

  <body>
    <div id="qunit"></div>
    <div id="qunit-fixture">
      <div style="width:600px;">
        <iframe
          src="resources/frame.content.html"
          width="100%"
          scrolling="no"
        ></iframe>
      </div>
    </div>
    <script src="resources/qunit.js"></script>
    <script src="resources/jquery.js"></script>
    <script src="../js/iframeResizer.min.js"></script>
    <script>
      'use strict'
      var msgId = '[iFrameSizerTest]:'

      function resize(size) {
        console.info('Size width:' + size)
        $('#qunit-fixture > div').width(size)
      }

      asyncTest('iFrame Resize Event', function() {
        var evtCounter = 0

        $('iframe').iFrameResize({
          //log:true,
          interval: 1000,
          heightCalculationMethod: 'max',
          resizeFrom: 'child',
          onResized: function(messageData) {
            switch ('' + ++evtCounter) {
              case '1':
                setTimeout(function() {
                  resize(300)
                }, 150)
                break
              case '2':
                setTimeout(function() {
                  resize(600)
                }, 150)
                ok(
                  'resize' === messageData.type,
                  '1 Received ' +
                    messageData.type +
                    ' message back from iFrame. Expected resize'
                )
                ok(
                  '300' === messageData.width,
                  '2 iFrame width = ' + messageData.width + '. Expected 300.'
                )
                break
              default:
                ok(
                  'resetPage' === messageData.type,
                  '3 Received ' +
                    messageData.type +
                    ' message back from iFrame. Expected resetPage'
                )
                if ('600' === messageData.width) {
                  ok(
                    '600' === messageData.width,
                    '4 iFrame width = ' + messageData.width + '. Expected 600.'
                  )
                  start()
                }
            }
          }
        })
      })
    </script>
  </body>
</html>