javascript - Jasmine fixtures not cleaned up, tests not independent -
i'm using jasmine unit test table column sorting functionality. issue came noticed columns in wrong order (z-a instead of a-z) after first click. used browser's debugger examine html , confirm column in fact mis-sorted. test of independence, added click end of preceding it-block, , surprisingly fixed issue. reordering tests avoid other's click worked.
this disproves the assertion "fixtures container automatically cleaned-up between tests". can verify bug or explain i'm misunderstanding?
describe('gem bootstrap_sortable_rails', function() { var header; beforeeach(function() { setfixtures('<table class="sortable"><thead><tr><th data-sortkey="0">name</th></tr></thead>' + '<tbody><tr><td data-value="harrow baptist church"><a href="/organizations/1">harrow baptist church</td></tr>' + '<tr><td data-value="human touch worldwide"><a href="/organizations/1">human touch worldwide</td></tr></tbody></table>'); header = $('th'); }); describe('when clicking on tableheader', function() { it('inserts arrow after click', function() { header.click(); expect(header.find('span')).tohaveclass('arrow'); header.click(); // added make test below pass! }); it('sorts a-z z-a', function() { header.click(); expect($('td').first()).tohavetext('harrow baptist church'); header.click(); expect($('td').first()).tohavetext('human touch worldwide') }); }); });
ruby 1.9.3, rails 3.2.14, jasmine-jquery-rails 1.5.9.
i upgraded jasmine 2.0 , jasmine-jquery-rails 2.0.2, no difference.
Comments
Post a Comment