2018-03-09 15:18:59 -05:00
|
|
|
import $ from 'jquery';
|
2022-05-13 08:08:49 -04:00
|
|
|
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
|
2017-03-13 17:48:32 -04:00
|
|
|
import '~/commons/bootstrap';
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2019-12-20 10:07:34 -05:00
|
|
|
describe('Bootstrap jQuery extensions', () => {
|
|
|
|
describe('disable', () => {
|
|
|
|
beforeEach(() => {
|
2022-05-13 08:08:49 -04:00
|
|
|
setHTMLFixture('<input type="text" />');
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
resetHTMLFixture();
|
2016-07-24 16:45:11 -04:00
|
|
|
});
|
2018-10-17 03:13:26 -04:00
|
|
|
|
2019-12-20 10:07:34 -05:00
|
|
|
it('adds the disabled attribute', () => {
|
2019-11-15 07:06:12 -05:00
|
|
|
const $input = $('input').first();
|
2018-10-17 03:13:26 -04:00
|
|
|
$input.disable();
|
|
|
|
|
|
|
|
expect($input).toHaveAttr('disabled', 'disabled');
|
|
|
|
});
|
2019-12-20 10:07:34 -05:00
|
|
|
|
|
|
|
it('adds the disabled class', () => {
|
2019-11-15 07:06:12 -05:00
|
|
|
const $input = $('input').first();
|
2018-10-17 03:13:26 -04:00
|
|
|
$input.disable();
|
|
|
|
|
|
|
|
expect($input).toHaveClass('disabled');
|
|
|
|
});
|
|
|
|
});
|
2019-12-20 10:07:34 -05:00
|
|
|
|
|
|
|
describe('enable', () => {
|
|
|
|
beforeEach(() => {
|
2022-05-13 08:08:49 -04:00
|
|
|
setHTMLFixture('<input type="text" disabled="disabled" class="disabled" />');
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
resetHTMLFixture();
|
2018-10-17 03:13:26 -04:00
|
|
|
});
|
|
|
|
|
2019-12-20 10:07:34 -05:00
|
|
|
it('removes the disabled attribute', () => {
|
2019-11-15 07:06:12 -05:00
|
|
|
const $input = $('input').first();
|
2018-10-17 03:13:26 -04:00
|
|
|
$input.enable();
|
|
|
|
|
|
|
|
expect($input).not.toHaveAttr('disabled');
|
|
|
|
});
|
2019-12-20 10:07:34 -05:00
|
|
|
|
|
|
|
it('removes the disabled class', () => {
|
2019-11-15 07:06:12 -05:00
|
|
|
const $input = $('input').first();
|
2018-10-17 03:13:26 -04:00
|
|
|
$input.enable();
|
|
|
|
|
|
|
|
expect($input).not.toHaveClass('disabled');
|
2016-07-24 16:45:11 -04:00
|
|
|
});
|
|
|
|
});
|
2018-10-17 03:13:26 -04:00
|
|
|
});
|