]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dojo/tests/string.js
add Dojo 1.1.1
[eow] / static / dojo-release-1.1.1 / dojo / tests / string.js
1 if(!dojo._hasResource["tests.string"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["tests.string"] = true;
3 dojo.provide("tests.string");
4
5 dojo.require("dojo.string");
6
7 tests.register("tests.string", 
8         [
9                 function test_string_pad(t){
10                         t.is("00001", dojo.string.pad("1", 5));
11                         t.is("000001", dojo.string.pad("000001", 5));
12                         t.is("10000", dojo.string.pad("1", 5, null, true));
13                 },
14
15                 function test_string_substitute(t){
16                         t.is("File 'foo.html' is not found in directory '/temp'.", dojo.string.substitute("File '${0}' is not found in directory '${1}'.", ["foo.html","/temp"]));
17                         t.is("File 'foo.html' is not found in directory '/temp'.", dojo.string.substitute("File '${name}' is not found in directory '${info.dir}'.", {name: "foo.html", info: {dir: "/temp"}}));
18                         // Verify that an error is thrown!
19                         t.assertError(Error, dojo.string, "substitute", ["${x}", {y:1}]);
20                 },
21                 
22                 function test_string_trim(t){
23                         t.is("astoria", dojo.string.trim("   \f\n\r\t      astoria           "));
24                         t.is("astoria", dojo.string.trim("astoria                            "));
25                         t.is("astoria", dojo.string.trim("                            astoria"));
26                         t.is("astoria", dojo.string.trim("astoria"));
27                 }
28         ]
29 );
30
31 }