debian-mirror-gitlab/spec/frontend/repository/utils/dom_spec.js

31 lines
956 B
JavaScript
Raw Normal View History

2019-12-26 22:10:19 +05:30
import { setHTMLFixture } from '../../helpers/fixtures';
2020-01-01 13:55:28 +05:30
import { updateElementsVisibility, updateFormAction } from '~/repository/utils/dom';
2019-12-26 22:10:19 +05:30
describe('updateElementsVisibility', () => {
it('adds hidden class', () => {
setHTMLFixture('<div class="js-test"></div>');
updateElementsVisibility('.js-test', false);
expect(document.querySelector('.js-test').classList).toContain('hidden');
});
it('removes hidden class', () => {
setHTMLFixture('<div class="hidden js-test"></div>');
updateElementsVisibility('.js-test', true);
expect(document.querySelector('.js-test').classList).not.toContain('hidden');
});
});
2020-01-01 13:55:28 +05:30
describe('updateFormAction', () => {
it('updates form action', () => {
setHTMLFixture('<form class="js-test" action="/"></form>');
updateFormAction('.js-test', '/gitlab/create', '/test');
expect(document.querySelector('.js-test').action).toBe('http://localhost/gitlab/create/test');
});
});