possibly_valid_url: allow spaces after first '/'
[conkeror/arlinius.git] / tests / simple / utils.js
blobd94bc212b58a719290317e36b015b73b6332fd18
2 require('walnut.js');
4 walnut_run({
5     test_remove_duplicates_filter_1: function () {
6         var ar = [1, 2, 3, 3];
7         assert_objects_equal(ar.filter(remove_duplicates_filter()), [1, 2, 3]);
8     },
9     test_get_home_directory_1: function () {
10         assert(get_home_directory() instanceof Ci.nsIFile);
11     },
12     test_make_uri_1: function () {
13         assert(make_uri("http://example.com/") instanceof Ci.nsIURI);
14     },
15     test_make_uri_2: function () {
16         assert(make_uri(make_file("/a/b/c")) instanceof Ci.nsIURI);
17     },
18     test_make_uri_3: function () {
19         assert_equals(make_uri(make_file("/a/b/c")).spec.substr(0,5), "file:");
20     },
21     test_splice_range_1: function () {
22         assert_objects_equal(splice_range([[1,3],[4,6],[7,10]], 2, 8),
23                              [[1,10]]);
24     }
25 });
27 walnut_run({
28     test_string_format_1: function () {
29         assert_equals(string_format("", {}),
30                       "");
31     },
32     test_string_format_2: function () {
33         assert_equals(string_format("%a", {a: 'hello'}),
34                       "hello");
35     },
36     test_string_format_3: function () {
37         assert_equals(string_format("%a%a", {a: 'hello'}),
38                       "hellohello");
39     }
40 });
43 walnut_run({
44     test_array_p_1: function () {
45         assert(array_p([]));
46     },
47     test_array_p_2: function () {
48         assert(array_p(Array()));
49     },
50     test_make_array_1: function () {
51         assert_objects_equal(make_array(undefined), []);
52     },
53     test_make_array_2: function () {
54         assert_objects_equal(make_array(null), [null]);
55     }
56 });
58 walnut_run({
59     test_possibly_valid_url_1: function () {
60         assert_not(possibly_valid_url(""));
61     },
62     test_possibly_valid_url_2: function () {
63         assert_not(possibly_valid_url("         "));
64     },
65     test_possibly_valid_url_3: function () {
66         assert(possibly_valid_url("example"));
67     },
68     test_possibly_valid_url_4: function () {
69         assert(possibly_valid_url("  example  "));
70     },
71     test_possibly_valid_url_5: function () {
72         assert_not(possibly_valid_url("example foo"));
73     },
74     test_possibly_valid_url_6: function () {
75         assert(possibly_valid_url("example/ foo"));
76     },
77     test_possibly_valid_url_7: function () {
78         assert_not(possibly_valid_url("example /foo"));
79     },
80     test_possibly_valid_url_8: function () {
81         assert(possibly_valid_url("/example foo"));
82     },
83     test_possibly_valid_url_9: function () {
84         assert(possibly_valid_url(" /example foo"));
85     },
86     test_possibly_valid_url_10: function () {
87         assert(possibly_valid_url(" ex/ample foo"));
88     },
89     test_possibly_valid_url_11: function () {
90         assert(possibly_valid_url("/"));
91     }
92 });