Release as 1.0.4
[conkeror.git] / tests / simple / completers.js
blob7c73f0b5073136fc1b08ee79301d6ba070bff75f
2 require("walnut");
4 walnut_run({
5     suite_setup: function () {
6         this.completer = new all_word_completer(
7             $completions = ["the quick brown fox",
8                             "jumped over",
9                             "the lazy dog's tail"]);
10     },
11     test_all_word_completer_1: function () {
12         var completions = this.completer.complete("he", 2, false);
13         assert_equals(completions.count, 2);
14         assert_equals(completions.get_value(0), "the quick brown fox");
15         assert_equals(completions.get_value(1), "the lazy dog's tail");
16     },
17     test_all_word_completer_2: function () {
18         var completions = this.completer.complete("ic he", 2, false);
19         assert_equals(completions.count, 1);
20         assert_equals(completions.get_value(0), "the quick brown fox");
21     }
22 });
24 walnut_run({
25     suite_setup: function () {
26         this.completer = new prefix_completer(
27             $completions = ["the quick brown fox",
28                             "jumped over",
29                             "the lazy dog's tail"]);
30     },
31     test_prefix_completer_1: function () {
32         var completions = this.completer.complete("the", 2, false);
33         assert_equals(completions.count, 2);
34         assert_equals(completions.get_value(0), "the lazy dog's tail");
35         assert_equals(completions.get_value(1), "the quick brown fox");
36     }
37 });
39 walnut_run({
40     suite_setup: function () {
41         var scope = { a: 1,
42                       b: 2,
43                       c: 3,
44                       foo: 4,
45                       bar: 5,
46                       baz: 6,
47                       quux: 7 };
48         this.completer = new javascript_completer(scope);
49     },
50     test_javascript_completer_1: function () {
51         var completions = this.completer.complete("a", 1, false);
52         assert_equals(completions.count, 1);
53     },
54     test_javascript_completer_2: function () {
55         var completions = this.completer.complete("b", 1, false);
56         assert_equals(completions.count, 3);
57     },
58     test_javascript_completer_3: function () {
59         var completions = this.completer.complete("ba", 2, false);
60         assert_equals(completions.count, 2);
61     }
62 });