import { addNoScrollClass, removeNoScrollClass } from './DOMOperations';

describe('DOM operations', () => {
  describe('add no-scroll operations', () => {
    afterEach(() => {
      removeNoScrollClass();
    });

    it('adds no-scroll class to parent root', () => {
      expect(hasNoScrollClass()).toBe(false);
      addNoScrollClass();
      expect(hasNoScrollClass()).toBe(true);
    });
  });

  describe('remove no-scroll operations', () => {
    beforeEach(() => {
      addNoScrollClass();
    });

    it('removes no-scroll class from parent root', () => {
      expect(hasNoScrollClass()).toBe(true);
      removeNoScrollClass();
      expect(hasNoScrollClass()).toBe(false);
    });
  });

  function hasNoScrollClass() {
    return document.documentElement.classList.contains('no-scroll');
  }
});
