You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. /**
  8. * Tests Ext.data.Store functionality
  9. * @author Ed Spencer
  10. */
  11. (function() {
  12. var suite = Ext.test.session.getSuite('Ext.Direct'),
  13. assert = Y.Assert;
  14. //a shared setup function used by several of the suites
  15. var defaultSetup = function() {
  16. this.API = {
  17. "url": "php\/router.php",
  18. "type": "remoting",
  19. "actions": {
  20. "TestAction": [{
  21. "name": "doEcho",
  22. "len": 1
  23. }, {
  24. "name": "multiply",
  25. "len": 1
  26. }, {
  27. "name": "getTree",
  28. "len": 1
  29. }],
  30. "Profile": [{
  31. "name": "getBasicInfo",
  32. "len": 2
  33. }, {
  34. "name": "getPhoneInfo",
  35. "len": 1
  36. }, {
  37. "name": "getLocationInfo",
  38. "len": 1
  39. }, {
  40. "name": "updateBasicInfo",
  41. "len": 2,
  42. "formHandler": true
  43. }]
  44. }
  45. };
  46. };
  47. suite.add(new Y.Test.Case({
  48. name: 'adding providers',
  49. setUp: defaultSetup,
  50. testAddProvider: function() {
  51. var p = Ext.Direct.addProvider(
  52. this.API
  53. );
  54. Y.ObjectAssert.hasKeys(p.actions, [
  55. "Profile",
  56. "TestAction"
  57. ], 'Test actions provided');
  58. Y.ObjectAssert.hasKeys(p.actions, p, Ext.Direct.providers, "Test providers cache");
  59. },
  60. testGetProvider: function() {
  61. var p = Ext.Direct.addProvider(
  62. this.API
  63. );
  64. Y.ObjectAssert.hasKeys(p, Ext.Direct.getProvider(p.id));
  65. },
  66. testRemoveProvider: function() {
  67. // Remove via id
  68. var p = Ext.Direct.addProvider(
  69. this.API
  70. );
  71. var id = p.id;
  72. Ext.Direct.removeProvider(id);
  73. Y.Assert.isUndefined(Ext.Direct.getProvider(id));
  74. // Remove via object
  75. var p = Ext.Direct.addProvider(
  76. this.API
  77. );
  78. var id = p.id;
  79. Ext.Direct.removeProvider(p);
  80. Y.Assert.isUndefined(Ext.Direct.getProvider(id));
  81. }
  82. }));
  83. })();