debian-mirror-gitlab/spec/frontend/monitoring/components/empty_state_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-07-28 23:09:34 +05:30
import { GlLoadingIcon, GlEmptyState } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { shallowMount } from '@vue/test-utils';
2019-09-30 21:07:59 +05:30
import EmptyState from '~/monitoring/components/empty_state.vue';
2021-03-11 19:13:27 +05:30
import { dashboardEmptyStates } from '~/monitoring/constants';
2019-09-30 21:07:59 +05:30
function createComponent(props) {
return shallowMount(EmptyState, {
propsData: {
settingsPath: '/settingsPath',
clustersPath: '/clustersPath',
documentationPath: '/documentationPath',
emptyGettingStartedSvgPath: '/path/to/getting-started.svg',
emptyLoadingSvgPath: '/path/to/loading.svg',
emptyNoDataSvgPath: '/path/to/no-data.svg',
2020-01-01 13:55:28 +05:30
emptyNoDataSmallSvgPath: '/path/to/no-data-small.svg',
2019-09-30 21:07:59 +05:30
emptyUnableToConnectSvgPath: '/path/to/unable-to-connect.svg',
2020-07-28 23:09:34 +05:30
...props,
2019-09-30 21:07:59 +05:30
},
});
}
describe('EmptyState', () => {
2020-07-28 23:09:34 +05:30
it('shows loading state with a loading icon', () => {
const wrapper = createComponent({
selectedState: dashboardEmptyStates.LOADING,
});
expect(wrapper.find(GlLoadingIcon).exists()).toBe(true);
expect(wrapper.find(GlEmptyState).exists()).toBe(false);
});
2019-09-30 21:07:59 +05:30
it('shows gettingStarted state', () => {
const wrapper = createComponent({
2020-07-28 23:09:34 +05:30
selectedState: dashboardEmptyStates.GETTING_STARTED,
2019-09-30 21:07:59 +05:30
});
expect(wrapper.element).toMatchSnapshot();
});
2020-07-28 23:09:34 +05:30
it('shows unableToConnect state', () => {
2019-09-30 21:07:59 +05:30
const wrapper = createComponent({
2020-07-28 23:09:34 +05:30
selectedState: dashboardEmptyStates.UNABLE_TO_CONNECT,
2019-09-30 21:07:59 +05:30
});
expect(wrapper.element).toMatchSnapshot();
});
2020-07-28 23:09:34 +05:30
it('shows noData state', () => {
2019-09-30 21:07:59 +05:30
const wrapper = createComponent({
2020-07-28 23:09:34 +05:30
selectedState: dashboardEmptyStates.NO_DATA,
2019-09-30 21:07:59 +05:30
});
expect(wrapper.element).toMatchSnapshot();
});
});