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
6ebc082e
Commit
6ebc082e
authored
Feb 10, 2021
by
Jose Vargas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor delayed_job_mixin_spec to use shallowMount
parent
0dbe4c2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
52 deletions
+46
-52
spec/frontend/jobs/mixins/delayed_job_mixin_spec.js
spec/frontend/jobs/mixins/delayed_job_mixin_spec.js
+46
-52
No files found.
spec/frontend/jobs/mixins/delayed_job_mixin_spec.js
View file @
6ebc082e
import
Vue
from
'
vue
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
delayedJobMixin
from
'
~/jobs/mixins/delayed_job_mixin
'
;
import
delayedJobMixin
from
'
~/jobs/mixins/delayed_job_mixin
'
;
describe
(
'
DelayedJobMixin
'
,
()
=>
{
describe
(
'
DelayedJobMixin
'
,
()
=>
{
let
wrapper
;
const
delayedJobFixture
=
getJSONFixture
(
'
jobs/delayed.json
'
);
const
delayedJobFixture
=
getJSONFixture
(
'
jobs/delayed.json
'
);
const
dummyComponent
=
Vue
.
extend
({
const
dummyComponent
=
{
mixins
:
[
delayedJobMixin
],
props
:
{
props
:
{
job
:
{
job
:
{
type
:
Object
,
type
:
Object
,
required
:
true
,
required
:
true
,
},
},
},
},
render
(
createElement
)
{
mixins
:
[
delayedJobMixin
],
return
createElement
(
'
div
'
,
this
.
remainingTime
);
template
:
'
<div>{{remainingTime}}</div>
'
,
},
};
});
let
vm
;
afterEach
(()
=>
{
afterEach
(()
=>
{
vm
.
$
destroy
();
wrapper
.
destroy
();
jest
.
clearAllTimers
()
;
wrapper
=
null
;
});
});
describe
(
'
if job is empty object
'
,
()
=>
{
describe
(
'
if job is empty object
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
vm
=
mountComponent
(
dummyComponent
,
{
wrapper
=
shallowMount
(
dummyComponent
,
{
job
:
{},
propsData
:
{
job
:
{},
},
});
});
});
});
it
(
'
sets remaining time to 00:00:00
'
,
()
=>
{
it
(
'
sets remaining time to 00:00:00
'
,
()
=>
{
expect
(
vm
.
$el
.
innerText
).
toBe
(
'
00:00:00
'
);
expect
(
wrapper
.
text
()
).
toBe
(
'
00:00:00
'
);
});
});
describe
(
'
after mounting
'
,
()
=>
{
it
(
'
does not update remaining time after mounting
'
,
async
()
=>
{
beforeEach
(()
=>
vm
.
$nextTick
()
);
await
wrapper
.
vm
.
$nextTick
(
);
it
(
'
does not update remaining time
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toBe
(
'
00:00:00
'
);
expect
(
vm
.
$el
.
innerText
).
toBe
(
'
00:00:00
'
);
});
});
});
});
});
...
@@ -48,33 +44,32 @@ describe('DelayedJobMixin', () => {
...
@@ -48,33 +44,32 @@ describe('DelayedJobMixin', () => {
describe
(
'
if job is delayed job
'
,
()
=>
{
describe
(
'
if job is delayed job
'
,
()
=>
{
let
remainingTimeInMilliseconds
=
42000
;
let
remainingTimeInMilliseconds
=
42000
;
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
jest
jest
.
spyOn
(
Date
,
'
now
'
)
.
spyOn
(
Date
,
'
now
'
)
.
mockImplementation
(
.
mockImplementation
(
()
=>
new
Date
(
delayedJobFixture
.
scheduled_at
).
getTime
()
-
remainingTimeInMilliseconds
,
()
=>
new
Date
(
delayedJobFixture
.
scheduled_at
).
getTime
()
-
remainingTimeInMilliseconds
,
);
);
vm
=
mountComponent
(
dummyComponent
,
{
wrapper
=
shallowMount
(
dummyComponent
,
{
job
:
delayedJobFixture
,
propsData
:
{
job
:
delayedJobFixture
,
},
});
});
});
describe
(
'
after mounting
'
,
()
=>
{
await
wrapper
.
vm
.
$nextTick
();
beforeEach
(()
=>
vm
.
$nextTick
()
);
}
);
it
(
'
sets remaining time
'
,
()
=>
{
it
(
'
sets remaining time
'
,
()
=>
{
expect
(
vm
.
$el
.
innerText
).
toBe
(
'
00:00:42
'
);
expect
(
wrapper
.
text
()
).
toBe
(
'
00:00:42
'
);
});
});
it
(
'
updates remaining time
'
,
()
=>
{
it
(
'
updates remaining time
'
,
async
()
=>
{
remainingTimeInMilliseconds
=
41000
;
remainingTimeInMilliseconds
=
41000
;
jest
.
advanceTimersByTime
(
1000
);
jest
.
advanceTimersByTime
(
1000
);
return
vm
.
$nextTick
().
then
(()
=>
{
await
wrapper
.
vm
.
$nextTick
();
expect
(
vm
.
$el
.
innerText
).
toBe
(
'
00:00:41
'
);
expect
(
wrapper
.
text
()).
toBe
(
'
00:00:41
'
);
});
});
});
});
});
});
});
});
...
@@ -96,33 +91,32 @@ describe('DelayedJobMixin', () => {
...
@@ -96,33 +91,32 @@ describe('DelayedJobMixin', () => {
describe
(
'
if job is delayed job
'
,
()
=>
{
describe
(
'
if job is delayed job
'
,
()
=>
{
let
remainingTimeInMilliseconds
=
42000
;
let
remainingTimeInMilliseconds
=
42000
;
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
jest
jest
.
spyOn
(
Date
,
'
now
'
)
.
spyOn
(
Date
,
'
now
'
)
.
mockImplementation
(
.
mockImplementation
(
()
=>
mockGraphQlJob
.
scheduledAt
.
getTime
()
-
remainingTimeInMilliseconds
,
()
=>
mockGraphQlJob
.
scheduledAt
.
getTime
()
-
remainingTimeInMilliseconds
,
);
);
vm
=
mountComponent
(
dummyComponent
,
{
wrapper
=
shallowMount
(
dummyComponent
,
{
job
:
mockGraphQlJob
,
propsData
:
{
job
:
mockGraphQlJob
,
},
});
});
});
describe
(
'
after mounting
'
,
()
=>
{
await
wrapper
.
vm
.
$nextTick
();
beforeEach
(()
=>
vm
.
$nextTick
()
);
}
);
it
(
'
sets remaining time
'
,
()
=>
{
it
(
'
sets remaining time
'
,
()
=>
{
expect
(
vm
.
$el
.
innerText
).
toBe
(
'
00:00:42
'
);
expect
(
wrapper
.
text
()
).
toBe
(
'
00:00:42
'
);
});
});
it
(
'
updates remaining time
'
,
()
=>
{
it
(
'
updates remaining time
'
,
async
()
=>
{
remainingTimeInMilliseconds
=
41000
;
remainingTimeInMilliseconds
=
41000
;
jest
.
advanceTimersByTime
(
1000
);
jest
.
advanceTimersByTime
(
1000
);
return
vm
.
$nextTick
().
then
(()
=>
{
await
wrapper
.
vm
.
$nextTick
();
expect
(
vm
.
$el
.
innerText
).
toBe
(
'
00:00:41
'
);
expect
(
wrapper
.
text
()).
toBe
(
'
00:00:41
'
);
});
});
});
});
});
});
});
});
...
...
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