1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-09 09:56:40 +02:00

Added unit tests

This commit is contained in:
Max Guglielmi 2016-05-07 19:20:42 +10:00
parent 9a694ba263
commit 4965cd5360
10 changed files with 608 additions and 10 deletions

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.2.19 by Max Guglielmi
* build date: 2016-05-07T03:25:36.873Z
* build date: 2016-05-07T09:17:18.517Z
* MIT License
*/
span.colVisSpan{text-align:left;}span.colVisSpan a.colVis{display:inline-block;padding:7px 5px 0;font-size:inherit;font-weight:inherit;vertical-align:top}div.colVisCont{position:relative;background:#fff;-webkit-box-shadow:3px 3px 2px #888;-moz-box-shadow:3px 3px 2px #888;box-shadow:3px 3px 2px #888;position:absolute;display:none;border:1px solid #ccc;height:auto;width:250px;background-color:#fff;margin:35px 0 0 -100px;z-index:10000;padding:10px 10px 10px 10px;text-align:left;font-size:12px;}div.colVisCont:after,div.colVisCont:before{bottom:100%;left:50%;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none}div.colVisCont:after{border-color:rgba(255,255,255,0);border-bottom-color:#fff;border-width:10px;margin-left:-10px}div.colVisCont:before{border-color:rgba(255,255,255,0);border-bottom-color:#ccc;border-width:12px;margin-left:-12px}div.colVisCont p{margin:6px auto 6px auto}div.colVisCont a.colVis{display:initial;font-weight:inherit}ul.cols_checklist{padding:0;margin:0;list-style:none;}ul.cols_checklist label{display:block}ul.cols_checklist input{vertical-align:middle;margin:2px 5px 2px 1px}li.cols_checklist_item{padding:4px;margin:0;}li.cols_checklist_item:hover{background-color:#335ea8;color:#fff}.cols_checklist_slc_item{background-color:#335ea8;color:#fff}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.2.19 by Max Guglielmi
* build date: 2016-05-07T03:25:36.873Z
* build date: 2016-05-07T09:17:18.517Z
* MIT License
*/
span.expClpFlt a.btnExpClpFlt{width:35px;height:35px;display:inline-block;}span.expClpFlt a.btnExpClpFlt:hover{background-color:#f4f4f4}span.expClpFlt img{padding:8px 11px 11px 11px}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.2.19 by Max Guglielmi
* build date: 2016-05-07T03:25:36.873Z
* build date: 2016-05-07T09:17:18.517Z
* MIT License
*/
.activeHeader{background-color:#66afe9 !important;color:#fff !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.2.19 by Max Guglielmi
* build date: 2016-05-07T03:25:36.873Z
* build date: 2016-05-07T09:17:18.517Z
* MIT License
*/
table.TF{border-left:1px solid #ccc;border-top:none;border-right:none;border-bottom:none;}table.TF th{background:#ebecee url("images/bg_th.jpg") left top repeat-x;border-bottom:1px solid #d0d0d0;border-right:1px solid #d0d0d0;border-left:1px solid #fff;border-top:1px solid #fff;color:#333}table.TF td{border-bottom:1px dotted #999;padding:5px}.fltrow{background-color:#ebecee !important;}.fltrow th,.fltrow td{border-bottom:1px dotted #666 !important;padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #999 !important}input.flt{width:99% !important}.inf{height:$min-height;background:#d7d7d7 url("images/bg_infDiv.jpg") 0 0 repeat-x !important}input.reset{background:transparent url("images/btn_eraser.gif") center center no-repeat !important}.helpBtn:hover{background-color:transparent}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important;}.nextPage:hover{background:transparent url("images/btn_over_next_page.gif") center center no-repeat !important}.previousPage{background:transparent url("images/btn_previous_page.gif") center center no-repeat !important;}.previousPage:hover{background:transparent url("images/btn_over_previous_page.gif") center center no-repeat !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important;}.firstPage:hover{background:transparent url("images/btn_over_first_page.gif") center center no-repeat !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important;}.lastPage:hover{background:transparent url("images/btn_over_last_page.gif") center center no-repeat !important}div.grd_Cont{background-color:#ebecee !important;border:1px solid #ccc !important;padding:0 !important;}div.grd_Cont .even{background-color:#fff}div.grd_Cont .odd{background-color:#d5d5d5}div.grd_headTblCont{background-color:#ebecee !important;border-bottom:none !important;}div.grd_headTblCont table{border-right:none !important}div.grd_tblCont table th,div.grd_headTblCont table th,div.grd_headTblCont table td{background:#ebecee url("images/bg_th.jpg") left top repeat-x !important;border-bottom:1px solid #d0d0d0 !important;border-right:1px solid #d0d0d0 !important;border-left:1px solid #fff !important;border-top:1px solid #fff !important}div.grd_tblCont table td{border-bottom:1px solid #999 !important}.grd_inf{background:#d7d7d7 url("images/bg_infDiv.jpg") 0 0 repeat-x !important;border-top:1px solid #d0d0d0 !important}.loader{border:1px solid #999}.defaultLoader{width:32px;height:32px;background:transparent url("images/img_loading.gif") 0 0 no-repeat !important}.even{background-color:#fff}.odd{background-color:#d5d5d5}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.activeHeader{background:#999 !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.2.19 by Max Guglielmi
* build date: 2016-05-07T03:25:36.873Z
* build date: 2016-05-07T09:17:18.517Z
* MIT License
*/
table.TF{border-left:1px dotted #81963b;border-top:none;border-right:0;border-bottom:none;}table.TF th{background:#39424b url("images/bg_headers.jpg") left top repeat-x;border-bottom:0;border-right:1px dotted #d0d0d0;border-left:0;border-top:0;color:#fff}table.TF td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b;padding:5px}.fltrow{background-color:#81963b !important;}.fltrow th,.fltrow td{border-bottom:1px dotted #39424b !important;border-right:1px dotted #fff !important;border-left:0 !important;border-top:0 !important;padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #687830 !important}input.flt{width:99% !important}.inf{background:#d8d8d8;height:$min-height}input.reset{width:53px;background:transparent url("images/btn_filter.png") center center no-repeat !important}.helpBtn:hover{background-color:transparent}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important}.previousPage{background:transparent url("images/btn_previous_page.gif") center center no-repeat !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important}div.grd_Cont{background:#81963b url("images/bg_headers.jpg") left top repeat-x !important;border:1px solid #ccc !important;padding:0 1px 1px 1px !important;}div.grd_Cont .even{background-color:#bccd83}div.grd_Cont .odd{background-color:#fff}div.grd_headTblCont{background-color:#ebecee !important;border-bottom:none !important}div.grd_tblCont table{border-right:none !important;}div.grd_tblCont table td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b}div.grd_tblCont table th,div.grd_headTblCont table th{background:transparent url("images/bg_headers.jpg") 0 0 repeat-x !important;border-bottom:0 !important;border-right:1px dotted #d0d0d0 !important;border-left:0 !important;border-top:0 !important;padding:0 4px 0 4px !important;color:#fff !important;height:35px !important}div.grd_headTblCont table td{border-bottom:1px dotted #39424b !important;border-right:1px dotted #fff !important;border-left:0 !important;border-top:0 !important;background-color:#81963b !important;padding:1px 3px 1px 3px !important}.grd_inf{background-color:#d8d8d8;border-top:1px solid #d0d0d0 !important}.loader{border:0 !important;background:#81963b !important}.defaultLoader{width:32px;height:32px;background:transparent url("images/img_loading.gif") 0 0 no-repeat !important}.even{background-color:#bccd83}.odd{background-color:#fff}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.activeHeader{background:#81963b !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.2.19 by Max Guglielmi
* build date: 2016-05-07T03:25:36.873Z
* build date: 2016-05-07T09:17:18.517Z
* MIT License
*/
table.TF{padding:0;color:#000;border-right:1px solid #a4bed4;border-top:1px solid #a4bed4;border-left:1px solid #a4bed4;border-bottom:0;}table.TF th{margin:0;color:inherit;background:#d1e5fe url("images/bg_skyblue.gif") 0 0 repeat-x;border-color:#fdfdfd #a4bed4 #a4bed4 #fdfdfd;border-width:1px;border-style:solid}table.TF td{margin:0;padding:5px;color:inherit;border-bottom:1px solid #a4bed4;border-left:0;border-top:0;border-right:0}.fltrow{background-color:#d1e5fe !important;}.fltrow th,.fltrow td{padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #a4bed4 !important}input.flt{width:99% !important}.inf{background-color:#e3efff !important;border:1px solid #a4bed4;height:$min-height;color:#004a6f}div.tot,div.status{border-right:0 !important}.helpBtn:hover{background-color:transparent}input.reset{background:transparent url("images/icn_clear_filters.png") center center no-repeat !important}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.nextPage:hover{background:#ffe4ab url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.previousPage{background:transparent url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.previousPage:hover{background:#ffe4ab url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.firstPage:hover{background:#ffe4ab url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.lastPage:hover{background:#ffe4ab url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.activeHeader{background:#ffe4ab !important;border:1px solid #ffb552 !important;color:inherit !important}div.grd_Cont{background-color:#d9eaed !important;border:1px solid #9cc !important;padding:0 !important;}div.grd_Cont .even{background-color:#fff}div.grd_Cont .odd{background-color:#e3efff}div.grd_headTblCont{background-color:#d9eaed !important;border-bottom:none !important}div.grd_tblCont table{border-right:none !important}div.grd_tblCont table th,div.grd_headTblCont table th,div.grd_headTblCont table td{background:#d9eaed url("images/bg_skyblue.gif") left top repeat-x;border-bottom:1px solid #a4bed4;border-right:1px solid #a4bed4 !important;border-left:1px solid #fff !important;border-top:1px solid #fff !important}div.grd_tblCont table td{border-bottom:1px solid #a4bed4 !important;border-right:0 !important;border-left:0 !important;border-top:0 !important}.grd_inf{background-color:#cce2fe;color:#004a6f;border-top:1px solid #9cc !important;}.grd_inf a{text-decoration:none;font-weight:bold}.loader{background-color:#2d8eef;border:1px solid #cce2fe;border-radius:5px}.even{background-color:#fff}.odd{background-color:#e3efff}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.ezActiveRow{background-color:#ffdc61 !important;color:inherit}.ezSelectedRow{background-color:#ffe4ab !important;color:inherit}.ezActiveCell{background-color:#fff !important;color:#000 !important;font-weight:bold}.ezETSelectedCell{background-color:#fff !important;font-weight:bold;color:#000 !important}

View file

@ -482,8 +482,7 @@ return /******/ (function(modules) { // webpackBootstrap
/*** data types ***/
//defines default date type (european DMY)
this.defaultDateType = f.default_date_type || 'DMY';
//defines default thousands separator
//US = ',' EU = '.'
//defines default thousands separator US = ',' EU = '.'
this.thousandsSeparator = f.thousands_separator || ',';
//defines default decimal separator
//US & javascript = '.' EU = ','

View file

@ -339,8 +339,7 @@ export class TableFilter {
/*** data types ***/
//defines default date type (european DMY)
this.defaultDateType = f.default_date_type || 'DMY';
//defines default thousands separator
//US = ',' EU = '.'
//defines default thousands separator US = ',' EU = '.'
this.thousandsSeparator = f.thousands_separator || ',';
//defines default decimal separator
//US & javascript = '.' EU = ','

356
test/test-data-types.html Normal file
View file

@ -0,0 +1,356 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>TableFilter filter data types tests</title>
<link rel="stylesheet" href="libs/qunit/qunit.css">
<script src="libs/qunit/qunit.js"></script>
<script src="libs/polyfill.js"></script>
</head>
<body>
<table id="demo">
<thead>
<tr>
<th>Email</th>
<th>Id</th>
<th>Phone</th>
<th>&euro;</th>
<th>US $</th>
<th>Url</th>
<th>EU Date</th>
<th>US Date</th>
<th>DD-MMM-YYYY Date</th>
<th>IP</th>
</tr>
</thead>
<tbody>
<tr>
<td>devo@flexomat.com</td>
<td>66672</td>
<td>941-964-8535</td>
<td>
<div align="right">2.482,79</div>
</td>
<td>
<div align="right">2,482.79</div>
</td>
<td>http://gmail.com</td>
<td>14/12/1988</td>
<td>12/14/1988</td>
<td>14-Dec-1988</td>
<td>186.114.137.213</td>
</tr>
<tr>
<td>henry@mountdev.net</td>
<td>35889</td>
<td>941-964-9543</td>
<td>
<div align="right">2.776,09</div>
</td>
<td>
<div align="right">2,776.09</div>
</td>
<td>http://www.gmail.com</td>
<td>19/1/1984</td>
<td>1/19/1984</td>
<td>19-Jan-1984</td>
<td>170.138.54.12</td>
</tr>
<tr>
<td>christian@reno.gov</td>
<td>60021</td>
<td>941-964-5617</td>
<td>
<div align="right">2.743,41</div>
</td>
<td>
<div align="right">2,743.41</div>
</td>
<td>http://www.dotnet.ca</td>
<td>25/3/2000</td>
<td>3/25/2000</td>
<td>25-Mar-2000</td>
<td>219.115.156.141</td>
</tr>
<tr>
<td>muffins@donuts.com</td>
<td>17927</td>
<td>941-964-9511</td>
<td>
<div align="right">2.998,18</div>
</td>
<td>
<div align="right">2,998.18</div>
</td>
<td>http://google.se</td>
<td>24/1/1993</td>
<td>1/24/1993</td>
<td>24-Jan-1993</td>
<td>252.253.244.189</td>
</tr>
<tr>
<td>muffins@reno.gov</td>
<td>76375</td>
<td>941-964-2757</td>
<td>
<div align="right">1.836,09</div>
</td>
<td>
<div align="right">1,836.09</div>
</td>
<td>http://www.samba.org</td>
<td>4/4/1988</td>
<td>4/4/1988</td>
<td>4-Apr-1988</td>
<td>88.233.9.89</td>
</tr>
<tr>
<td>mendez@gmail.com</td>
<td>45834</td>
<td>941-964-2575</td>
<td>
<div align="right">2.805,46</div>
</td>
<td>
<div align="right">2,805.46</div>
</td>
<td>http://flexomat.com</td>
<td>12/12/1985</td>
<td>12/12/1985</td>
<td>12-Dec-1985</td>
<td>88.233.9.89</td>
</tr>
<tr>
<td>dev@gmail.com</td>
<td>20022</td>
<td>941-964-4967</td>
<td>
<div align="right">3.296,54</div>
</td>
<td>
<div align="right">3,296.54</div>
</td>
<td>http://www.flexomat.com</td>
<td>3/7/2002</td>
<td>7/3/2002</td>
<td>3-Jul-2002</td>
<td>219.115.156.145</td>
</tr>
<tr>
<td>foo@polyester.se</td>
<td>55987</td>
<td>941-964-745</td>
<td>
<div align="right">2.953,73</div>
</td>
<td>
<div align="right">2,953.73</div>
</td>
<td>http://www.donuts.com</td>
<td>4/8/1987</td>
<td>8/4/1987</td>
<td>4-Aug-1987</td>
<td>88.233.9.87</td>
</tr>
<tr>
<td>adam@aftonbladet.se</td>
<td>38867</td>
<td>941-964-6302</td>
<td>
<div align="right">1.949,27</div>
</td>
<td>
<div align="right">1,949.27</div>
</td>
<td>http://flexomat.com</td>
<td>27/7/1995</td>
<td>7/27/1995</td>
<td>27-Jul-1995</td>
<td>170.138.54.16</td>
</tr>
<tr>
<td>devo@donuts.com</td>
<td>51426</td>
<td>941-964-1234</td>
<td>
<div align="right">1.067,00</div>
</td>
<td>
<div align="right">1,067.00</div>
</td>
<td>http://www.polyester.se</td>
<td>5/1/1986</td>
<td>1/5/1986</td>
<td>5-Jan-1986</td>
<td>252.253.244.186</td>
</tr>
<tr>
<td>henry@samba.org</td>
<td>40859</td>
<td>941-964-4856</td>
<td>
<div align="right">3.401,19</div>
</td>
<td>
<div align="right">3,401.19</div>
</td>
<td>http://www.flexomat.com</td>
<td>7/3/1990</td>
<td>3/7/1990</td>
<td>7-Mar-1990</td>
<td>88.233.9.85</td>
</tr>
<tr>
<td>found@dotnet.ca</td>
<td>23986</td>
<td>941-964-2686</td>
<td>
<div align="right">1.393,52</div>
</td>
<td>
<div align="right">1,393.52</div>
</td>
<td>http://lostnfound.org</td>
<td>22/7/1993</td>
<td>7/22/1993</td>
<td>22-Jul-1993</td>
<td>113.231.1.44</td>
</tr>
<tr>
<td>carl@fish.org</td>
<td>73392</td>
<td>941-964-5792</td>
<td>
<div align="right">3.876,04</div>
</td>
<td>
<div align="right">3,876.04</div>
</td>
<td>http://www.google.se</td>
<td>14/7/1984</td>
<td>7/14/1984</td>
<td>14-Jul-1984</td>
<td>219.115.156.137</td>
</tr>
<tr>
<td>found@mountdev.net</td>
<td>03519</td>
<td>941-964-1599</td>
<td>
<div align="right">1.176,48</div>
</td>
<td>
<div align="right">1,176.48</div>
</td>
<td>http://donuts.com</td>
<td>6/8/2000</td>
<td>8/6/2000</td>
<td>6-Aug-2000</td>
<td>88.233.9.86</td>
</tr>
<tr>
<td>lost@fish.org</td>
<td>36628</td>
<td>941-964-5985</td>
<td>
<div align="right">822,23</div>
</td>
<td>
<div align="right">822.23</div>
</td>
<td>http://www.gmail.com</td>
<td>14/7/1994</td>
<td>7/14/1994</td>
<td>14-Jul-1994</td>
<td>252.253.244.184</td>
</tr>
<tr>
<td>mendez@dotnet.ca</td>
<td>90442</td>
<td>941-964-1649</td>
<td>
<div align="right">1.985,72</div>
</td>
<td>
<div align="right">1,975.72</div>
</td>
<td>http://reno.gov</td>
<td>20/10/1997</td>
<td>10/20/1997</td>
<td>20-Oct-1997</td>
<td>113.231.1.79</td>
</tr>
<tr>
<td>carl@donuts.com</td>
<td>00412</td>
<td>941-964-6432</td>
<td>
<div align="right">1.834,77</div>
</td>
<td>
<div align="right">1,834.77</div>
</td>
<td>http://gmail.com</td>
<td>23/8/1997</td>
<td>8/23/1997</td>
<td>23-Aug-1997</td>
<td>170.138.54.19</td>
</tr>
<tr>
<td>foo@fish.org</td>
<td>80653</td>
<td>941-964-1022</td>
<td>
<div align="right">260,26</div>
</td>
<td>
<div align="right">260.26</div>
</td>
<td>http://samba.org</td>
<td>24/11/1991</td>
<td>11/24/1991</td>
<td>24-Nov-1991</td>
<td>88.233.9.89</td>
</tr>
<tr>
<td>found@fish.org</td>
<td>54635</td>
<td>941-964-6439</td>
<td>
<div align="right">1.442,80</div>
</td>
<td>
<div align="right">1,442.80</div>
</td>
<td>http://dotnet.ca</td>
<td>12/7/1987</td>
<td>7/12/1987</td>
<td>12-Jul-1987</td>
<td>88.233.9.90</td>
</tr>
<tr>
<td>found@flexomat.com</td>
<td>20953</td>
<td>941-964-5544</td>
<td>
<div align="right">575,42</div>
</td>
<td>
<div align="right">575.42</div>
</td>
<td>http://gmail.com</td>
<td>10/6/1988</td>
<td>6/10/1988</td>
<td>10-Jun-1988</td>
<td>88.233.19.89</td>
</tr>
</tbody>
</table>
<script src="../dist/tablefilter/tablefilter.js"></script>
<script src="test-data-types.js"></script>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>

244
test/test-data-types.js Normal file
View file

@ -0,0 +1,244 @@
(function(win, TableFilter){
// TODO: add sort to test it with different column types
var tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
col_number_format: [
null, null, null,
'EU', 'US', null,
null, null, null,
'IpAddress'
],
col_date_type: [
null, null, null,
null, null, null,
'dmy', 'mdy', 'ddmmmyyyy',
null
]
});
tf.init();
window.tf = tf;
module('Sanity checks');
test('Data types', function() {
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.hasColNbFormat, true, 'Has number column types');
deepEqual(tf.hasColDateType, true, 'Has date column tyoes');
});
module('Data types filtering');
test('Can filter a column with a string', function() {
// act
tf.setFilterValue(0, 'carl');
tf.filter();
// assert
deepEqual(tf.getValidRows(), [14, 18], 'Expected rows');
});
test('Can filter a EU formatted number', function() {
// setup
tf.clearFilters();
// act
tf.setFilterValue(3, '1.836,09');
tf.filter();
// assert
deepEqual(tf.getValidRows(), [6], 'Expected rows');
});
test('Can filter a EU formatted number column with a number', function() {
// setup
tf.clearFilters();
// act
tf.setFilterValue(3, 3876);
tf.filter();
// assert
deepEqual(tf.getValidRows(), [14], 'Expected rows');
});
test('Can filter a EU formatted number column with a number without ' +
'thousands separator', function() {
// setup
tf.clearFilters();
// act
tf.setFilterValue(3, '1393,52');
tf.filter();
// assert
deepEqual(tf.getValidRows(), [13], 'Expected rows');
});
test('Can filter a EU formatted number column with a number without ' +
'decimals', function() {
// setup
tf.clearFilters();
// act
tf.setFilterValue(3, '2.805');
tf.filter();
// assert
deepEqual(tf.getValidRows(), [7], 'Expected rows');
});
test('Can filter a US formatted number', function() {
// setup
tf.clearFilters();
// act
tf.setFilterValue(4, '1,836.09');
tf.filter();
// assert
deepEqual(tf.getValidRows(), [6], 'Expected rows');
});
test('Can filter a US formatted number column with a number', function() {
// setup
tf.clearFilters();
// act
tf.setFilterValue(4, 3876);
tf.filter();
// assert
deepEqual(tf.getValidRows(), [14], 'Expected rows');
});
test('Can filter a US formatted number column with a number without ' +
'thousands separator', function() {
// setup
tf.clearFilters();
// act
tf.setFilterValue(4, '1393.52');
tf.filter();
// assert
deepEqual(tf.getValidRows(), [13], 'Expected rows');
});
test('Can filter a US formatted number column with a number without ' +
'decimals', function() {
// setup
tf.clearFilters();
// act
tf.setFilterValue(4, '2,805');
tf.filter();
// assert
deepEqual(tf.getValidRows(), [7], 'Expected rows');
});
test('Can filter a EU formatted date column', function() {
// setup
tf.clearFilters();
// act
tf.setFilterValue(6, '14/7/1994');
tf.filter();
// assert
deepEqual(tf.getValidRows(), [16], 'Expected rows');
});
test('Can filter a EU formatted date column with different date separator',
function() {
// setup
tf.clearFilters();
// act
tf.setFilterValue(6, '20-10-97');
tf.filter();
// assert
deepEqual(tf.getValidRows(), [17], 'Expected rows');
});
test('Can filter a US formatted date column', function() {
// setup
tf.clearFilters();
// act
tf.setFilterValue(7, '7/14/1994');
tf.filter();
// assert
deepEqual(tf.getValidRows(), [16], 'Expected rows');
});
test('Can filter a US formatted date column with different date separator',
function() {
// setup
tf.clearFilters();
// act
tf.setFilterValue(7, '10-20-97');
tf.filter();
// assert
deepEqual(tf.getValidRows(), [17], 'Expected rows');
});
test('Can filter a dd-MMM-yyy formatted date column', function() {
// setup
tf.clearFilters();
// act
tf.setFilterValue(8, '3-Jul-2002');
tf.filter();
// assert
deepEqual(tf.getValidRows(), [8], 'Expected rows');
});
test('Can filter a dd-MMM-yyy formatted date column with different date ' +
'separator', function() {
// setup
tf.clearFilters();
// act
tf.setFilterValue(8, '25.Mar.2000');
tf.filter();
// assert
deepEqual(tf.getValidRows(), [4], 'Expected rows');
});
test('Can filter an IP address column', function() {
// setup
tf.clearFilters();
// act
tf.setFilterValue(9, '219.115.156.145');
tf.filter();
// assert
deepEqual(tf.getValidRows(), [8], 'Expected rows');
});
test('Can filter an IP address column with a truncated IP address',
function() {
// setup
tf.clearFilters();
// act
tf.setFilterValue(9, '219.115.15');
tf.filter();
// assert
deepEqual(tf.getValidRows(), [4, 8, 14], 'Expected rows');
});
// module('Tear-down');
// test('can destroy TableFilter DOM elements', function() {
// tf.destroy();
// deepEqual(tf.hasGrid(), false, 'Filters removed');
// });
})(window, TableFilter);