<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="../../dist/jquery/jquery-1.4.2.min.js"></script>
  <script src="../../dist/jquery/jquery.ba-bbq.min.js"></script>
  <script src="../../src/o_O.js"></script>
  <script src="../../src/modules/o_O.model.js"></script>
  <script src="../../src/modules/o_O.validations.js"></script>
  <script src="../../src/drivers/jquery/adapters/o_O.dom.js"></script>
  <script src="../../src/drivers/jquery/modules/o_O.controller.js"></script>
  <script src="../../src/drivers/jquery/modules/o_O.support.js"></script>
  <script src="/tests.js"></script>
  <script src="run_all.js"></script>

  <link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />
<script type="text/javascript" src="qunit.js"></script>

  <script>

  $(document).ready(function(){
    
    o_O('Review', function(that){
      that.validates_presence_of('title');
      that.validates_presence_of('content');
      return that;
    });
    
    o_O('TestController', {
      create: function(){
        
      }
    })
    
    module("Forms");
    
    test('getting form attributes', function(){
      equals(o_O.params_from_form($('form#test-form')).title, 'Biscuit', 'form attributes should come in nicely')
      equals(o_O.params_from_form($('form#test-form')).selection, "1", 'should work with checkboxes')
      equals(o_O.params_from_form($('form#test-form')).thing['title'], "Thing's Title", 'should work with checkboxes')
    });
    
    test('params should be empty', function(){
      equals(typeof o_O.params(), 'object')
    })
    
    test('setting a param', function(){
      o_O.params('thing', 'new value')
      equals(o_O.params('thing'), 'new value')
    })
    
    test('submitting a form', function(){
      $("form#test-form").trigger('submit')
      equals(o_O.params('title'), 'Biscuit');
      equals(o_O.params('thing')['title'], "Thing's Title");
    })

  });
  </script>
  
</head>
<body>
  <h1 id="qunit-header">Form Tests</h1>
 <h2 id="qunit-banner"></h2>
 <h2 id="qunit-userAgent"></h2>
 <ol id="qunit-tests"></ol>
 <form id="test-form" data-bind="test#create">
  <input type="text" name="title" type="text" value="Biscuit">
  <input type="radio" name="selection" value="1" checked>
  <input type="radio" name="selection" value="-1">
  <input type="text" name="thing[title]" value="Thing's Title"></input>
 </form>
</body>
</html>