summaryrefslogtreecommitdiff
path: root/spec/frontend/bootstrap_jquery_spec.js
blob: 15186600a8a566100846f912c4ea4f47c1f1af7e (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import $ from 'jquery';
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
import '~/commons/bootstrap';

describe('Bootstrap jQuery extensions', () => {
  describe('disable', () => {
    beforeEach(() => {
      setHTMLFixture('<input type="text" />');
    });

    afterEach(() => {
      resetHTMLFixture();
    });

    it('adds the disabled attribute', () => {
      const $input = $('input').first();
      $input.disable();

      expect($input).toHaveAttr('disabled', 'disabled');
    });

    it('adds the disabled class', () => {
      const $input = $('input').first();
      $input.disable();

      expect($input).toHaveClass('disabled');
    });
  });

  describe('enable', () => {
    beforeEach(() => {
      setHTMLFixture('<input type="text" disabled="disabled" class="disabled" />');
    });

    afterEach(() => {
      resetHTMLFixture();
    });

    it('removes the disabled attribute', () => {
      const $input = $('input').first();
      $input.enable();

      expect($input).not.toHaveAttr('disabled');
    });

    it('removes the disabled class', () => {
      const $input = $('input').first();
      $input.enable();

      expect($input).not.toHaveClass('disabled');
    });
  });
});