drilldownrow_test.js 1.8 KB

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