toolbarseparatorrenderer_test.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright 2009 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. goog.provide('goog.ui.ToolbarSeparatorRendererTest');
  15. goog.setTestOnly('goog.ui.ToolbarSeparatorRendererTest');
  16. goog.require('goog.dom');
  17. goog.require('goog.dom.TagName');
  18. goog.require('goog.dom.classlist');
  19. goog.require('goog.testing.jsunit');
  20. goog.require('goog.ui.Component');
  21. goog.require('goog.ui.INLINE_BLOCK_CLASSNAME');
  22. goog.require('goog.ui.ToolbarSeparator');
  23. goog.require('goog.ui.ToolbarSeparatorRenderer');
  24. var parent;
  25. var renderer;
  26. var separator;
  27. function setUp() {
  28. parent = goog.dom.getElement('parent');
  29. renderer = goog.ui.ToolbarSeparatorRenderer.getInstance();
  30. separator = new goog.ui.ToolbarSeparator(renderer);
  31. }
  32. function tearDown() {
  33. separator.dispose();
  34. goog.dom.removeChildren(parent);
  35. }
  36. function testConstructor() {
  37. assertNotNull('Renderer must not be null', renderer);
  38. }
  39. function testGetCssClass() {
  40. assertEquals(
  41. 'getCssClass() must return expected value',
  42. goog.ui.ToolbarSeparatorRenderer.CSS_CLASS, renderer.getCssClass());
  43. }
  44. function testCreateDom() {
  45. var element = renderer.createDom(separator);
  46. assertNotNull('Created element must not be null', element);
  47. assertEquals('Created element must be a DIV',
  48. String(goog.dom.TagName.DIV), element.tagName);
  49. assertSameElements(
  50. 'Created element must have expected class names',
  51. [
  52. goog.ui.ToolbarSeparatorRenderer.CSS_CLASS,
  53. // Separators are always in a disabled state.
  54. renderer.getClassForState(goog.ui.Component.State.DISABLED),
  55. goog.ui.INLINE_BLOCK_CLASSNAME
  56. ],
  57. goog.dom.classlist.get(element));
  58. }
  59. function testCreateDomWithExtraCssClass() {
  60. separator.addClassName('another-class');
  61. var element = renderer.createDom(separator);
  62. assertContains(
  63. 'Created element must contain extra CSS classes', 'another-class',
  64. goog.dom.classlist.get(element));
  65. }