2022-04-06 09:09:15 +00:00
|
|
|
import { GlEmptyState } from '@gitlab/ui';
|
2021-10-29 18:13:13 +00:00
|
|
|
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
|
|
|
|
import ClustersEmptyState from '~/clusters_list/components/clusters_empty_state.vue';
|
|
|
|
|
|
|
|
const clustersEmptyStateImage = 'path/to/svg';
|
|
|
|
const emptyStateHelpText = 'empty state text';
|
|
|
|
|
|
|
|
describe('ClustersEmptyStateComponent', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
2021-12-02 21:10:16 +00:00
|
|
|
const defaultProvideData = {
|
2021-10-29 18:13:13 +00:00
|
|
|
clustersEmptyStateImage,
|
|
|
|
};
|
|
|
|
|
|
|
|
const findEmptyStateText = () => wrapper.findByTestId('clusters-empty-state-text');
|
|
|
|
|
2022-04-06 09:09:15 +00:00
|
|
|
const createWrapper = ({ provideData = { emptyStateHelpText: null } } = {}) => {
|
2021-10-29 18:13:13 +00:00
|
|
|
wrapper = shallowMountExtended(ClustersEmptyState, {
|
2021-12-02 21:10:16 +00:00
|
|
|
provide: { ...defaultProvideData, ...provideData },
|
2021-10-29 18:13:13 +00:00
|
|
|
stubs: { GlEmptyState },
|
|
|
|
});
|
2021-12-02 21:10:16 +00:00
|
|
|
};
|
|
|
|
|
2021-10-29 18:13:13 +00:00
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the help text is not provided', () => {
|
2021-11-15 18:12:21 +00:00
|
|
|
beforeEach(() => {
|
2022-04-06 09:09:15 +00:00
|
|
|
createWrapper();
|
2021-11-15 18:12:21 +00:00
|
|
|
});
|
|
|
|
|
2022-04-06 09:09:15 +00:00
|
|
|
it('should not render the empty state text', () => {
|
|
|
|
expect(findEmptyStateText().exists()).toBe(false);
|
2021-11-15 18:12:21 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-10-29 18:13:13 +00:00
|
|
|
describe('when the help text is provided', () => {
|
|
|
|
beforeEach(() => {
|
2021-12-02 21:10:16 +00:00
|
|
|
createWrapper({ provideData: { emptyStateHelpText } });
|
2021-10-29 18:13:13 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should show the empty state text', () => {
|
|
|
|
expect(findEmptyStateText().text()).toBe(emptyStateHelpText);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|