diff options
Diffstat (limited to 'spec/frontend/behaviors')
-rw-r--r-- | spec/frontend/behaviors/markdown/paste_markdown_table_spec.js | 12 | ||||
-rw-r--r-- | spec/frontend/behaviors/markdown/render_metrics_spec.js | 36 |
2 files changed, 30 insertions, 18 deletions
diff --git a/spec/frontend/behaviors/markdown/paste_markdown_table_spec.js b/spec/frontend/behaviors/markdown/paste_markdown_table_spec.js index a98919e2113..eab805382bd 100644 --- a/spec/frontend/behaviors/markdown/paste_markdown_table_spec.js +++ b/spec/frontend/behaviors/markdown/paste_markdown_table_spec.js @@ -57,6 +57,18 @@ describe('PasteMarkdownTable', () => { expect(new PasteMarkdownTable(data).isTable()).toBe(false); }); + + it('returns false when the table copy comes from a diff', () => { + data.types = ['text/html', 'text/plain']; + data.getData = jest.fn().mockImplementation(mimeType => { + if (mimeType === 'text/html') { + return '<table class="diff-wrap-lines"><tr><td>First</td><td>Second</td></tr></table>'; + } + return 'First\tSecond'; + }); + + expect(new PasteMarkdownTable(data).isTable()).toBe(false); + }); }); describe('convertToTableMarkdown', () => { diff --git a/spec/frontend/behaviors/markdown/render_metrics_spec.js b/spec/frontend/behaviors/markdown/render_metrics_spec.js index 3f7beeb817b..ab81ed6b8f0 100644 --- a/spec/frontend/behaviors/markdown/render_metrics_spec.js +++ b/spec/frontend/behaviors/markdown/render_metrics_spec.js @@ -11,20 +11,20 @@ const getElements = () => Array.from(document.getElementsByClassName('js-render- describe('Render metrics for Gitlab Flavoured Markdown', () => { it('does nothing when no elements are found', () => { - renderMetrics([]); - - expect(mockEmbedGroup).not.toHaveBeenCalled(); + return renderMetrics([]).then(() => { + expect(mockEmbedGroup).not.toHaveBeenCalled(); + }); }); it('renders a vue component when elements are found', () => { document.body.innerHTML = `<div class="js-render-metrics" data-dashboard-url="${TEST_HOST}"></div>`; - renderMetrics(getElements()); - - expect(mockEmbedGroup).toHaveBeenCalledTimes(1); - expect(mockEmbedGroup).toHaveBeenCalledWith( - expect.objectContaining({ propsData: { urls: [`${TEST_HOST}`] } }), - ); + return renderMetrics(getElements()).then(() => { + expect(mockEmbedGroup).toHaveBeenCalledTimes(1); + expect(mockEmbedGroup).toHaveBeenCalledWith( + expect.objectContaining({ propsData: { urls: [`${TEST_HOST}`] } }), + ); + }); }); it('takes sibling metrics and groups them under a shared parent', () => { @@ -36,14 +36,14 @@ describe('Render metrics for Gitlab Flavoured Markdown', () => { <div class="js-render-metrics" data-dashboard-url="${TEST_HOST}/3"></div> `; - renderMetrics(getElements()); - - expect(mockEmbedGroup).toHaveBeenCalledTimes(2); - expect(mockEmbedGroup).toHaveBeenCalledWith( - expect.objectContaining({ propsData: { urls: [`${TEST_HOST}/1`, `${TEST_HOST}/2`] } }), - ); - expect(mockEmbedGroup).toHaveBeenCalledWith( - expect.objectContaining({ propsData: { urls: [`${TEST_HOST}/3`] } }), - ); + return renderMetrics(getElements()).then(() => { + expect(mockEmbedGroup).toHaveBeenCalledTimes(2); + expect(mockEmbedGroup).toHaveBeenCalledWith( + expect.objectContaining({ propsData: { urls: [`${TEST_HOST}/1`, `${TEST_HOST}/2`] } }), + ); + expect(mockEmbedGroup).toHaveBeenCalledWith( + expect.objectContaining({ propsData: { urls: [`${TEST_HOST}/3`] } }), + ); + }); }); }); |