Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
bf0bbd7b
Commit
bf0bbd7b
authored
Nov 29, 2017
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve require input spec
parent
fbe8dfb3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
36 deletions
+40
-36
spec/javascripts/behaviors/requires_input_spec.js
spec/javascripts/behaviors/requires_input_spec.js
+40
-36
No files found.
spec/javascripts/behaviors/requires_input_spec.js
View file @
bf0bbd7b
/* eslint-disable space-before-function-paren, no-var */
import
'
~/behaviors/requires_input
'
;
import
'
~/behaviors/requires_input
'
;
(
function
()
{
describe
(
'
requiresInput
'
,
()
=>
{
describe
(
'
requiresInput
'
,
function
()
{
let
submitButton
;
preloadFixtures
(
'
branches/new_branch.html.raw
'
);
preloadFixtures
(
'
branches/new_branch.html.raw
'
);
beforeEach
(
function
()
{
loadFixtures
(
'
branches/new_branch.html.raw
'
);
beforeEach
(()
=>
{
this
.
submitButton
=
$
(
'
button[type="submit"]
'
);
loadFixtures
(
'
branches/new_branch.html.raw
'
);
});
submitButton
=
$
(
'
button[type="submit"]
'
);
it
(
'
disables submit when any field is required
'
,
function
()
{
});
$
(
'
.js-requires-input
'
).
requiresInput
();
return
expect
(
this
.
submitButton
).
toBeDisabled
();
it
(
'
disables submit when any field is required
'
,
()
=>
{
});
$
(
'
.js-requires-input
'
).
requiresInput
();
it
(
'
enables submit when no field is required
'
,
function
()
{
expect
(
submitButton
).
toBeDisabled
();
$
(
'
*[required=required]
'
).
removeAttr
(
'
required
'
);
});
$
(
'
.js-requires-input
'
).
requiresInput
();
return
expect
(
this
.
submitButton
).
not
.
toBeDisabled
();
it
(
'
enables submit when no field is required
'
,
()
=>
{
});
$
(
'
*[required=required]
'
).
removeAttr
(
'
required
'
);
it
(
'
enables submit when all required fields are pre-filled
'
,
function
()
{
$
(
'
.js-requires-input
'
).
requiresInput
();
$
(
'
*[required=required]
'
).
remove
();
expect
(
submitButton
).
not
.
toBeDisabled
();
$
(
'
.js-requires-input
'
).
requiresInput
();
});
return
expect
(
$
(
'
.submit
'
)).
not
.
toBeDisabled
();
});
it
(
'
enables submit when all required fields are pre-filled
'
,
()
=>
{
it
(
'
enables submit when all required fields receive input
'
,
function
()
{
$
(
'
*[required=required]
'
).
remove
();
$
(
'
.js-requires-input
'
).
requiresInput
();
$
(
'
.js-requires-input
'
).
requiresInput
();
$
(
'
#required1
'
).
val
(
'
input1
'
).
change
();
expect
(
$
(
'
.submit
'
)).
not
.
toBeDisabled
();
expect
(
this
.
submitButton
).
toBeDisabled
();
});
$
(
'
#optional1
'
).
val
(
'
input1
'
).
change
();
expect
(
this
.
submitButton
).
toBeDisabled
();
it
(
'
enables submit when all required fields receive input
'
,
()
=>
{
$
(
'
#required2
'
).
val
(
'
input2
'
).
change
();
$
(
'
.js-requires-input
'
).
requiresInput
();
$
(
'
#required3
'
).
val
(
'
input3
'
).
change
();
$
(
'
#required1
'
).
val
(
'
input1
'
).
change
();
$
(
'
#required4
'
).
val
(
'
input4
'
).
change
();
expect
(
submitButton
).
toBeDisabled
();
$
(
'
#required5
'
).
val
(
'
1
'
).
change
();
return
expect
(
$
(
'
.submit
'
)).
not
.
toBeDisabled
();
$
(
'
#optional1
'
).
val
(
'
input1
'
).
change
();
});
expect
(
submitButton
).
toBeDisabled
();
$
(
'
#required2
'
).
val
(
'
input2
'
).
change
();
$
(
'
#required3
'
).
val
(
'
input3
'
).
change
();
$
(
'
#required4
'
).
val
(
'
input4
'
).
change
();
$
(
'
#required5
'
).
val
(
'
1
'
).
change
();
expect
(
$
(
'
.submit
'
)).
not
.
toBeDisabled
();
});
});
})
.
call
(
window
)
;
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment