Debian Codegraph @

closure-library/closure/goog/ui/toolbarseparatorrenderer_test.js

raw
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
15 goog.provide('goog.ui.ToolbarSeparatorRendererTest');
16 goog.setTestOnly('goog.ui.ToolbarSeparatorRendererTest');
17
18 goog.require('goog.dom');
19 goog.require('goog.dom.TagName');
20 goog.require('goog.dom.classlist');
21 goog.require('goog.testing.jsunit');
22 goog.require('goog.ui.Component');
23 goog.require('goog.ui.INLINE_BLOCK_CLASSNAME');
24 goog.require('goog.ui.ToolbarSeparator');
25 goog.require('goog.ui.ToolbarSeparatorRenderer');
26
27 var parent;
28 var renderer;
29 var separator;
30
31 function setUp() {
32 parent = goog.dom.getElement('parent');
33 renderer = goog.ui.ToolbarSeparatorRenderer.getInstance();
34 separator = new goog.ui.ToolbarSeparator(renderer);
35 }
36
37 function tearDown() {
38 separator.dispose();
39 goog.dom.removeChildren(parent);
40 }
41
42 function testConstructor() {
43 assertNotNull('Renderer must not be null', renderer);
44 }
45
46 function testGetCssClass() {
47 assertEquals(
48 'getCssClass() must return expected value',
49 goog.ui.ToolbarSeparatorRenderer.CSS_CLASS, renderer.getCssClass());
50 }
51
52 function testCreateDom() {
53 var element = renderer.createDom(separator);
54 assertNotNull('Created element must not be null', element);
55 assertEquals('Created element must be a DIV',
56 String(goog.dom.TagName.DIV), element.tagName);
57 assertSameElements(
58 'Created element must have expected class names',
59 [
60 goog.ui.ToolbarSeparatorRenderer.CSS_CLASS,
61 // Separators are always in a disabled state.
62 renderer.getClassForState(goog.ui.Component.State.DISABLED),
63 goog.ui.INLINE_BLOCK_CLASSNAME
64 ],
65 goog.dom.classlist.get(element));
66 }
67
68 function testCreateDomWithExtraCssClass() {
69 separator.addClassName('another-class');
70 var element = renderer.createDom(separator);
71 assertContains(
72 'Created element must contain extra CSS classes', 'another-class',
73 goog.dom.classlist.get(element));
74 }