summaryrefslogtreecommitdiff
path: root/spec/frontend/behaviors/autosize_spec.js
blob: 3444c7b4075af91471a75959372b14d1cbe197e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import '~/behaviors/autosize';

function load() {
  document.dispatchEvent(new Event('DOMContentLoaded'));
}

jest.mock('~/helpers/startup_css_helper', () => {
  return {
    waitForCSSLoaded: jest.fn().mockImplementation(cb => cb.apply()),
  };
});

describe('Autosize behavior', () => {
  beforeEach(() => {
    setFixtures('<textarea class="js-autosize"></textarea>');
  });

  it('is applied to the textarea', () => {
    load();

    const textarea = document.querySelector('textarea');
    expect(textarea.classList).toContain('js-autosize-initialized');
  });
});