Alien-GvaScript

 view release on metacpan or  search on metacpan

test/unit/grid.html  view on Meta::CPAN

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
  <head>
    <meta http-equiv="Content-Type" content='text/html; charset=iso-8859-1' />
    <link rel="stylesheet" href="../test.css" type="text/css" media="screen" charset="utf-8" />
    <link rel="stylesheet" href="../images/GvaScript.css" type="text/css" media="screen" charset="utf-8" />

    <script src="../../lib/Alien/GvaScript/lib/prototype.js" type="text/javascript"></script>
    <script src="../unittest.js" type="text/javascript"></script>
    <script src="../../lib/Alien/GvaScript/lib/GvaScript.js" type="text/javascript"></script>
    <title>GvaScript Unit Tests</title>
  </head>
  <body>
    <h1>Unit Tests :: GvaScript/grid.js </h1>
    <p>Tests for methods included in Grid</p>
    <!-- Test Log output -->
    <div id="testlog">...</div>

    <div class="wrapper" style="height:220px;">
        <div id="grid" tabindex="0"></div>
        <div id="grid_toolbar" style="height:28px"></div>
    </div>

    <textarea id="gridlog"></textarea>
    <script type="text/javascript" language="javascript" charset="iso-8859-1">
    // <![CDATA[
    new Test.Unit.Runner({
        // test initialization of Grid component
        testInit: function() { with(this) {
            var url = "resources/_grid_result.json";
            var gc = new GvaScript.Grid("my_grid", url, {
                grid_container: 'grid',
                toolbar_container: 'grid_toolbar',
                columns: [
                    {label: 'CODE',      value: 'CLE_LANGUE'},
                    {label: 'LABEL',     value: function(e) {return e.LIB_LANGUE.first()}},
                    {label: 'SYNONYMES', value: function(e) {return e.LIB_LANGUE.reject(function(e, i) {return i==0}).join(', ')}, default_value: 'n/a', width: 300},
                    {label: 'TARIF',     value: function(e) {return e.MNT_HEURE_LANGUE + ' CHF'}, css: 'red'}
                ],
                actions: [
                    {
                        label: 'grid action',
                        condition: true,
                        callback: function() {GvaScript.Grids.get('my_grid').clear('bye bye');}
                    }
                ],
                grabfocus: true,
                onEmpty: function() {
                    $('grid').update("<h3 style='color: #183E6C'>Aucune mot ne correspond aux critères ci-dessus.</h3>");
                },        
                onPing: function(target) {
                    $('gridlog').update(target.CLE_LANGUE);
                }, 
                onCancel: function() {$('gridlog').update('ESCAPE')}
            });      
            assertInstanceOf(GvaScript.Grid, gc, 'Grid Component has not been properly initialized');
            assertEqual(8, gc.limit, 'Failed to dynamically set the Grid limit based on available space.');
        }},

        // test rendering of the grid and its columns
        testCols: function() { with(this) {
            wait(1000, function() { with(this) {
                var tbl = $$('.gva-grid')[0];
                assert(tbl, 'Failed to render Grid into HTML table.');

                // test nb of rows/cols



( run in 0.715 second using v1.01-cache-2.11-cpan-119454b85a5 )