summaryrefslogtreecommitdiff
path: root/spec/frontend/deploy_freeze/components/deploy_freeze_table_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/deploy_freeze/components/deploy_freeze_table_spec.js')
-rw-r--r--spec/frontend/deploy_freeze/components/deploy_freeze_table_spec.js24
1 files changed, 20 insertions, 4 deletions
diff --git a/spec/frontend/deploy_freeze/components/deploy_freeze_table_spec.js b/spec/frontend/deploy_freeze/components/deploy_freeze_table_spec.js
index e4ee1b9ad26..168ddcfeacc 100644
--- a/spec/frontend/deploy_freeze/components/deploy_freeze_table_spec.js
+++ b/spec/frontend/deploy_freeze/components/deploy_freeze_table_spec.js
@@ -2,6 +2,7 @@ import { createLocalVue, mount } from '@vue/test-utils';
import Vuex from 'vuex';
import DeployFreezeTable from '~/deploy_freeze/components/deploy_freeze_table.vue';
import createStore from '~/deploy_freeze/store';
+import { RECEIVE_FREEZE_PERIODS_SUCCESS } from '~/deploy_freeze/store/mutation_types';
import { freezePeriodsFixture, timezoneDataFixture } from '../helpers';
const localVue = createLocalVue();
@@ -26,6 +27,7 @@ describe('Deploy freeze table', () => {
const findEmptyFreezePeriods = () => wrapper.find('[data-testid="empty-freeze-periods"]');
const findAddDeployFreezeButton = () => wrapper.find('[data-testid="add-deploy-freeze"]');
+ const findEditDeployFreezeButton = () => wrapper.find('[data-testid="edit-deploy-freeze"]');
const findDeployFreezeTable = () => wrapper.find('[data-testid="deploy-freeze-table"]');
beforeEach(() => {
@@ -45,17 +47,31 @@ describe('Deploy freeze table', () => {
it('displays empty', () => {
expect(findEmptyFreezePeriods().exists()).toBe(true);
expect(findEmptyFreezePeriods().text()).toBe(
- 'No deploy freezes exist for this project. To add one, click Add deploy freeze',
+ 'No deploy freezes exist for this project. To add one, select Add deploy freeze',
);
});
- it('displays data', () => {
- store.state.freezePeriods = freezePeriodsFixture;
+ describe('with data', () => {
+ beforeEach(async () => {
+ store.commit(RECEIVE_FREEZE_PERIODS_SUCCESS, freezePeriodsFixture);
+ await wrapper.vm.$nextTick();
+ });
- return wrapper.vm.$nextTick(() => {
+ it('displays data', () => {
const tableRows = findDeployFreezeTable().findAll('tbody tr');
expect(tableRows.length).toBe(freezePeriodsFixture.length);
expect(findEmptyFreezePeriods().exists()).toBe(false);
+ expect(findEditDeployFreezeButton().exists()).toBe(true);
+ });
+
+ it('allows user to edit deploy freeze', async () => {
+ findEditDeployFreezeButton().trigger('click');
+ await wrapper.vm.$nextTick();
+
+ expect(store.dispatch).toHaveBeenCalledWith(
+ 'setFreezePeriod',
+ store.state.freezePeriods[0],
+ );
});
});
});