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
5ab13b43
Commit
5ab13b43
authored
Sep 13, 2019
by
Illya Klymov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor jobs/list_spec to Jest
parent
bb31fea5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
67 deletions
+115
-67
spec/frontend/ide/components/jobs/list_spec.js
spec/frontend/ide/components/jobs/list_spec.js
+115
-0
spec/javascripts/ide/components/jobs/list_spec.js
spec/javascripts/ide/components/jobs/list_spec.js
+0
-67
No files found.
spec/frontend/ide/components/jobs/list_spec.js
0 → 100644
View file @
5ab13b43
import
{
shallowMount
,
mount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
Vuex
from
'
vuex
'
;
import
StageList
from
'
~/ide/components/jobs/list.vue
'
;
import
Stage
from
'
~/ide/components/jobs/stage.vue
'
;
const
localVue
=
createLocalVue
();
localVue
.
use
(
Vuex
);
const
storeActions
=
{
fetchJobs
:
jest
.
fn
(),
toggleStageCollapsed
:
jest
.
fn
(),
setDetailJob
:
jest
.
fn
(),
};
const
store
=
new
Vuex
.
Store
({
modules
:
{
pipelines
:
{
namespaced
:
true
,
actions
:
storeActions
,
},
},
});
describe
(
'
IDE stages list
'
,
()
=>
{
let
wrapper
;
const
defaultProps
=
{
stages
:
[],
loading
:
false
,
};
const
stages
=
[
'
build
'
,
'
test
'
,
'
deploy
'
].
map
((
name
,
id
)
=>
({
id
,
name
,
jobs
:
[],
status
:
{
icon
:
'
status_success
'
},
}));
const
createComponent
=
props
=>
{
wrapper
=
shallowMount
(
StageList
,
{
propsData
:
{
...
defaultProps
,
...
props
,
},
localVue
,
store
,
sync
:
false
,
});
};
afterEach
(()
=>
{
Object
.
values
(
storeActions
).
forEach
(
actionMock
=>
actionMock
.
mockClear
());
});
afterAll
(()
=>
{
wrapper
.
destroy
();
wrapper
=
null
;
});
it
(
'
renders loading icon when no stages & loading
'
,
()
=>
{
createComponent
({
loading
:
true
,
stages
:
[]
});
expect
(
wrapper
.
find
(
GlLoadingIcon
).
exists
()).
toBe
(
true
);
});
it
(
'
renders stages components for each stage
'
,
()
=>
{
createComponent
({
stages
});
expect
(
wrapper
.
findAll
(
Stage
).
length
).
toBe
(
stages
.
length
);
});
it
(
'
triggers fetchJobs action when stage emits fetch event
'
,
()
=>
{
createComponent
({
stages
});
wrapper
.
find
(
Stage
).
vm
.
$emit
(
'
fetch
'
);
expect
(
storeActions
.
fetchJobs
).
toHaveBeenCalled
();
});
it
(
'
triggers toggleStageCollapsed action when stage emits toggleCollapsed event
'
,
()
=>
{
createComponent
({
stages
});
wrapper
.
find
(
Stage
).
vm
.
$emit
(
'
toggleCollapsed
'
);
expect
(
storeActions
.
toggleStageCollapsed
).
toHaveBeenCalled
();
});
it
(
'
triggers setDetailJob action when stage emits clickViewLog event
'
,
()
=>
{
createComponent
({
stages
});
wrapper
.
find
(
Stage
).
vm
.
$emit
(
'
clickViewLog
'
);
expect
(
storeActions
.
setDetailJob
).
toHaveBeenCalled
();
});
describe
(
'
integration tests
'
,
()
=>
{
const
findCardHeader
=
()
=>
wrapper
.
find
(
'
.card-header
'
);
beforeEach
(()
=>
{
wrapper
=
mount
(
StageList
,
{
propsData
:
{
...
defaultProps
,
stages
},
store
,
sync
:
false
,
localVue
,
});
});
it
(
'
calls toggleStageCollapsed when clicking stage header
'
,
()
=>
{
findCardHeader
().
trigger
(
'
click
'
);
expect
(
storeActions
.
toggleStageCollapsed
).
toHaveBeenCalledWith
(
expect
.
any
(
Object
),
0
,
undefined
,
);
});
it
(
'
calls fetchJobs when stage is mounted
'
,
()
=>
{
expect
(
storeActions
.
fetchJobs
.
mock
.
calls
.
map
(([,
stage
])
=>
stage
)).
toEqual
(
stages
);
});
});
});
spec/javascripts/ide/components/jobs/list_spec.js
deleted
100644 → 0
View file @
bb31fea5
import
Vue
from
'
vue
'
;
import
StageList
from
'
~/ide/components/jobs/list.vue
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
import
{
createComponentWithStore
}
from
'
../../../helpers/vue_mount_component_helper
'
;
import
{
stages
,
jobs
}
from
'
../../mock_data
'
;
describe
(
'
IDE stages list
'
,
()
=>
{
const
Component
=
Vue
.
extend
(
StageList
);
let
vm
;
beforeEach
(()
=>
{
const
store
=
createStore
();
vm
=
createComponentWithStore
(
Component
,
store
,
{
stages
:
stages
.
map
((
mappedState
,
i
)
=>
({
...
mappedState
,
id
:
i
,
dropdownPath
:
mappedState
.
dropdown_path
,
jobs
:
[...
jobs
],
isLoading
:
false
,
isCollapsed
:
false
,
})),
loading
:
false
,
});
spyOn
(
vm
,
'
fetchJobs
'
);
spyOn
(
vm
,
'
toggleStageCollapsed
'
);
vm
.
$mount
();
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
it
(
'
renders list of stages
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
.card
'
).
length
).
toBe
(
2
);
});
it
(
'
renders loading icon when no stages & is loading
'
,
done
=>
{
vm
.
stages
=
[];
vm
.
loading
=
true
;
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.loading-container
'
)).
not
.
toBe
(
null
);
done
();
});
});
it
(
'
calls toggleStageCollapsed when clicking stage header
'
,
done
=>
{
vm
.
$el
.
querySelector
(
'
.card-header
'
).
click
();
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
toggleStageCollapsed
).
toHaveBeenCalledWith
(
0
);
done
();
});
});
it
(
'
calls fetchJobs when stage is mounted
'
,
()
=>
{
expect
(
vm
.
fetchJobs
.
calls
.
count
()).
toBe
(
stages
.
length
);
expect
(
vm
.
fetchJobs
.
calls
.
argsFor
(
0
)).
toEqual
([
vm
.
stages
[
0
]]);
expect
(
vm
.
fetchJobs
.
calls
.
argsFor
(
1
)).
toEqual
([
vm
.
stages
[
1
]]);
});
});
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