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
552c0c99
Commit
552c0c99
authored
May 29, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more store tests
parent
c8f3a60d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
195 additions
and
3 deletions
+195
-3
app/assets/javascripts/ide/stores/modules/pipelines/mutations.js
...ets/javascripts/ide/stores/modules/pipelines/mutations.js
+1
-1
spec/javascripts/ide/stores/modules/pipelines/actions_spec.js
.../javascripts/ide/stores/modules/pipelines/actions_spec.js
+106
-1
spec/javascripts/ide/stores/modules/pipelines/mutations_spec.js
...avascripts/ide/stores/modules/pipelines/mutations_spec.js
+88
-1
No files found.
app/assets/javascripts/ide/stores/modules/pipelines/mutations.js
View file @
552c0c99
...
...
@@ -47,7 +47,7 @@ export default {
[
types
.
RECEIVE_JOBS_ERROR
](
state
,
id
)
{
state
.
stages
=
state
.
stages
.
map
(
stage
=>
Object
.
assign
(
stage
,
{
isLoading
:
id
===
stage
.
id
?
tru
e
:
stage
.
isLoading
,
isLoading
:
id
===
stage
.
id
?
fals
e
:
stage
.
isLoading
,
}),
);
},
...
...
spec/javascripts/ide/stores/modules/pipelines/actions_spec.js
View file @
552c0c99
...
...
@@ -8,11 +8,16 @@ import actions, {
fetchLatestPipeline
,
stopPipelinePolling
,
clearEtagPoll
,
requestJobs
,
receiveJobsError
,
receiveJobsSuccess
,
fetchJobs
,
toggleStageCollapsed
,
}
from
'
~/ide/stores/modules/pipelines/actions
'
;
import
state
from
'
~/ide/stores/modules/pipelines/state
'
;
import
*
as
types
from
'
~/ide/stores/modules/pipelines/mutation_types
'
;
import
testAction
from
'
../../../../helpers/vuex_action_helper
'
;
import
{
pipelines
}
from
'
../../../mock_data
'
;
import
{
pipelines
,
jobs
}
from
'
../../../mock_data
'
;
describe
(
'
IDE pipelines actions
'
,
()
=>
{
let
mockedState
;
...
...
@@ -176,4 +181,104 @@ describe('IDE pipelines actions', () => {
});
});
});
describe
(
'
requestJobs
'
,
()
=>
{
it
(
'
commits request
'
,
done
=>
{
testAction
(
requestJobs
,
1
,
mockedState
,
[{
type
:
types
.
REQUEST_JOBS
,
payload
:
1
}],
[],
done
);
});
});
describe
(
'
receiveJobsError
'
,
()
=>
{
it
(
'
commits error
'
,
done
=>
{
testAction
(
receiveJobsError
,
1
,
mockedState
,
[{
type
:
types
.
RECEIVE_JOBS_ERROR
,
payload
:
1
}],
[],
done
,
);
});
it
(
'
creates flash message
'
,
()
=>
{
const
flashSpy
=
spyOnDependency
(
actions
,
'
flash
'
);
receiveJobsError
({
commit
()
{}
},
1
);
expect
(
flashSpy
).
toHaveBeenCalled
();
});
});
describe
(
'
receiveJobsSuccess
'
,
()
=>
{
it
(
'
commits data
'
,
done
=>
{
testAction
(
receiveJobsSuccess
,
{
id
:
1
,
data
:
jobs
},
mockedState
,
[{
type
:
types
.
RECEIVE_JOBS_SUCCESS
,
payload
:
{
id
:
1
,
data
:
jobs
}
}],
[],
done
,
);
});
});
describe
(
'
fetchJobs
'
,
()
=>
{
const
stage
=
{
id
:
1
,
dropdownPath
:
`
${
gl
.
TEST_HOST
}
/jobs`
,
};
describe
(
'
success
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
stage
.
dropdownPath
).
replyOnce
(
200
,
jobs
);
});
it
(
'
dispatches request
'
,
done
=>
{
testAction
(
fetchJobs
,
stage
,
mockedState
,
[],
[
{
type
:
'
requestJobs
'
,
payload
:
stage
.
id
},
{
type
:
'
receiveJobsSuccess
'
,
payload
:
{
id
:
stage
.
id
,
data
:
jobs
}
},
],
done
,
);
});
});
describe
(
'
error
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
stage
.
dropdownPath
).
replyOnce
(
500
);
});
it
(
'
dispatches error
'
,
done
=>
{
testAction
(
fetchJobs
,
stage
,
mockedState
,
[],
[
{
type
:
'
requestJobs
'
,
payload
:
stage
.
id
},
{
type
:
'
receiveJobsError
'
,
payload
:
stage
.
id
},
],
done
,
);
});
});
});
describe
(
'
toggleStageCollapsed
'
,
()
=>
{
it
(
'
commits collapse
'
,
done
=>
{
testAction
(
toggleStageCollapsed
,
1
,
mockedState
,
[{
type
:
types
.
TOGGLE_STAGE_COLLAPSE
,
payload
:
1
}],
[],
done
,
);
});
});
});
spec/javascripts/ide/stores/modules/pipelines/mutations_spec.js
View file @
552c0c99
import
mutations
from
'
~/ide/stores/modules/pipelines/mutations
'
;
import
state
from
'
~/ide/stores/modules/pipelines/state
'
;
import
*
as
types
from
'
~/ide/stores/modules/pipelines/mutation_types
'
;
import
{
fullPipelinesResponse
,
stages
}
from
'
../../../mock_data
'
;
import
{
fullPipelinesResponse
,
stages
,
jobs
}
from
'
../../../mock_data
'
;
describe
(
'
IDE pipelines mutations
'
,
()
=>
{
let
mockedState
;
...
...
@@ -86,4 +86,91 @@ describe('IDE pipelines mutations', () => {
]);
});
});
describe
(
types
.
REQUEST_JOBS
,
()
=>
{
beforeEach
(()
=>
{
mockedState
.
stages
=
stages
.
map
((
stage
,
i
)
=>
({
...
stage
,
id
:
i
,
}));
});
it
(
'
sets isLoading on stage
'
,
()
=>
{
mutations
[
types
.
REQUEST_JOBS
](
mockedState
,
mockedState
.
stages
[
0
].
id
);
expect
(
mockedState
.
stages
[
0
].
isLoading
).
toBe
(
true
);
});
});
describe
(
types
.
RECEIVE_JOBS_ERROR
,
()
=>
{
beforeEach
(()
=>
{
mockedState
.
stages
=
stages
.
map
((
stage
,
i
)
=>
({
...
stage
,
id
:
i
,
}));
});
it
(
'
sets isLoading on stage after error
'
,
()
=>
{
mutations
[
types
.
RECEIVE_JOBS_ERROR
](
mockedState
,
mockedState
.
stages
[
0
].
id
);
expect
(
mockedState
.
stages
[
0
].
isLoading
).
toBe
(
false
);
});
});
describe
(
types
.
RECEIVE_JOBS_SUCCESS
,
()
=>
{
let
data
;
beforeEach
(()
=>
{
mockedState
.
stages
=
stages
.
map
((
stage
,
i
)
=>
({
...
stage
,
id
:
i
,
}));
data
=
{
latest_statuses
:
[...
jobs
],
};
});
it
(
'
updates loading
'
,
()
=>
{
mutations
[
types
.
RECEIVE_JOBS_SUCCESS
](
mockedState
,
{
id
:
mockedState
.
stages
[
0
].
id
,
data
});
expect
(
mockedState
.
stages
[
0
].
isLoading
).
toBe
(
false
);
});
it
(
'
sets jobs on stage
'
,
()
=>
{
mutations
[
types
.
RECEIVE_JOBS_SUCCESS
](
mockedState
,
{
id
:
mockedState
.
stages
[
0
].
id
,
data
});
expect
(
mockedState
.
stages
[
0
].
jobs
.
length
).
toBe
(
jobs
.
length
);
expect
(
mockedState
.
stages
[
0
].
jobs
).
toEqual
(
jobs
.
map
(
job
=>
({
id
:
job
.
id
,
name
:
job
.
name
,
status
:
job
.
status
,
path
:
job
.
build_path
,
})),
);
});
});
describe
(
types
.
TOGGLE_STAGE_COLLAPSE
,
()
=>
{
beforeEach
(()
=>
{
mockedState
.
stages
=
stages
.
map
((
stage
,
i
)
=>
({
...
stage
,
id
:
i
,
isCollapsed
:
false
,
}));
});
it
(
'
toggles collapsed state
'
,
()
=>
{
const
stage
=
mockedState
.
stages
[
0
];
mutations
[
types
.
TOGGLE_STAGE_COLLAPSE
](
mockedState
,
stage
.
id
);
expect
(
stage
.
isCollapsed
).
toBe
(
true
);
mutations
[
types
.
TOGGLE_STAGE_COLLAPSE
](
mockedState
,
stage
.
id
);
expect
(
stage
.
isCollapsed
).
toBe
(
false
);
});
});
});
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