not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.3 KiB

  1. define(["sugar-web/graphics/menupalette", "sugar-web/graphics/palette"], function (menupalette, palette) {
  2. 'use strict';
  3. describe("menupalette", function () {
  4. var invoker;
  5. var menuData;
  6. var menuPalette;
  7. beforeEach(function () {
  8. invoker = document.createElement('button');
  9. menuData = [
  10. {
  11. label: "One",
  12. id: "one-button",
  13. icon: true
  14. },
  15. {
  16. label: "Two",
  17. id: "two-button",
  18. icon: true
  19. },
  20. {
  21. label: "Three",
  22. id: "three-button",
  23. icon: true
  24. }
  25. ];
  26. menuPalette = new menupalette.MenuPalette(invoker, undefined,
  27. menuData);
  28. });
  29. it("should have a fixed number of clickable items", function () {
  30. var buttons = menuPalette.getPalette().
  31. querySelectorAll('.container button');
  32. expect(buttons.length).toBe(menuData.length);
  33. });
  34. it("should emit a signal with the clicked item", function () {
  35. var button;
  36. var buttonSelected;
  37. function onItemSelected(event) {
  38. button = event.detail.target;
  39. buttonSelected = true;
  40. }
  41. runs(function () {
  42. buttonSelected = false;
  43. menuPalette.addEventListener('selectItem', onItemSelected);
  44. var buttons = menuPalette.getPalette().
  45. querySelectorAll('.container button');
  46. buttons[1].click();
  47. });
  48. waitsFor(function () {
  49. return buttonSelected;
  50. }, "should have selected a button");
  51. runs(function () {
  52. expect(button.id).toBe("two-button");
  53. });
  54. });
  55. it("should be an instance of the child class", function () {
  56. expect(menuPalette instanceof menupalette.MenuPalette).toBe(true);
  57. });
  58. it("should be an instance of the parent class", function () {
  59. expect(menuPalette instanceof palette.Palette).toBe(true);
  60. });
  61. });
  62. });