blob: 57f666e29d6f5baa998f2c9b98df3e8078699af4 (
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
|
import $ from 'jquery';
import { loadHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
import setupNativeFormVariableList from '~/ci_variable_list/native_form_variable_list';
describe('NativeFormVariableList', () => {
let $wrapper;
beforeEach(() => {
loadHTMLFixture('pipeline_schedules/edit.html');
$wrapper = $('.js-ci-variable-list-section');
setupNativeFormVariableList({
container: $wrapper,
formField: 'schedule',
});
});
afterEach(() => {
resetHTMLFixture();
});
describe('onFormSubmit', () => {
it('should clear out the `name` attribute on the inputs for the last empty row on form submission (avoid BE validation)', () => {
const $row = $wrapper.find('.js-row');
expect($row.find('.js-ci-variable-input-key').attr('name')).toBe(
'schedule[variables_attributes][][key]',
);
expect($row.find('.js-ci-variable-input-value').attr('name')).toBe(
'schedule[variables_attributes][][secret_value]',
);
$wrapper.closest('form').trigger('trigger-submit');
expect($row.find('.js-ci-variable-input-key').attr('name')).toBe('');
expect($row.find('.js-ci-variable-input-value').attr('name')).toBe('');
});
});
});
|