4f985a721e2d7eb460097e919451f4d578e2c6bf.svn-base 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. if (!dojo._hasResource["tests.AdapterRegistry"]) { // _hasResource checks added
  2. // by build. Do not use
  3. // _hasResource directly in
  4. // your code.
  5. dojo._hasResource["tests.AdapterRegistry"] = true;
  6. dojo.provide("tests.AdapterRegistry");
  7. dojo.require("dojo.AdapterRegistry");
  8. doh.register("tests.AdapterRegistry", [function ctor(t) {
  9. var taa = new dojo.AdapterRegistry();
  10. t.is(0, taa.pairs.length);
  11. t.f(taa.returnWrappers);
  12. var taa = new dojo.AdapterRegistry(true);
  13. t.t(taa.returnWrappers);
  14. },
  15. function register(t) {
  16. var taa = new dojo.AdapterRegistry();
  17. taa.register("blah", function(str) {
  18. return str == "blah";
  19. }, function() {
  20. return "blah";
  21. });
  22. t.is(1, taa.pairs.length);
  23. t.is("blah", taa.pairs[0][0]);
  24. taa.register("thinger");
  25. taa.register("prepend", null, null, true, true);
  26. t.is("prepend", taa.pairs[0][0]);
  27. t.t(taa.pairs[0][3]);
  28. },
  29. /*
  30. * function match(t){ },
  31. */
  32. function noMatch(t) {
  33. var taa = new dojo.AdapterRegistry();
  34. var threw = false;
  35. try {
  36. taa.match("blah");
  37. } catch (e) {
  38. threw = true;
  39. }
  40. t.t(threw);
  41. },
  42. function returnWrappers(t) {
  43. var taa = new dojo.AdapterRegistry();
  44. taa.register("blah", function(str) {
  45. return str == "blah";
  46. }, function() {
  47. return "blah";
  48. });
  49. t.is("blah", taa.match("blah"));
  50. taa.returnWrappers = true;
  51. t.is("blah", taa.match("blah")());
  52. },
  53. function unregister(t) {
  54. var taa = new dojo.AdapterRegistry();
  55. taa.register("blah", function(str) {
  56. return str == "blah";
  57. }, function() {
  58. return "blah";
  59. });
  60. taa.register("thinger");
  61. taa.register("prepend", null, null, true, true);
  62. taa.unregister("prepend");
  63. t.is(2, taa.pairs.length);
  64. t.is("blah", taa.pairs[0][0]);
  65. }]);
  66. }