inline-mode.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. describe('inline mode', function () {
  2. let element;
  3. let dp;
  4. let picker;
  5. beforeEach(function () {
  6. element = parseHTML('<div data-date="04/22/2020"></div>').firstChild;
  7. testContainer.appendChild(element);
  8. dp = new Datepicker(element, {container: 'body'});
  9. picker = document.querySelector('.datepicker');
  10. });
  11. afterEach(function () {
  12. dp.destroy();
  13. testContainer.removeChild(element);
  14. });
  15. it('uses the bound element for the container regardless of the container option', function () {
  16. expect(picker.parentElement, 'to be', element);
  17. });
  18. it('does not add datepicker-input class to the bound element', function () {
  19. expect(element.classList.contains('datepicker-input'), 'to be false');
  20. });
  21. it('shows the picker on construction', function () {
  22. expect(isVisible(picker), 'to be true');
  23. });
  24. it('uses the data-date attribute for the initial date(s)', function () {
  25. expect(dp.dates[0], 'to be', dateValue(2020, 3, 22));
  26. expect(getViewSwitch(picker).textContent, 'to be', 'April 2020');
  27. expect(picker.querySelector('.datepicker-cell.selected').textContent, 'to be', '22');
  28. });
  29. it('hide() takes no effect', function () {
  30. dp.hide();
  31. expect(isVisible(picker), 'to be true');
  32. });
  33. it('enterEditMode() takes no effect', function () {
  34. dp.enterEditMode();
  35. expect(dp.editMode, 'to be undefined');
  36. });
  37. });