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

54 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-01-03 14:25:43 +05:30
import { GlEmptyState } from '@gitlab/ui';
2020-01-01 13:55:28 +05:30
import { shallowMount } from '@vue/test-utils';
import GroupEmptyState from '~/monitoring/components/group_empty_state.vue';
import { metricStates } from '~/monitoring/constants';
2021-01-03 14:25:43 +05:30
const MockGlEmptyState = {
props: GlEmptyState.props,
template: '<div><slot name="description"></slot></div>',
};
2020-01-01 13:55:28 +05:30
function createComponent(props) {
return shallowMount(GroupEmptyState, {
propsData: {
...props,
documentationPath: '/path/to/docs',
settingsPath: '/path/to/settings',
svgPath: '/path/to/empty-group-illustration.svg',
},
2021-01-03 14:25:43 +05:30
stubs: {
GlEmptyState: MockGlEmptyState,
},
2020-01-01 13:55:28 +05:30
});
}
describe('GroupEmptyState', () => {
2021-01-03 14:25:43 +05:30
let wrapper;
afterEach(() => {
wrapper.destroy();
});
describe.each([
2020-01-01 13:55:28 +05:30
metricStates.NO_DATA,
metricStates.TIMEOUT,
metricStates.CONNECTION_FAILED,
metricStates.BAD_QUERY,
metricStates.LOADING,
metricStates.UNKNOWN_ERROR,
'FOO STATE', // does not fail with unknown states
2021-01-03 14:25:43 +05:30
])('given state %s', selectedState => {
beforeEach(() => {
wrapper = createComponent({ selectedState });
});
2020-01-01 13:55:28 +05:30
2021-01-03 14:25:43 +05:30
it('renders the slotted content', () => {
expect(wrapper.element).toMatchSnapshot();
});
2020-01-01 13:55:28 +05:30
2021-01-03 14:25:43 +05:30
it('passes the expected props to GlEmptyState', () => {
expect(wrapper.find(MockGlEmptyState).props()).toMatchSnapshot();
});
2020-01-01 13:55:28 +05:30
});
});