summaryrefslogtreecommitdiff
path: root/spec/frontend/issuable_form_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/issuable_form_spec.js')
-rw-r--r--spec/frontend/issuable_form_spec.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/frontend/issuable_form_spec.js b/spec/frontend/issuable_form_spec.js
new file mode 100644
index 00000000000..009ca28ff78
--- /dev/null
+++ b/spec/frontend/issuable_form_spec.js
@@ -0,0 +1,56 @@
+import $ from 'jquery';
+
+import IssuableForm from '~/issuable_form';
+
+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
+ ${'wip '}
+ ${' wIP: '}
+ ${'[WIp] '}
+ ${'wIP:'}
+ ${' [WIp]'}
+ ${'drAft '}
+ ${'draFT: '}
+ ${' [DRaft] '}
+ ${'drAft:'}
+ ${'[draFT]'}
+ ${' dRaFt - '}
+ ${'dRaFt - '}
+ ${'(draft) '}
+ ${' (DrafT)'}
+ ${'wip wip: [wip] draft draft - draft: [draft] (draft)'}
+ `('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");
+ });
+ });
+});