/ext-4.1.0_b3/src/core/test/unit/spec/dom/Element.style.js

https://bitbucket.org/srogerf/javascript · JavaScript · 118 lines · 99 code · 19 blank · 0 comment · 3 complexity · eb3e9a849d592c4cae61786a2e8dd70e MD5 · raw file

  1. describe("Ext.Element.style", function() {
  2. var testEl;
  3. beforeEach(function() {
  4. testEl = Ext.getBody().createChild({
  5. id : 'ExtElementHelper',
  6. style : 'position:absolute;'
  7. });
  8. });
  9. afterEach(function() {
  10. testEl.remove();
  11. });
  12. describe('addCls', function () {
  13. xit('should add one class', function () {
  14. testEl.addCls('foo');
  15. expect(testEl.dom.className).toEqual('foo');
  16. });
  17. it('should add two class', function () {
  18. testEl.addCls('foo').addCls('bar');
  19. expect(testEl.dom.className).toEqual('foo bar');
  20. });
  21. xit('should add one class when given duplicates', function () {
  22. testEl.addCls('foo').addCls('foo');
  23. expect(testEl.dom.className).toEqual('foo');
  24. });
  25. xit('should add two class at once', function () {
  26. testEl.addCls('foo bar').addCls('bar');
  27. expect(testEl.dom.className).toEqual('foo bar');
  28. });
  29. xit('should add two class at once and handle duplicates', function () {
  30. testEl.addCls('foo bar').addCls('bar foo');
  31. expect(testEl.dom.className).toEqual('foo bar');
  32. });
  33. });
  34. describe('removeCls', function () {
  35. it('should remove nothing if no classes', function () {
  36. testEl.removeCls('bar');
  37. expect(testEl.dom.className).toEqual('');
  38. });
  39. it('should remove nothing if class is not present', function () {
  40. testEl.dom.className = 'foo bar';
  41. testEl.removeCls('fbar');
  42. expect(testEl.dom.className).toEqual('foo bar');
  43. });
  44. it('should remove only class', function () {
  45. testEl.dom.className = 'foo';
  46. testEl.removeCls('foo');
  47. expect(testEl.dom.className).toEqual('');
  48. });
  49. it('should remove last class', function () {
  50. testEl.dom.className = 'foo bar';
  51. testEl.removeCls('bar');
  52. expect(testEl.dom.className).toEqual('foo');
  53. });
  54. it('should remove first class', function () {
  55. testEl.dom.className = 'foo bar';
  56. testEl.removeCls('bar');
  57. expect(testEl.dom.className).toEqual('foo');
  58. });
  59. it('should remove middle class', function () {
  60. testEl.dom.className = 'foo bar jazz';
  61. testEl.removeCls('bar');
  62. expect(testEl.dom.className).toEqual('foo jazz');
  63. });
  64. it('should remove multiple classes', function () {
  65. testEl.dom.className = 'foo bar jazz spud';
  66. testEl.removeCls('jazz bar fff');
  67. expect(testEl.dom.className).toEqual('foo spud');
  68. });
  69. it('should remove multiple classes sequentially', function () {
  70. testEl.dom.className = 'foo bar jazz spud';
  71. testEl.removeCls('jazz').removeCls('bar').removeCls('fff');
  72. expect(testEl.dom.className).toEqual('foo spud');
  73. });
  74. });
  75. describe('getStyle', function(){
  76. var el, dom;
  77. beforeEach(function(){
  78. dom = document.createElement('div');
  79. testEl.appendChild(dom);
  80. el = new Ext.Element(dom);
  81. });
  82. afterEach(function(){
  83. dom.parentNode.removeChild(dom);
  84. el = dom = null;
  85. });
  86. describe('border-*-width', function(){
  87. Ext.Array.forEach('top right bottom left'.split(' '), function(side){
  88. it('must report the correct border-'+ side +'-width when the border-'+ side +'-style is "solid"', function(){
  89. dom.style.cssText = 'border:5px solid';
  90. expect(el.getStyle('border-'+ side +'-width')).toBe('5px');
  91. });
  92. it('must report 0px for border-'+ side +'-width when the border-'+ side +'-style is "none"', function(){
  93. dom.style.cssText = 'border:5px solid; border-' + side + '-style:none';
  94. expect(el.getStyle('border-'+ side +'-width')).toBe('0px');
  95. });
  96. });
  97. });
  98. });
  99. }, "/src/dom/Element.style.js");