diff options
Diffstat (limited to 'spec/frontend/vue_shared')
-rw-r--r-- | spec/frontend/vue_shared/components/markdown/suggestion_diff_row_spec.js | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/spec/frontend/vue_shared/components/markdown/suggestion_diff_row_spec.js b/spec/frontend/vue_shared/components/markdown/suggestion_diff_row_spec.js index c8deac1c086..8e6ac6a5fab 100644 --- a/spec/frontend/vue_shared/components/markdown/suggestion_diff_row_spec.js +++ b/spec/frontend/vue_shared/components/markdown/suggestion_diff_row_spec.js @@ -7,8 +7,8 @@ const oldLine = { meta_data: null, new_line: null, old_line: 5, - rich_text: '-oldtext', - text: '-oldtext', + rich_text: 'oldrichtext', + text: 'oldplaintext', type: 'old', }; @@ -18,8 +18,8 @@ const newLine = { meta_data: null, new_line: 6, old_line: null, - rich_text: '-newtext', - text: '-newtext', + rich_text: 'newrichtext', + text: 'newplaintext', type: 'new', }; @@ -42,14 +42,46 @@ describe('SuggestionDiffRow', () => { wrapper.destroy(); }); - it('renders correctly', () => { - factory({ - propsData: { - line: oldLine, - }, + describe('renders correctly', () => { + it('has the right classes on the wrapper', () => { + factory({ + propsData: { + line: oldLine, + }, + }); + + expect(wrapper.is('.line_holder')).toBe(true); + }); + + it('renders the rich text when it is available', () => { + factory({ + propsData: { + line: newLine, + }, + }); + + expect(wrapper.find('td.line_content').text()).toEqual('newrichtext'); }); - expect(wrapper.is('.line_holder')).toBe(true); + it('renders the plain text when it is available but rich text is not', () => { + factory({ + propsData: { + line: Object.assign({}, newLine, { rich_text: undefined }), + }, + }); + + expect(wrapper.find('td.line_content').text()).toEqual('newplaintext'); + }); + + it('renders a zero-width space when it has no plain or rich texts', () => { + factory({ + propsData: { + line: Object.assign({}, newLine, { rich_text: undefined, text: undefined }), + }, + }); + + expect(wrapper.find('td.line_content').text()).toEqual('\u200B'); + }); }); describe('when passed line has type old', () => { |