dff0bca5bf90f8dab47f8a23e30913706042231d.svn-base 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. if (!dojo._hasResource["tests.string"]) { // _hasResource checks added by
  2. // build. Do not use _hasResource
  3. // directly in your code.
  4. dojo._hasResource["tests.string"] = true;
  5. dojo.provide("tests.string");
  6. dojo.require("dojo.string");
  7. tests.register("tests.string", [function test_string_pad(t) {
  8. t.is("00001", dojo.string.pad("1", 5));
  9. t.is("000001", dojo.string.pad("000001", 5));
  10. t.is("10000", dojo.string.pad("1", 5, null, true));
  11. },
  12. function test_string_substitute(t) {
  13. t
  14. .is(
  15. "File 'foo.html' is not found in directory '/temp'.",
  16. dojo.string
  17. .substitute(
  18. "File '${0}' is not found in directory '${1}'.",
  19. ["foo.html", "/temp"]));
  20. t
  21. .is(
  22. "File 'foo.html' is not found in directory '/temp'.",
  23. dojo.string
  24. .substitute(
  25. "File '${name}' is not found in directory '${info.dir}'.",
  26. {
  27. name : "foo.html",
  28. info : {
  29. dir : "/temp"
  30. }
  31. }));
  32. // Verify that an error is thrown!
  33. t.assertError(Error, dojo.string, "substitute", ["${x}", {
  34. y : 1
  35. }]);
  36. },
  37. function test_string_trim(t) {
  38. t.is("astoria", dojo.string
  39. .trim(" \f\n\r\t astoria "));
  40. t.is("astoria", dojo.string
  41. .trim("astoria "));
  42. t.is("astoria", dojo.string
  43. .trim(" astoria"));
  44. t.is("astoria", dojo.string.trim("astoria"));
  45. }]);
  46. }