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
1a04efe4
Commit
1a04efe4
authored
Aug 03, 2020
by
jakeburden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace mock freeze period with fixture
parent
cd6560ec
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
12 deletions
+16
-12
spec/frontend/deploy_freeze/components/deploy_freeze_modal_spec.js
...tend/deploy_freeze/components/deploy_freeze_modal_spec.js
+4
-3
spec/frontend/deploy_freeze/components/deploy_freeze_table_spec.js
...tend/deploy_freeze/components/deploy_freeze_table_spec.js
+4
-3
spec/frontend/deploy_freeze/store/actions_spec.js
spec/frontend/deploy_freeze/store/actions_spec.js
+4
-3
spec/frontend/deploy_freeze/store/mutations_spec.js
spec/frontend/deploy_freeze/store/mutations_spec.js
+4
-3
No files found.
spec/frontend/deploy_freeze/components/deploy_freeze_modal_spec.js
View file @
1a04efe4
...
...
@@ -4,7 +4,7 @@ import { GlButton, GlModal } from '@gitlab/ui';
import
DeployFreezeModal
from
'
~/deploy_freeze/components/deploy_freeze_modal.vue
'
;
import
TimezoneDropdown
from
'
~/vue_shared/components/timezone_dropdown.vue
'
;
import
createStore
from
'
~/deploy_freeze/store
'
;
import
{
mock
DeployFreezePayload
,
mock
TimezoneData
}
from
'
../mock_data
'
;
import
{
mockTimezoneData
}
from
'
../mock_data
'
;
const
localVue
=
createLocalVue
();
localVue
.
use
(
Vuex
);
...
...
@@ -12,6 +12,7 @@ localVue.use(Vuex);
describe
(
'
Deploy freeze modal
'
,
()
=>
{
let
wrapper
;
let
store
;
const
freezePeriodsFixture
=
getJSONFixture
(
'
/api/freeze-periods/freeze-periods.json
'
);
beforeEach
(()
=>
{
store
=
createStore
({
...
...
@@ -57,7 +58,7 @@ describe('Deploy freeze modal', () => {
describe
(
'
Adding a new deploy freeze
'
,
()
=>
{
beforeEach
(()
=>
{
const
{
freeze_start
,
freeze_end
,
cron_timezone
}
=
mockDeployFreezePayload
;
const
{
freeze_start
,
freeze_end
,
cron_timezone
}
=
freezePeriodsFixture
[
0
]
;
setInput
(
freeze_start
,
freeze_end
,
cron_timezone
);
});
...
...
@@ -79,7 +80,7 @@ describe('Deploy freeze modal', () => {
describe
(
'
when the cron state is valid
'
,
()
=>
{
beforeEach
(()
=>
{
const
{
freeze_start
,
freeze_end
,
cron_timezone
}
=
mockDeployFreezePayload
;
const
{
freeze_start
,
freeze_end
,
cron_timezone
}
=
freezePeriodsFixture
[
0
]
;
setInput
(
freeze_start
,
freeze_end
,
cron_timezone
);
});
...
...
spec/frontend/deploy_freeze/components/deploy_freeze_table_spec.js
View file @
1a04efe4
...
...
@@ -2,7 +2,7 @@ import Vuex from 'vuex';
import
{
createLocalVue
,
mount
}
from
'
@vue/test-utils
'
;
import
DeployFreezeTable
from
'
~/deploy_freeze/components/deploy_freeze_table.vue
'
;
import
createStore
from
'
~/deploy_freeze/store
'
;
import
{
mock
FreezePeriods
,
mock
TimezoneData
}
from
'
../mock_data
'
;
import
{
mockTimezoneData
}
from
'
../mock_data
'
;
const
localVue
=
createLocalVue
();
localVue
.
use
(
Vuex
);
...
...
@@ -50,11 +50,12 @@ describe('Deploy freeze table', () => {
});
it
(
'
displays data
'
,
()
=>
{
store
.
state
.
freezePeriods
=
mockFreezePeriods
;
const
freezePeriodsFixture
=
getJSONFixture
(
'
/api/freeze-periods/freeze-periods.json
'
);
store
.
state
.
freezePeriods
=
freezePeriodsFixture
;
return
wrapper
.
vm
.
$nextTick
(()
=>
{
const
tableRows
=
findDeployFreezeTable
().
findAll
(
'
tbody tr
'
);
expect
(
tableRows
.
length
).
toBe
(
mockFreezePeriods
.
length
);
expect
(
tableRows
.
length
).
toBe
(
freezePeriodsFixture
.
length
);
expect
(
findEmptyFreezePeriods
().
exists
()).
toBe
(
false
);
});
});
...
...
spec/frontend/deploy_freeze/store/actions_spec.js
View file @
1a04efe4
...
...
@@ -6,7 +6,7 @@ import createFlash from '~/flash';
import
getInitialState
from
'
~/deploy_freeze/store/state
'
;
import
*
as
actions
from
'
~/deploy_freeze/store/actions
'
;
import
*
as
types
from
'
~/deploy_freeze/store/mutation_types
'
;
import
{
mockTimezoneData
,
mockFreezePeriods
}
from
'
../mock_data
'
;
import
{
mockTimezoneData
}
from
'
../mock_data
'
;
jest
.
mock
(
'
~/api.js
'
);
jest
.
mock
(
'
~/flash.js
'
);
...
...
@@ -14,6 +14,7 @@ jest.mock('~/flash.js');
describe
(
'
deploy freeze store actions
'
,
()
=>
{
let
mock
;
let
state
;
const
freezePeriodsFixture
=
getJSONFixture
(
'
/api/freeze-periods/freeze-periods.json
'
);
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
...
...
@@ -21,7 +22,7 @@ describe('deploy freeze store actions', () => {
projectId
:
'
8
'
,
timezoneData
:
mockTimezoneData
,
});
Api
.
freezePeriods
.
mockResolvedValue
({
data
:
mockFreezePeriods
});
Api
.
freezePeriods
.
mockResolvedValue
({
data
:
freezePeriodsFixture
});
Api
.
createFreezePeriod
.
mockResolvedValue
();
});
...
...
@@ -97,7 +98,7 @@ describe('deploy freeze store actions', () => {
state
,
[
{
type
:
types
.
REQUEST_FREEZE_PERIODS
},
{
type
:
types
.
RECEIVE_FREEZE_PERIODS_SUCCESS
,
payload
:
mockFreezePeriods
},
{
type
:
types
.
RECEIVE_FREEZE_PERIODS_SUCCESS
,
payload
:
freezePeriodsFixture
},
],
[],
);
...
...
spec/frontend/deploy_freeze/store/mutations_spec.js
View file @
1a04efe4
import
state
from
'
~/deploy_freeze/store/state
'
;
import
mutations
from
'
~/deploy_freeze/store/mutations
'
;
import
*
as
types
from
'
~/deploy_freeze/store/mutation_types
'
;
import
{
mock
FreezePeriods
,
mock
TimezoneData
}
from
'
../mock_data
'
;
import
{
mockTimezoneData
}
from
'
../mock_data
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
describe
(
'
Deploy freeze mutations
'
,
()
=>
{
...
...
@@ -27,10 +27,11 @@ describe('Deploy freeze mutations', () => {
describe
(
'
RECEIVE_FREEZE_PERIODS_SUCCESS
'
,
()
=>
{
it
(
'
should set freeze periods and format timezones from identifiers to names
'
,
()
=>
{
const
timezoneNames
=
[
'
Eastern Time (US & Canada)
'
,
'
UTC
'
,
'
Berlin
'
];
const
freezePeriodsFixture
=
getJSONFixture
(
'
/api/freeze-periods/freeze-periods.json
'
);
mutations
[
types
.
RECEIVE_FREEZE_PERIODS_SUCCESS
](
stateCopy
,
mockFreezePeriods
);
mutations
[
types
.
RECEIVE_FREEZE_PERIODS_SUCCESS
](
stateCopy
,
freezePeriodsFixture
);
const
expectedFreezePeriods
=
mockFreezePeriods
.
map
((
freezePeriod
,
index
)
=>
({
const
expectedFreezePeriods
=
freezePeriodsFixture
.
map
((
freezePeriod
,
index
)
=>
({
...
convertObjectPropsToCamelCase
(
freezePeriod
),
cronTimezone
:
timezoneNames
[
index
],
}));
...
...
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