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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
c6974623
Commit
c6974623
authored
Oct 23, 2019
by
Dhiraj Bodicherla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated custom metrics form specs
parent
0e3ff210
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
12 deletions
+39
-12
ee/spec/frontend/custom_metrics/components/custom_metrics_form_fields_spec.js
...tom_metrics/components/custom_metrics_form_fields_spec.js
+39
-12
No files found.
ee/spec/frontend/custom_metrics/components/custom_metrics_form_fields_spec.js
View file @
c6974623
...
...
@@ -4,6 +4,8 @@ import MockAdapter from 'axios-mock-adapter';
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
CustomMetricsFormFields
from
'
ee/custom_metrics/components/custom_metrics_form_fields.vue
'
;
const
{
CancelToken
}
=
axios
;
describe
(
'
custom metrics form fields component
'
,
()
=>
{
let
component
;
let
mockAxios
;
...
...
@@ -121,9 +123,14 @@ describe('custom metrics form fields component', () => {
it
(
'
receives and validates a persisted value
'
,
()
=>
{
const
query
=
'
persistedQuery
'
;
const
axiosPost
=
jest
.
spyOn
(
axios
,
'
post
'
);
const
source
=
CancelToken
.
source
();
mountComponent
({
metricPersisted
:
true
,
...
makeFormData
({
query
})
});
expect
(
axiosPost
).
toHaveBeenCalledWith
(
validateQueryPath
,
{
query
});
expect
(
axiosPost
).
toHaveBeenCalledWith
(
validateQueryPath
,
{
query
},
{
cancelToken
:
source
.
token
},
);
expect
(
getNamedInput
(
queryInputName
).
value
).
toBe
(
query
);
jest
.
runAllTimers
();
});
...
...
@@ -144,16 +151,19 @@ describe('custom metrics form fields component', () => {
});
describe
(
'
when query validation is in flight
'
,
()
=>
{
jest
.
useFakeTimers
();
beforeEach
(()
=>
{
jest
.
useFakeTimers
();
mountComponent
(
{
metricPersisted
:
true
,
...
makeFormData
({
query
:
'
validQuery
'
})
},
{
requestValidation
:
jest
.
fn
()
.
mockImplementation
(
()
=>
new
Promise
(
resolve
=>
setTimeout
(()
=>
resolve
(
validQueryResponse
))),
),
requestValidation
:
jest
.
fn
().
mockImplementation
(
()
=>
new
Promise
(
resolve
=>
setTimeout
(()
=>
{
resolve
(
validQueryResponse
);
},
4000
),
),
),
},
);
});
...
...
@@ -162,28 +172,45 @@ describe('custom metrics form fields component', () => {
jest
.
clearAllTimers
();
});
it
(
'
expect queryValidateInFlight is in flight
'
,
()
=>
{
it
(
'
expect queryValidateInFlight is in flight
'
,
done
=>
{
const
queryInput
=
component
.
find
(
`input[name="
${
queryInputName
}
"]`
);
queryInput
.
setValue
(
'
query
'
);
queryInput
.
trigger
(
'
input
'
);
component
.
vm
.
$nextTick
(()
=>
{
expect
(
component
.
vm
.
queryValidateInFlight
).
toBe
(
true
);
jest
.
run
All
Timers
();
setTimeout
(()
=>
{
jest
.
run
OnlyPending
Timers
();
component
.
vm
.
$nextTick
(()
=>
{
expect
(
component
.
vm
.
queryValidateInFlight
).
toBe
(
false
);
expect
(
component
.
vm
.
queryIsValid
).
toBe
(
true
);
done
();
});
});
});
it
(
'
expect loading message to display
'
,
()
=>
{
it
(
'
expect loading message to display
'
,
done
=>
{
const
queryInput
=
component
.
find
(
`input[name="
${
queryInputName
}
"]`
);
queryInput
.
setValue
(
'
query
'
);
queryInput
.
trigger
(
'
input
'
);
component
.
vm
.
$nextTick
(()
=>
{
expect
(
component
.
text
()).
toContain
(
'
Validating query
'
);
jest
.
runAllTimers
();
jest
.
runOnlyPendingTimers
();
done
();
});
});
it
(
'
expect loading message to disappear
'
,
done
=>
{
const
queryInput
=
component
.
find
(
`input[name="
${
queryInputName
}
"]`
);
queryInput
.
setValue
(
'
query
'
);
queryInput
.
trigger
(
'
input
'
);
component
.
vm
.
$nextTick
(()
=>
{
jest
.
runOnlyPendingTimers
();
component
.
vm
.
$nextTick
(()
=>
{
expect
(
component
.
vm
.
queryValidateInFlight
).
toBe
(
false
);
expect
(
component
.
vm
.
queryIsValid
).
toBe
(
true
);
expect
(
component
.
vm
.
errorMessage
).
toBe
(
''
);
done
();
});
});
});
});
...
...
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