diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2011-06-26 22:41:31 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2011-06-26 22:41:31 -0400 |
commit | 73027f06a42d6d3c10aec4fa8cc0c070c0981fe2 (patch) | |
tree | 0cf6a3784dc00c11b40fcb1f20b3bace1f646d49 /test/js | |
parent | f1cca3a1da7c87b48583e871bf8770fe6df4d3f2 (diff) | |
download | python-coveragepy-git-73027f06a42d6d3c10aec4fa8cc0c070c0981fe2.tar.gz |
HTML report hotkeys work differently if the current chunk is off-screen. A chunk on-screen will be selected next.
Diffstat (limited to 'test/js')
-rw-r--r-- | test/js/tests.js | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/test/js/tests.js b/test/js/tests.js index 3c04e075..73b4ce2b 100644 --- a/test/js/tests.js +++ b/test/js/tests.js @@ -1,13 +1,19 @@ // Tests of coverage.py HTML report chunk navigation. -/* global: coverage, test, module, equals, jQuery, $ */ +/*global coverage, test, module, equals, jQuery, $ */ // Test helpers function selection_is(sel) { + raw_selection_is(sel, true); +} + +function raw_selection_is(sel, check_highlight) { var beg = sel[0], end = sel[1]; equals(coverage.sel_begin, beg); equals(coverage.sel_end, end); - equals(coverage.code_container().find(".highlight").length, end-beg); + if (check_highlight) { + equals(coverage.code_container().find(".highlight").length, end-beg); + } } function build_fixture(spec) { @@ -161,3 +167,38 @@ test("Jump from a line selected", function () { coverage.to_next_chunk(); selection_is([5,7]); }); + +// Tests of select_line_or_chunk. + +$.each([ + // The data for each test: a spec for the fixture to build, and an array + // of the selection that will be selected by select_line_or_chunk for + // each line in the fixture. + ['rrwwrr', [[1,3], [1,3], [3,4], [4,5], [5,7], [5,7]]], + ['rb', [[1,2], [2,3]]], + ['r', [[1,2]]], + ['w', [[1,2]]], + ['www', [[1,2], [2,3], [3,4]]], + ['wwwrrr', [[1,2], [2,3], [3,4], [4,7], [4,7], [4,7]]], + ['rrrwww', [[1,4], [1,4], [1,4], [4,5], [5,6], [6,7]]], + ['rrrbbb', [[1,4], [1,4], [1,4], [4,7], [4,7], [4,7]]] +], function (i, params) { + + // Each of these tests uses a fixture with two highlighted chunks. + var id = params[0]; + var sels = params[1]; + + module("Select line or chunk - " + id, { + setup: function () { + build_fixture(id); + } + }); + + $.each(sels, function (i, sel) { + i++; + test("Select line " + i, function () { + coverage.select_line_or_chunk(i); + raw_selection_is(sel); + }); + }); +}); |