OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
4 <script src="assert_selection.js"></script> | 4 <script src="assert_selection.js"></script> |
5 <div id="log"></div> | 5 <div id="log"></div> |
6 <script> | 6 <script> |
7 function checked_assert_selection(input, command, output) { | 7 function checked_assert_selection(input, command, output) { |
8 try { | 8 try { |
9 assert_selection(input, command, output); | 9 assert_selection(input, command, output); |
10 } catch (exception) { | 10 } catch (exception) { |
11 return exception.message; | 11 return exception.message; |
12 } | 12 } |
13 return 'no exception'; | 13 return 'no exception'; |
14 } | 14 } |
15 | 15 |
16 test(() => { | 16 test(() => { |
| 17 assert_selection('foo', 'noop', 'foo'); |
17 assert_selection('|foo', 'noop', '|foo'); | 18 assert_selection('|foo', 'noop', '|foo'); |
18 assert_selection('f|oo', 'noop', 'f|oo'); | 19 assert_selection('f|oo', 'noop', 'f|oo'); |
19 assert_selection('foo|', 'noop', 'foo|'); | 20 assert_selection('foo|', 'noop', 'foo|'); |
20 assert_selection('^foo|', 'noop', '^foo|'); | 21 assert_selection('^foo|', 'noop', '^foo|'); |
21 assert_selection('f^oo|', 'noop', 'f^oo|'); | 22 assert_selection('f^oo|', 'noop', 'f^oo|'); |
22 assert_selection('f^o|o', 'noop', 'f^o|o'); | 23 assert_selection('f^o|o', 'noop', 'f^o|o'); |
23 assert_selection('|foo^', 'noop', '|foo^'); | 24 assert_selection('|foo^', 'noop', '|foo^'); |
24 assert_selection( | 25 assert_selection( |
25 '|foo^', | 26 '|foo^', |
26 selection => selection.modify('extend', 'forward', 'character'), | 27 selection => selection.modify('extend', 'forward', 'character'), |
(...skipping 27 matching lines...) Expand all Loading... |
54 '<table><tbody><tr><td>foo</td></tr></tbody></table>|'); | 55 '<table><tbody><tr><td>foo</td></tr></tbody></table>|'); |
55 assert_selection( | 56 assert_selection( |
56 '^<table><tr><td>foo</td></tr></table>|', 'noop', | 57 '^<table><tr><td>foo</td></tr></table>|', 'noop', |
57 '^<table><tbody><tr><td>foo</td></tr></tbody></table>|'); | 58 '^<table><tbody><tr><td>foo</td></tr></tbody></table>|'); |
58 assert_selection( | 59 assert_selection( |
59 '|<table><tr><td>foo</td></tr></table>^', 'noop', | 60 '|<table><tr><td>foo</td></tr></table>^', 'noop', |
60 '|<table><tbody><tr><td>foo</td></tr></tbody></table>^'); | 61 '|<table><tbody><tr><td>foo</td></tr></tbody></table>^'); |
61 }, 'markers around table'); | 62 }, 'markers around table'); |
62 | 63 |
63 test(() => { | 64 test(() => { |
64 assert_equals(checked_assert_selection('foo', 'noop', 'baz'), | |
65 'You should specify caret position in "foo".'); | |
66 }, 'no marker in input'); | |
67 | |
68 test(() => { | |
69 assert_equals(checked_assert_selection('fo|o', 'noop', 'fo|o'), | 65 assert_equals(checked_assert_selection('fo|o', 'noop', 'fo|o'), |
70 'no exception'); | 66 'no exception'); |
71 }, 'no marker in output'); | 67 }, 'no marker in output'); |
72 | 68 |
73 test(() => { | 69 test(() => { |
74 assert_equals(checked_assert_selection('fo|o|', 'noop', 'foo'), | 70 assert_equals(checked_assert_selection('fo|o|', 'noop', 'foo'), |
75 'You should have at least one focus marker "|" in "fo|o|".'); | 71 'You should have at least one focus marker "|" in "fo|o|".'); |
76 }, 'multiple focus markers in input'); | 72 }, 'multiple focus markers in input'); |
77 | 73 |
78 test(() => { | 74 test(() => { |
(...skipping 24 matching lines...) Expand all Loading... |
103 test(() => { | 99 test(() => { |
104 assert_equals(checked_assert_selection('^|foo', 'noop', 'baz'), | 100 assert_equals(checked_assert_selection('^|foo', 'noop', 'baz'), |
105 'You should have focus marker and should not have anchor marker if and o
nly if selection is a caret in "^|foo".'); | 101 'You should have focus marker and should not have anchor marker if and o
nly if selection is a caret in "^|foo".'); |
106 }, 'anchor == foucs in input'); | 102 }, 'anchor == foucs in input'); |
107 | 103 |
108 test(() => { | 104 test(() => { |
109 assert_equals(checked_assert_selection('|foo', 'noop', 'b^|az'), | 105 assert_equals(checked_assert_selection('|foo', 'noop', 'b^|az'), |
110 'You should have focus marker and should not have anchor marker if and o
nly if selection is a caret in "b^|az".'); | 106 'You should have focus marker and should not have anchor marker if and o
nly if selection is a caret in "b^|az".'); |
111 }, 'anchor == foucs in output'); | 107 }, 'anchor == foucs in output'); |
112 </script> | 108 </script> |
OLD | NEW |