Commit bd618ae2 authored by Nathan Friend's avatar Nathan Friend Committed by Miguel Rincon

Remove unnecessary stubbed component

And also fix one more typo in a constant.
parent 450d0ce0
<script> <script>
import { GlSorting, GlSortingItem } from '@gitlab/ui'; import { GlSorting, GlSortingItem } from '@gitlab/ui';
import { import {
ASCENDING_ODER, ASCENDING_ORDER,
DESCENDING_ORDER, DESCENDING_ORDER,
SORT_OPTIONS, SORT_OPTIONS,
RELEASED_AT, RELEASED_AT,
...@@ -36,7 +36,7 @@ export default { ...@@ -36,7 +36,7 @@ export default {
}, },
direction() { direction() {
if (this.value === RELEASED_AT_ASC || this.value === CREATED_ASC) { if (this.value === RELEASED_AT_ASC || this.value === CREATED_ASC) {
return ASCENDING_ODER; return ASCENDING_ORDER;
} }
return DESCENDING_ORDER; return DESCENDING_ORDER;
...@@ -48,12 +48,12 @@ export default { ...@@ -48,12 +48,12 @@ export default {
return this.sortOptions.find((s) => s.orderBy === this.orderBy).label; return this.sortOptions.find((s) => s.orderBy === this.orderBy).label;
}, },
isDirectionAscending() { isDirectionAscending() {
return this.direction === ASCENDING_ODER; return this.direction === ASCENDING_ORDER;
}, },
}, },
methods: { methods: {
onDirectionChange() { onDirectionChange() {
const direction = this.isDirectionAscending ? DESCENDING_ORDER : ASCENDING_ODER; const direction = this.isDirectionAscending ? DESCENDING_ORDER : ASCENDING_ORDER;
this.emitInputEventIfChanged(this.orderBy, direction); this.emitInputEventIfChanged(this.orderBy, direction);
}, },
onSortItemClick(item) { onSortItemClick(item) {
......
import { GlSorting } from '@gitlab/ui'; import { GlSorting, GlSortingItem } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import ReleasesSortApolloClient from '~/releases/components/releases_sort_apollo_client.vue'; import ReleasesSortApolloClient from '~/releases/components/releases_sort_apollo_client.vue';
import { RELEASED_AT_ASC, RELEASED_AT_DESC, CREATED_ASC, CREATED_DESC } from '~/releases/constants'; import { RELEASED_AT_ASC, RELEASED_AT_DESC, CREATED_ASC, CREATED_DESC } from '~/releases/constants';
const GlSortingItemStub = {
template: '<div><slot></slot></div>',
};
describe('releases_sort_apollo_client.vue', () => { describe('releases_sort_apollo_client.vue', () => {
let wrapper; let wrapper;
...@@ -16,7 +12,7 @@ describe('releases_sort_apollo_client.vue', () => { ...@@ -16,7 +12,7 @@ describe('releases_sort_apollo_client.vue', () => {
value: valueProp, value: valueProp,
}, },
stubs: { stubs: {
GlSortingItem: GlSortingItemStub, GlSortingItem,
}, },
}); });
}; };
...@@ -26,7 +22,7 @@ describe('releases_sort_apollo_client.vue', () => { ...@@ -26,7 +22,7 @@ describe('releases_sort_apollo_client.vue', () => {
}); });
const findSorting = () => wrapper.findComponent(GlSorting); const findSorting = () => wrapper.findComponent(GlSorting);
const findSortingItems = () => wrapper.findAllComponents(GlSortingItemStub); const findSortingItems = () => wrapper.findAllComponents(GlSortingItem);
const findReleasedDateItem = () => const findReleasedDateItem = () =>
findSortingItems().wrappers.find((item) => item.text() === 'Released date'); findSortingItems().wrappers.find((item) => item.text() === 'Released date');
const findCreatedDateItem = () => const findCreatedDateItem = () =>
...@@ -96,4 +92,12 @@ describe('releases_sort_apollo_client.vue', () => { ...@@ -96,4 +92,12 @@ describe('releases_sort_apollo_client.vue', () => {
expect(wrapper.emitted().input?.[0]?.[0]).toEqual(emittedEvent); expect(wrapper.emitted().input?.[0]?.[0]).toEqual(emittedEvent);
}); });
}); });
describe('prop validation', () => {
it('validates that the `value` prop is one of the expected sort strings', () => {
expect(() => {
createComponent('not a valid value');
}).toThrow('Invalid prop: custom validator check failed');
});
});
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment