Commit 38f3bf58 authored by pburdette's avatar pburdette

Apply reviewer feedback

Rename spec, remove a few
un-needed pieces of the spec and
focus on reusablitliy.
parent 6b956d95
...@@ -13,12 +13,6 @@ describe('Pipelines table in Commits and Merge requests', () => { ...@@ -13,12 +13,6 @@ describe('Pipelines table in Commits and Merge requests', () => {
let pipeline; let pipeline;
let mock; let mock;
const defaultProps = {
endpoint: 'endpoint.json',
emptyStateSvgPath: 'foo',
errorStateSvgPath: 'foo',
};
const findRunPipelineBtn = () => wrapper.findByTestId('run_pipeline_button'); const findRunPipelineBtn = () => wrapper.findByTestId('run_pipeline_button');
const findRunPipelineBtnMobile = () => wrapper.findByTestId('run_pipeline_button_mobile'); const findRunPipelineBtnMobile = () => wrapper.findByTestId('run_pipeline_button_mobile');
const findLoadingState = () => wrapper.findComponent(GlLoadingIcon); const findLoadingState = () => wrapper.findComponent(GlLoadingIcon);
...@@ -27,10 +21,13 @@ describe('Pipelines table in Commits and Merge requests', () => { ...@@ -27,10 +21,13 @@ describe('Pipelines table in Commits and Merge requests', () => {
const findTableRows = () => wrapper.findAllByTestId('pipeline-table-row'); const findTableRows = () => wrapper.findAllByTestId('pipeline-table-row');
const findModal = () => wrapper.findComponent(GlModal); const findModal = () => wrapper.findComponent(GlModal);
const createComponent = (props = defaultProps) => { const createComponent = (props = {}) => {
wrapper = extendedWrapper( wrapper = extendedWrapper(
mount(PipelinesTable, { mount(PipelinesTable, {
propsData: { propsData: {
endpoint: 'endpoint.json',
emptyStateSvgPath: 'foo',
errorStateSvgPath: 'foo',
...props, ...props,
}, },
}), }),
...@@ -106,23 +103,21 @@ describe('Pipelines table in Commits and Merge requests', () => { ...@@ -106,23 +103,21 @@ describe('Pipelines table in Commits and Merge requests', () => {
expect(wrapper.vm.updateContent).toHaveBeenCalledWith({ page: '2' }); expect(wrapper.vm.updateContent).toHaveBeenCalledWith({ page: '2' });
}); });
}); });
});
describe('pipeline badge counts', () => {
it('should receive update-pipelines-count event', (done) => {
mock.onGet('endpoint.json').reply(200, [pipeline]);
const element = document.createElement('div'); describe('pipeline badge counts', () => {
document.body.appendChild(element); it('should receive update-pipelines-count event', (done) => {
const element = document.createElement('div');
document.body.appendChild(element);
element.addEventListener('update-pipelines-count', (event) => { element.addEventListener('update-pipelines-count', (event) => {
expect(event.detail.pipelines).toEqual([pipeline]); expect(event.detail.pipelines).toEqual([pipeline]);
done(); done();
}); });
createComponent(); createComponent();
element.appendChild(wrapper.vm.$el); element.appendChild(wrapper.vm.$el);
});
}); });
}); });
}); });
...@@ -173,7 +168,6 @@ describe('Pipelines table in Commits and Merge requests', () => { ...@@ -173,7 +168,6 @@ describe('Pipelines table in Commits and Merge requests', () => {
mock.onGet('endpoint.json').reply(200, [pipelineCopy]); mock.onGet('endpoint.json').reply(200, [pipelineCopy]);
createComponent({ createComponent({
...defaultProps,
canRunPipeline: true, canRunPipeline: true,
projectId: '5', projectId: '5',
mergeRequestId: 3, mergeRequestId: 3,
...@@ -213,7 +207,6 @@ describe('Pipelines table in Commits and Merge requests', () => { ...@@ -213,7 +207,6 @@ describe('Pipelines table in Commits and Merge requests', () => {
mock.onGet('endpoint.json').reply(200, [pipelineCopy]); mock.onGet('endpoint.json').reply(200, [pipelineCopy]);
createComponent({ createComponent({
...defaultProps,
projectId: '5', projectId: '5',
mergeRequestId: 3, mergeRequestId: 3,
canCreatePipelineInTargetProject: true, canCreatePipelineInTargetProject: true,
...@@ -252,7 +245,6 @@ describe('Pipelines table in Commits and Merge requests', () => { ...@@ -252,7 +245,6 @@ describe('Pipelines table in Commits and Merge requests', () => {
}); });
it('should render error state', () => { it('should render error state', () => {
expect(findEmptyState().exists()).toBe(true);
expect(findEmptyState().text()).toBe( expect(findEmptyState().text()).toBe(
'There was an error fetching the pipelines. Try again in a few moments or contact your support team.', 'There was an error fetching the pipelines. Try again in a few moments or contact your support team.',
); );
......
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