diff options
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/deploy_freeze/components/timezone_dropdown_spec.js | 15 | ||||
-rw-r--r-- | spec/frontend/monitoring/router_spec.js | 3 |
2 files changed, 14 insertions, 4 deletions
diff --git a/spec/frontend/deploy_freeze/components/timezone_dropdown_spec.js b/spec/frontend/deploy_freeze/components/timezone_dropdown_spec.js index 7c1a4ff1085..d1219627ca7 100644 --- a/spec/frontend/deploy_freeze/components/timezone_dropdown_spec.js +++ b/spec/frontend/deploy_freeze/components/timezone_dropdown_spec.js @@ -1,6 +1,7 @@ import Vuex from 'vuex'; import { shallowMount, createLocalVue } from '@vue/test-utils'; import { GlDropdownItem, GlDropdown } from '@gitlab/ui'; +import { secondsToHours } from '~/lib/utils/datetime_utility'; import TimezoneDropdown from '~/vue_shared/components/timezone_dropdown.vue'; import createStore from '~/deploy_freeze/store'; @@ -12,6 +13,11 @@ describe('Deploy freeze timezone dropdown', () => { let store; const timezoneDataFixture = getJSONFixture('/api/freeze-periods/timezone_data.json'); + const findTzByName = (identifier = '') => + timezoneDataFixture.find(({ name }) => name.toLowerCase() === identifier.toLowerCase()); + + const formatTz = ({ offset, name }) => `[UTC ${secondsToHours(offset)}] ${name}`; + const createComponent = (searchTerm, selectedTimezone) => { store = createStore({ projectId: '8', @@ -63,8 +69,9 @@ describe('Deploy freeze timezone dropdown', () => { }); it('renders only the time zone searched for', () => { + const selectedTz = findTzByName('Alaska'); expect(findAllDropdownItems()).toHaveLength(1); - expect(findDropdownItemByIndex(0).text()).toBe('[UTC -8] Alaska'); + expect(findDropdownItemByIndex(0).text()).toBe(formatTz(selectedTz)); }); it('should not display empty results message', () => { @@ -72,13 +79,15 @@ describe('Deploy freeze timezone dropdown', () => { }); describe('Custom events', () => { + const selectedTz = findTzByName('Alaska'); + it('should emit input if a time zone is clicked', () => { findDropdownItemByIndex(0).vm.$emit('click'); expect(wrapper.emitted('input')).toEqual([ [ { - formattedTimezone: '[UTC -8] Alaska', - identifier: 'America/Juneau', + formattedTimezone: formatTz(selectedTz), + identifier: selectedTz.identifier, }, ], ]); diff --git a/spec/frontend/monitoring/router_spec.js b/spec/frontend/monitoring/router_spec.js index 2bf2065b178..8b97c8ed125 100644 --- a/spec/frontend/monitoring/router_spec.js +++ b/spec/frontend/monitoring/router_spec.js @@ -105,7 +105,8 @@ describe('Monitoring router', () => { path | currentDashboard ${'/panel/new'} | ${undefined} ${'/dashboard.yml/panel/new'} | ${'dashboard.yml'} - ${'/config%2Fprometheus%2Fcommon_metrics.yml/panel/new'} | ${'config%2Fprometheus%2Fcommon_metrics.yml'} + ${'/config/prometheus/common_metrics.yml/panel/new'} | ${'config/prometheus/common_metrics.yml'} + ${'/config%2Fprometheus%2Fcommon_metrics.yml/panel/new'} | ${'config/prometheus/common_metrics.yml'} `('"$path" renders page with dashboard "$currentDashboard"', ({ path, currentDashboard }) => { const wrapper = createWrapper(BASE_PATH, path); |