Debian Codegraph @

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

raw
1 // Copyright 2011 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.DrilldownRowTest');
16 goog.setTestOnly('goog.ui.DrilldownRowTest');
17
18 goog.require('goog.dom');
19 goog.require('goog.dom.TagName');
20 goog.require('goog.html.SafeHtml');
21 goog.require('goog.testing.jsunit');
22 goog.require('goog.ui.DrilldownRow');
23
24 function testMakeRows() {
25 var ff = goog.dom.getElement('firstRow');
26 var d = new goog.ui.DrilldownRow({});
27 var d1 = new goog.ui.DrilldownRow({html: createHtmlForRow('Second row')});
28 var d2 = new goog.ui.DrilldownRow({html: createHtmlForRow('Third row')});
29 var d21 = new goog.ui.DrilldownRow({html: createHtmlForRow('Fourth row')});
30 var d22 = new goog.ui.DrilldownRow(goog.ui.DrilldownRow.sampleProperties);
31 d.decorate(ff);
32 d.addChild(d1, true);
33 d.addChild(d2, true);
34 d2.addChild(d21, true);
35 d2.addChild(d22, true);
36
37 assertThrows(function() { d.findIndex(); });
38
39 assertEquals(0, d1.findIndex());
40 assertEquals(1, d2.findIndex());
41 }
42
43 function createHtmlForRow(rowText) {
44 var SafeHtml = goog.html.SafeHtml;
45 return SafeHtml.create(
46 goog.dom.TagName.TR, {},
47 SafeHtml.concat(
48 goog.html.SafeHtml.create(goog.dom.TagName.TD, {}, rowText),
49 goog.html.SafeHtml.create(goog.dom.TagName.TD, {}, 'Second column')));
50 }