Core_init.spec.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. describe('Core_init', () => {
  2. const id = 'testContainer';
  3. beforeEach(function() {
  4. this.$container = $(`<div id="${id}"></div>`).appendTo('body');
  5. });
  6. afterEach(function() {
  7. if (this.$container) {
  8. destroy();
  9. this.$container.remove();
  10. }
  11. });
  12. it('should respect startRows and startCols when no data is provided', () => {
  13. spec().$container.remove();
  14. spec().$container = $(`<div id="${id}"></div>`).appendTo('body');
  15. handsontable();
  16. expect(countRows()).toEqual(5); // as given in README.md
  17. expect(countCols()).toEqual(5); // as given in README.md
  18. });
  19. it('should respect width provided in inline style', () => {
  20. spec().$container.css({
  21. overflow: 'auto',
  22. width: '200px'
  23. });
  24. handsontable({
  25. data: [
  26. ['ABC', 'ABC', 'ABC', 'ABC', 'ABC', 'ABC', 'ABC', 'ABC', 'ABC']
  27. ]
  28. });
  29. expect(spec().$container.width()).toEqual(200);
  30. });
  31. it('should respect width provided in CSS class', () => {
  32. $('<style>.myTable {overflow: auto; width: 200px}</style>').appendTo('head');
  33. spec().$container.addClass('myTable');
  34. handsontable({
  35. data: [
  36. ['ABC', 'ABC', 'ABC', 'ABC', 'ABC', 'ABC', 'ABC', 'ABC', 'ABC']
  37. ]
  38. });
  39. expect(spec().$container.width()).toEqual(200);
  40. });
  41. it('should construct when container is not appended to document', () => {
  42. spec().$container.remove();
  43. handsontable();
  44. expect(getData()).toBeTruthy();
  45. });
  46. xit('should create table even if is launched inside custom element', () => {
  47. // TODO: When we'll update phantomjs, then we should try to run this test case.
  48. spec().$container = $(`<hot-table><div id="${id}"></div></hot-table>`).appendTo('body');
  49. handsontable();
  50. expect(() => {
  51. mouseOver(spec().$container.find('tr:eq(0) td:eq(1)'));
  52. }).not.toThrow();
  53. });
  54. });