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>
import { GlSorting, GlSortingItem } from '@gitlab/ui';
import {
ASCENDING_ODER,
ASCENDING_ORDER,
DESCENDING_ORDER,
SORT_OPTIONS,
RELEASED_AT,
......@@ -36,7 +36,7 @@ export default {
},
direction() {
if (this.value === RELEASED_AT_ASC || this.value === CREATED_ASC) {
return ASCENDING_ODER;
return ASCENDING_ORDER;
}
return DESCENDING_ORDER;
......@@ -48,12 +48,12 @@ export default {
return this.sortOptions.find((s) => s.orderBy === this.orderBy).label;
},
isDirectionAscending() {
return this.direction === ASCENDING_ODER;
return this.direction === ASCENDING_ORDER;
},
},
methods: {
onDirectionChange() {
const direction = this.isDirectionAscending ? DESCENDING_ORDER : ASCENDING_ODER;
const direction = this.isDirectionAscending ? DESCENDING_ORDER : ASCENDING_ORDER;
this.emitInputEventIfChanged(this.orderBy, direction);
},
onSortItemClick(item) {
......
import { GlSorting } from '@gitlab/ui';
import { GlSorting, GlSortingItem } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import ReleasesSortApolloClient from '~/releases/components/releases_sort_apollo_client.vue';
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', () => {
let wrapper;
......@@ -16,7 +12,7 @@ describe('releases_sort_apollo_client.vue', () => {
value: valueProp,
},
stubs: {
GlSortingItem: GlSortingItemStub,
GlSortingItem,
},
});
};
......@@ -26,7 +22,7 @@ describe('releases_sort_apollo_client.vue', () => {
});
const findSorting = () => wrapper.findComponent(GlSorting);
const findSortingItems = () => wrapper.findAllComponents(GlSortingItemStub);
const findSortingItems = () => wrapper.findAllComponents(GlSortingItem);
const findReleasedDateItem = () =>
findSortingItems().wrappers.find((item) => item.text() === 'Released date');
const findCreatedDateItem = () =>
......@@ -96,4 +92,12 @@ describe('releases_sort_apollo_client.vue', () => {
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