2020-07-17 17:09:23 -04:00
|
|
|
import $ from 'jquery';
|
|
|
|
|
2021-12-07 10:15:03 -05:00
|
|
|
import IssuableForm from '~/issuable/issuable_form';
|
2020-07-17 17:09:23 -04:00
|
|
|
|
|
|
|
function createIssuable() {
|
|
|
|
const instance = new IssuableForm($(document.createElement('form')));
|
|
|
|
|
|
|
|
instance.titleField = $(document.createElement('input'));
|
|
|
|
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('IssuableForm', () => {
|
|
|
|
let instance;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
instance = createIssuable();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('removeWip', () => {
|
|
|
|
it.each`
|
|
|
|
prefix
|
|
|
|
${'draFT: '}
|
|
|
|
${' [DRaft] '}
|
|
|
|
${'drAft:'}
|
|
|
|
${'[draFT]'}
|
|
|
|
${'(draft) '}
|
|
|
|
${' (DrafT)'}
|
2021-10-13 14:12:40 -04:00
|
|
|
${'draft: [draft] (draft)'}
|
2020-07-17 17:09:23 -04:00
|
|
|
`('removes "$prefix" from the beginning of the title', ({ prefix }) => {
|
|
|
|
instance.titleField.val(`${prefix}The Issuable's Title Value`);
|
|
|
|
|
|
|
|
instance.removeWip();
|
|
|
|
|
|
|
|
expect(instance.titleField.val()).toBe("The Issuable's Title Value");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('addWip', () => {
|
|
|
|
it("properly adds the work in progress prefix to the Issuable's title", () => {
|
|
|
|
instance.titleField.val("The Issuable's Title Value");
|
|
|
|
|
|
|
|
instance.addWip();
|
|
|
|
|
|
|
|
expect(instance.titleField.val()).toBe("Draft: The Issuable's Title Value");
|
|
|
|
});
|
|
|
|
});
|
2021-10-17 20:09:33 -04:00
|
|
|
|
|
|
|
describe('workInProgress', () => {
|
|
|
|
it.each`
|
|
|
|
title | expected
|
|
|
|
${'draFT: something is happening'} | ${true}
|
|
|
|
${'draft something is happening'} | ${false}
|
|
|
|
${'something is happening to drafts'} | ${false}
|
|
|
|
${'something is happening'} | ${false}
|
|
|
|
`('returns $expected with "$title"', ({ title, expected }) => {
|
|
|
|
instance.titleField.val(title);
|
|
|
|
|
|
|
|
expect(instance.workInProgress()).toBe(expected);
|
|
|
|
});
|
|
|
|
});
|
2020-07-17 17:09:23 -04:00
|
|
|
});
|