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
Léo-Paul Géneau
gitlab-ce
Commits
66ad04e4
Commit
66ad04e4
authored
Jul 10, 2018
by
Winnie Hellmann
Committed by
Mike Greiling
Jul 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mock timeouts and Promise in SmartInterval tests
parent
5bd8bfb6
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
130 additions
and
99 deletions
+130
-99
spec/javascripts/helpers/wait_for_promises.js
spec/javascripts/helpers/wait_for_promises.js
+1
-0
spec/javascripts/job_spec.js
spec/javascripts/job_spec.js
+12
-15
spec/javascripts/smart_interval_spec.js
spec/javascripts/smart_interval_spec.js
+117
-84
No files found.
spec/javascripts/helpers/wait_for_promises.js
0 → 100644
View file @
66ad04e4
export
default
()
=>
new
Promise
(
resolve
=>
requestAnimationFrame
(
resolve
));
spec/javascripts/job_spec.js
View file @
66ad04e4
...
@@ -5,6 +5,7 @@ import { numberToHumanSize } from '~/lib/utils/number_utils';
...
@@ -5,6 +5,7 @@ import { numberToHumanSize } from '~/lib/utils/number_utils';
import
'
~/lib/utils/datetime_utility
'
;
import
'
~/lib/utils/datetime_utility
'
;
import
Job
from
'
~/job
'
;
import
Job
from
'
~/job
'
;
import
'
~/breakpoints
'
;
import
'
~/breakpoints
'
;
import
waitForPromises
from
'
spec/helpers/wait_for_promises
'
;
describe
(
'
Job
'
,
()
=>
{
describe
(
'
Job
'
,
()
=>
{
const
JOB_URL
=
`
${
gl
.
TEST_HOST
}
/frontend-fixtures/builds-project/-/jobs/1`
;
const
JOB_URL
=
`
${
gl
.
TEST_HOST
}
/frontend-fixtures/builds-project/-/jobs/1`
;
...
@@ -12,10 +13,6 @@ describe('Job', () => {
...
@@ -12,10 +13,6 @@ describe('Job', () => {
let
response
;
let
response
;
let
job
;
let
job
;
function
waitForPromise
()
{
return
new
Promise
(
resolve
=>
requestAnimationFrame
(
resolve
));
}
preloadFixtures
(
'
builds/build-with-artifacts.html.raw
'
);
preloadFixtures
(
'
builds/build-with-artifacts.html.raw
'
);
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
@@ -49,7 +46,7 @@ describe('Job', () => {
...
@@ -49,7 +46,7 @@ describe('Job', () => {
beforeEach
(
function
(
done
)
{
beforeEach
(
function
(
done
)
{
job
=
new
Job
();
job
=
new
Job
();
waitForPromise
()
waitForPromise
s
()
.
then
(
done
)
.
then
(
done
)
.
catch
(
done
.
fail
);
.
catch
(
done
.
fail
);
});
});
...
@@ -93,7 +90,7 @@ describe('Job', () => {
...
@@ -93,7 +90,7 @@ describe('Job', () => {
job
=
new
Job
();
job
=
new
Job
();
waitForPromise
()
waitForPromise
s
()
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
$
(
'
#build-trace .js-build-output
'
).
text
()).
toMatch
(
/Update/
);
expect
(
$
(
'
#build-trace .js-build-output
'
).
text
()).
toMatch
(
/Update/
);
expect
(
job
.
state
).
toBe
(
'
newstate
'
);
expect
(
job
.
state
).
toBe
(
'
newstate
'
);
...
@@ -107,7 +104,7 @@ describe('Job', () => {
...
@@ -107,7 +104,7 @@ describe('Job', () => {
};
};
})
})
.
then
(()
=>
jasmine
.
clock
().
tick
(
4001
))
.
then
(()
=>
jasmine
.
clock
().
tick
(
4001
))
.
then
(
waitForPromise
)
.
then
(
waitForPromise
s
)
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
$
(
'
#build-trace .js-build-output
'
).
text
()).
toMatch
(
/UpdateMore/
);
expect
(
$
(
'
#build-trace .js-build-output
'
).
text
()).
toMatch
(
/UpdateMore/
);
expect
(
job
.
state
).
toBe
(
'
finalstate
'
);
expect
(
job
.
state
).
toBe
(
'
finalstate
'
);
...
@@ -126,7 +123,7 @@ describe('Job', () => {
...
@@ -126,7 +123,7 @@ describe('Job', () => {
job
=
new
Job
();
job
=
new
Job
();
waitForPromise
()
waitForPromise
s
()
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
$
(
'
#build-trace .js-build-output
'
).
text
()).
toMatch
(
/Update/
);
expect
(
$
(
'
#build-trace .js-build-output
'
).
text
()).
toMatch
(
/Update/
);
...
@@ -137,7 +134,7 @@ describe('Job', () => {
...
@@ -137,7 +134,7 @@ describe('Job', () => {
};
};
})
})
.
then
(()
=>
jasmine
.
clock
().
tick
(
4001
))
.
then
(()
=>
jasmine
.
clock
().
tick
(
4001
))
.
then
(
waitForPromise
)
.
then
(
waitForPromise
s
)
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
$
(
'
#build-trace .js-build-output
'
).
text
()).
not
.
toMatch
(
/Update/
);
expect
(
$
(
'
#build-trace .js-build-output
'
).
text
()).
not
.
toMatch
(
/Update/
);
expect
(
$
(
'
#build-trace .js-build-output
'
).
text
()).
toMatch
(
/Different/
);
expect
(
$
(
'
#build-trace .js-build-output
'
).
text
()).
toMatch
(
/Different/
);
...
@@ -160,7 +157,7 @@ describe('Job', () => {
...
@@ -160,7 +157,7 @@ describe('Job', () => {
job
=
new
Job
();
job
=
new
Job
();
waitForPromise
()
waitForPromise
s
()
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
document
.
querySelector
(
'
.js-truncated-info
'
).
classList
).
not
.
toContain
(
'
hidden
'
);
expect
(
document
.
querySelector
(
'
.js-truncated-info
'
).
classList
).
not
.
toContain
(
'
hidden
'
);
})
})
...
@@ -181,7 +178,7 @@ describe('Job', () => {
...
@@ -181,7 +178,7 @@ describe('Job', () => {
job
=
new
Job
();
job
=
new
Job
();
waitForPromise
()
waitForPromise
s
()
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
expect
(
document
.
querySelector
(
'
.js-truncated-info-size
'
).
textContent
.
trim
(),
document
.
querySelector
(
'
.js-truncated-info-size
'
).
textContent
.
trim
(),
...
@@ -203,7 +200,7 @@ describe('Job', () => {
...
@@ -203,7 +200,7 @@ describe('Job', () => {
job
=
new
Job
();
job
=
new
Job
();
waitForPromise
()
waitForPromise
s
()
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
expect
(
document
.
querySelector
(
'
.js-truncated-info-size
'
).
textContent
.
trim
(),
document
.
querySelector
(
'
.js-truncated-info-size
'
).
textContent
.
trim
(),
...
@@ -219,7 +216,7 @@ describe('Job', () => {
...
@@ -219,7 +216,7 @@ describe('Job', () => {
};
};
})
})
.
then
(()
=>
jasmine
.
clock
().
tick
(
4001
))
.
then
(()
=>
jasmine
.
clock
().
tick
(
4001
))
.
then
(
waitForPromise
)
.
then
(
waitForPromise
s
)
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
expect
(
document
.
querySelector
(
'
.js-truncated-info-size
'
).
textContent
.
trim
(),
document
.
querySelector
(
'
.js-truncated-info-size
'
).
textContent
.
trim
(),
...
@@ -258,7 +255,7 @@ describe('Job', () => {
...
@@ -258,7 +255,7 @@ describe('Job', () => {
job
=
new
Job
();
job
=
new
Job
();
waitForPromise
()
waitForPromise
s
()
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
document
.
querySelector
(
'
.js-truncated-info
'
).
classList
).
toContain
(
'
hidden
'
);
expect
(
document
.
querySelector
(
'
.js-truncated-info
'
).
classList
).
toContain
(
'
hidden
'
);
})
})
...
@@ -280,7 +277,7 @@ describe('Job', () => {
...
@@ -280,7 +277,7 @@ describe('Job', () => {
job
=
new
Job
();
job
=
new
Job
();
waitForPromise
()
waitForPromise
s
()
.
then
(
done
)
.
then
(
done
)
.
catch
(
done
.
fail
);
.
catch
(
done
.
fail
);
});
});
...
...
spec/javascripts/smart_interval_spec.js
View file @
66ad04e4
This diff is collapsed.
Click to expand it.
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