| 1 |
// DATA_TEMPLATE: empty_table |
| 2 |
oTest.fnStart( "Cell invalidation" ); |
| 3 |
|
| 4 |
|
| 5 |
$(document).ready( function () { |
| 6 |
var t = $('#example').DataTable( { |
| 7 |
ajax: "../../../examples/ajax/data/arrays.txt" |
| 8 |
} ); |
| 9 |
|
| 10 |
oTest.fnWaitTest( |
| 11 |
"Cell 1 html is as expected", |
| 12 |
null, |
| 13 |
function () { return $(t.cell(':eq(0)', 0).node()).text() == 'Airi Satou'; } |
| 14 |
); |
| 15 |
|
| 16 |
oTest.fnTest( |
| 17 |
"Cell 1 data is as expected", |
| 18 |
null, |
| 19 |
function () { return t.cell(':eq(0)', 0).data() == 'Airi Satou'; } |
| 20 |
); |
| 21 |
|
| 22 |
oTest.fnTest( |
| 23 |
"Cell 2 html is as expected", |
| 24 |
null, |
| 25 |
function () { return $(t.cell(':eq(0)', 1).node()).text() == 'Accountant'; } |
| 26 |
); |
| 27 |
|
| 28 |
oTest.fnTest( |
| 29 |
"Cell 2 data is as expected", |
| 30 |
null, |
| 31 |
function () { return t.cell(':eq(0)', 1).data() == 'Accountant'; } |
| 32 |
); |
| 33 |
|
| 34 |
oTest.fnTest( |
| 35 |
"Cell 3 html is as expected", |
| 36 |
null, |
| 37 |
function () { return $(t.cell(':eq(0)', 2).node()).text() == 'Tokyo'; } |
| 38 |
); |
| 39 |
|
| 40 |
oTest.fnTest( |
| 41 |
"Cell 3 data is as expected", |
| 42 |
null, |
| 43 |
function () { return t.cell(':eq(0)', 2).data() == 'Tokyo'; } |
| 44 |
); |
| 45 |
|
| 46 |
|
| 47 |
oTest.fnTest( |
| 48 |
"Modify the HTML in cell 2 - cell data hasn't changed", |
| 49 |
function () { $('#example tbody tr:eq(0) td:eq(1)').html('html write'); }, |
| 50 |
function () { return t.cell(':eq(0)', 1).data() == 'Accountant'; } |
| 51 |
); |
| 52 |
|
| 53 |
oTest.fnTest( |
| 54 |
"Modify the data in cell 1 - html updates", |
| 55 |
function () { t.cell(':eq(0)', 0).data('allan'); }, |
| 56 |
function () { return $(t.cell(':eq(0)', 0).node()).text() == 'allan'; } |
| 57 |
); |
| 58 |
|
| 59 |
oTest.fnTest( |
| 60 |
"And cell 2's content hasn't changed", |
| 61 |
null, |
| 62 |
function () { return $(t.cell(':eq(0)', 1).node()).text() == 'html write'; } |
| 63 |
); |
| 64 |
|
| 65 |
oTest.fnTest( |
| 66 |
"And cell 2's data hasn't changed", |
| 67 |
null, |
| 68 |
function () { return t.cell(':eq(0)', 1).data() == 'Accountant'; } |
| 69 |
); |
| 70 |
|
| 71 |
|
| 72 |
oTest.fnTest( |
| 73 |
"HTML write to cell 3 - data doesn't change", |
| 74 |
function () { $('#example tbody tr:eq(0) td:eq(2)').html('lottie'); }, |
| 75 |
function () { return t.cell(':eq(0)', 2).data() == 'Tokyo'; } |
| 76 |
); |
| 77 |
|
| 78 |
oTest.fnTest( |
| 79 |
"Data invalidate cell 3 - data value written to the DOM", |
| 80 |
function () { t.cell(':eq(0)', 2).invalidate(); }, |
| 81 |
function () { return $(t.cell(':eq(0)', 2).node()).text() == 'Tokyo'; } |
| 82 |
); |
| 83 |
|
| 84 |
oTest.fnTest( |
| 85 |
"And data matches", |
| 86 |
null, |
| 87 |
function () { return t.cell(':eq(0)', 2).data() == 'Tokyo'; } |
| 88 |
); |
| 89 |
|
| 90 |
oTest.fnTest( |
| 91 |
"And cell 2's content hasn't changed", |
| 92 |
null, |
| 93 |
function () { return $(t.cell(':eq(0)', 1).node()).text() == 'html write'; } |
| 94 |
); |
| 95 |
|
| 96 |
oTest.fnTest( |
| 97 |
"And cell 2's data hasn't changed", |
| 98 |
null, |
| 99 |
function () { return t.cell(':eq(0)', 1).data() == 'Accountant'; } |
| 100 |
); |
| 101 |
|
| 102 |
|
| 103 |
oTest.fnTest( |
| 104 |
"DOM invalidate cell 2 - data has changed", |
| 105 |
function () { t.cell(':eq(0)', 1).invalidate('dom'); }, |
| 106 |
function () { return t.cell(':eq(0)', 1).data() == 'html write'; } |
| 107 |
); |
| 108 |
|
| 109 |
|
| 110 |
oTest.fnTest( |
| 111 |
"Change data directly for cell 1 - html not updated", |
| 112 |
function () { t.row(':eq(0)').data()[0] = 'archie'; }, |
| 113 |
function () { return $(t.cell(':eq(0)', 0).node()).text() == 'allan'; } |
| 114 |
); |
| 115 |
|
| 116 |
oTest.fnTest( |
| 117 |
"Data invalidate cell 1 - data written to dom", |
| 118 |
function () { t.cell(':eq(0)', 0).invalidate(); }, |
| 119 |
function () { return $(t.cell(':eq(0)', 0).node()).text() == 'archie'; } |
| 120 |
); |
| 121 |
|
| 122 |
oTest.fnTest( |
| 123 |
"Change data directly for cell 1 - again html not updated", |
| 124 |
function () { t.row(':eq(0)').data()[0] = 'lottie'; }, |
| 125 |
function () { return $(t.cell(':eq(0)', 0).node()).text() == 'archie'; } |
| 126 |
); |
| 127 |
|
| 128 |
oTest.fnTest( |
| 129 |
"HTML invalidate cell 1 - data read from HTML", |
| 130 |
function () { t.cell(':eq(0)', 0).invalidate('dom'); }, |
| 131 |
function () { return t.cell(':eq(0)', 0).data() == 'archie'; } |
| 132 |
); |
| 133 |
|
| 134 |
oTest.fnTest( |
| 135 |
"And cell content remains", |
| 136 |
null, |
| 137 |
function () { return $(t.cell(':eq(0)', 0).node()).text() == 'archie'; } |
| 138 |
); |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
oTest.fnComplete(); |
| 143 |
} ); |