diff options
Diffstat (limited to 'spec/frontend/vue_shared/components/source_viewer')
12 files changed, 231 insertions, 47 deletions
diff --git a/spec/frontend/vue_shared/components/source_viewer/components/chunk_spec.js b/spec/frontend/vue_shared/components/source_viewer/components/chunk_spec.js index 8dc3348acfa..d720574ce6d 100644 --- a/spec/frontend/vue_shared/components/source_viewer/components/chunk_spec.js +++ b/spec/frontend/vue_shared/components/source_viewer/components/chunk_spec.js @@ -2,6 +2,9 @@ import { GlIntersectionObserver } from '@gitlab/ui'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import Chunk from '~/vue_shared/components/source_viewer/components/chunk.vue'; import ChunkLine from '~/vue_shared/components/source_viewer/components/chunk_line.vue'; +import { scrollToElement } from '~/lib/utils/common_utils'; + +jest.mock('~/lib/utils/common_utils'); const DEFAULT_PROPS = { chunkIndex: 2, @@ -13,11 +16,17 @@ const DEFAULT_PROPS = { blamePath: 'blame/file.js', }; +const hash = '#L142'; + describe('Chunk component', () => { let wrapper; + let idleCallbackSpy; const createComponent = (props = {}) => { - wrapper = shallowMountExtended(Chunk, { propsData: { ...DEFAULT_PROPS, ...props } }); + wrapper = shallowMountExtended(Chunk, { + mocks: { $route: { hash } }, + propsData: { ...DEFAULT_PROPS, ...props }, + }); }; const findIntersectionObserver = () => wrapper.findComponent(GlIntersectionObserver); @@ -26,6 +35,7 @@ describe('Chunk component', () => { const findContent = () => wrapper.findByTestId('content'); beforeEach(() => { + idleCallbackSpy = jest.spyOn(window, 'requestIdleCallback').mockImplementation((fn) => fn()); createComponent(); }); @@ -51,18 +61,30 @@ describe('Chunk component', () => { }); describe('rendering', () => { + it('does not register window.requestIdleCallback if isFirstChunk prop is true, renders lines immediately', () => { + jest.clearAllMocks(); + createComponent({ isFirstChunk: true }); + + expect(window.requestIdleCallback).not.toHaveBeenCalled(); + expect(findContent().exists()).toBe(true); + }); + it('does not render a Chunk Line component if isHighlighted is false', () => { expect(findChunkLines().length).toBe(0); }); + it('does not render simplified line numbers and content if browser is not in idle state', () => { + idleCallbackSpy.mockRestore(); + createComponent(); + + expect(findLineNumbers()).toHaveLength(0); + expect(findContent().exists()).toBe(false); + }); + it('renders simplified line numbers and content if isHighlighted is false', () => { expect(findLineNumbers().length).toBe(DEFAULT_PROPS.totalLines); - expect(findLineNumbers().at(0).attributes()).toMatchObject({ - 'data-line-number': `${DEFAULT_PROPS.startingFrom + 1}`, - href: `#L${DEFAULT_PROPS.startingFrom + 1}`, - id: `L${DEFAULT_PROPS.startingFrom + 1}`, - }); + expect(findLineNumbers().at(0).attributes('id')).toBe(`L${DEFAULT_PROPS.startingFrom + 1}`); expect(findContent().text()).toBe(DEFAULT_PROPS.content); }); @@ -80,5 +102,14 @@ describe('Chunk component', () => { blamePath: DEFAULT_PROPS.blamePath, }); }); + + it('does not scroll to route hash if last chunk is not loaded', () => { + expect(scrollToElement).not.toHaveBeenCalled(); + }); + + it('scrolls to route hash if last chunk is loaded', () => { + createComponent({ totalChunks: DEFAULT_PROPS.chunkIndex + 1 }); + expect(scrollToElement).toHaveBeenCalledWith(hash, { behavior: 'auto' }); + }); }); }); diff --git a/spec/frontend/vue_shared/components/source_viewer/plugins/link_dependencies_spec.js b/spec/frontend/vue_shared/components/source_viewer/plugins/link_dependencies_spec.js index 375b1307616..a7b55d7332f 100644 --- a/spec/frontend/vue_shared/components/source_viewer/plugins/link_dependencies_spec.js +++ b/spec/frontend/vue_shared/components/source_viewer/plugins/link_dependencies_spec.js @@ -1,10 +1,26 @@ import packageJsonLinker from '~/vue_shared/components/source_viewer/plugins/utils/package_json_linker'; +import godepsJsonLinker from '~/vue_shared/components/source_viewer/plugins/utils/godeps_json_linker'; import gemspecLinker from '~/vue_shared/components/source_viewer/plugins/utils/gemspec_linker'; +import gemfileLinker from '~/vue_shared/components/source_viewer/plugins/utils/gemfile_linker'; +import podspecJsonLinker from '~/vue_shared/components/source_viewer/plugins/utils/podspec_json_linker'; +import composerJsonLinker from '~/vue_shared/components/source_viewer/plugins/utils/composer_json_linker'; import linkDependencies from '~/vue_shared/components/source_viewer/plugins/link_dependencies'; -import { PACKAGE_JSON_FILE_TYPE, PACKAGE_JSON_CONTENT, GEMSPEC_FILE_TYPE } from './mock_data'; +import { + PACKAGE_JSON_FILE_TYPE, + PACKAGE_JSON_CONTENT, + GEMSPEC_FILE_TYPE, + GODEPS_JSON_FILE_TYPE, + GEMFILE_FILE_TYPE, + PODSPEC_JSON_FILE_TYPE, + COMPOSER_JSON_FILE_TYPE, +} from './mock_data'; jest.mock('~/vue_shared/components/source_viewer/plugins/utils/package_json_linker'); jest.mock('~/vue_shared/components/source_viewer/plugins/utils/gemspec_linker'); +jest.mock('~/vue_shared/components/source_viewer/plugins/utils/godeps_json_linker'); +jest.mock('~/vue_shared/components/source_viewer/plugins/utils/gemfile_linker'); +jest.mock('~/vue_shared/components/source_viewer/plugins/utils/podspec_json_linker'); +jest.mock('~/vue_shared/components/source_viewer/plugins/utils/composer_json_linker'); describe('Highlight.js plugin for linking dependencies', () => { const hljsResultMock = { value: 'test' }; @@ -18,4 +34,24 @@ describe('Highlight.js plugin for linking dependencies', () => { linkDependencies(hljsResultMock, GEMSPEC_FILE_TYPE); expect(gemspecLinker).toHaveBeenCalled(); }); + + it('calls godepsJsonLinker for godeps_json file types', () => { + linkDependencies(hljsResultMock, GODEPS_JSON_FILE_TYPE); + expect(godepsJsonLinker).toHaveBeenCalled(); + }); + + it('calls gemfileLinker for gemfile file types', () => { + linkDependencies(hljsResultMock, GEMFILE_FILE_TYPE); + expect(gemfileLinker).toHaveBeenCalled(); + }); + + it('calls podspecJsonLinker for podspec_json file types', () => { + linkDependencies(hljsResultMock, PODSPEC_JSON_FILE_TYPE); + expect(podspecJsonLinker).toHaveBeenCalled(); + }); + + it('calls composerJsonLinker for composer_json file types', () => { + linkDependencies(hljsResultMock, COMPOSER_JSON_FILE_TYPE); + expect(composerJsonLinker).toHaveBeenCalled(); + }); }); diff --git a/spec/frontend/vue_shared/components/source_viewer/plugins/mock_data.js b/spec/frontend/vue_shared/components/source_viewer/plugins/mock_data.js index aa874c9c081..5455479ec71 100644 --- a/spec/frontend/vue_shared/components/source_viewer/plugins/mock_data.js +++ b/spec/frontend/vue_shared/components/source_viewer/plugins/mock_data.js @@ -1,4 +1,34 @@ export const PACKAGE_JSON_FILE_TYPE = 'package_json'; + export const PACKAGE_JSON_CONTENT = '{ "dependencies": { "@babel/core": "^7.18.5" } }'; +export const COMPOSER_JSON_EXAMPLES = { + packagist: '{ "require": { "composer/installers": "^1.2" } }', + drupal: '{ "require": { "drupal/bootstrap": "3.x-dev" } }', + withoutLink: '{ "require": { "drupal/erp_common": "dev-master" } }', +}; + export const GEMSPEC_FILE_TYPE = 'gemspec'; + +export const GODEPS_JSON_FILE_TYPE = 'godeps_json'; + +export const GEMFILE_FILE_TYPE = 'gemfile'; + +export const PODSPEC_JSON_FILE_TYPE = 'podspec_json'; + +export const PODSPEC_JSON_CONTENT = `{ + "dependencies": { + "MyCheckCore": [ + ] + }, + "subspecs": [ + { + "dependencies": { + "AFNetworking/Security": [ + ] + } + } + ] + }`; + +export const COMPOSER_JSON_FILE_TYPE = 'composer_json'; diff --git a/spec/frontend/vue_shared/components/source_viewer/plugins/utils/composer_json_linker_spec.js b/spec/frontend/vue_shared/components/source_viewer/plugins/utils/composer_json_linker_spec.js new file mode 100644 index 00000000000..3ecb16ddcd0 --- /dev/null +++ b/spec/frontend/vue_shared/components/source_viewer/plugins/utils/composer_json_linker_spec.js @@ -0,0 +1,38 @@ +import composerJsonLinker from '~/vue_shared/components/source_viewer/plugins/utils/composer_json_linker'; +import { COMPOSER_JSON_EXAMPLES } from '../mock_data'; + +describe('Highlight.js plugin for linking composer.json dependencies', () => { + it('mutates the input value by wrapping dependency names and versions in anchors', () => { + const inputValue = + '<span class="hljs-attr">"drupal/erp_common""</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"dev-master"</span>'; + const outputValue = + '<span class="hljs-attr">"drupal/erp_common""</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"dev-master"</span>'; + const hljsResultMock = { value: inputValue }; + + const output = composerJsonLinker(hljsResultMock, COMPOSER_JSON_EXAMPLES.withoutLink); + expect(output).toBe(outputValue); + }); +}); + +const getInputValue = (dependencyString, version) => + `<span class="hljs-attr">"${dependencyString}"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"${version}"</span>`; +const getOutputValue = (dependencyString, version, expectedHref) => + `<span class="hljs-attr">"<a href="${expectedHref}" target="_blank" rel="nofollow noreferrer noopener">${dependencyString}</a>"</span>: <span class="hljs-attr">"<a href="${expectedHref}" target="_blank" rel="nofollow noreferrer noopener">${version}</a>"</span>`; + +describe('Highlight.js plugin for linking Godeps.json dependencies', () => { + it.each` + type | dependency | version | expectedHref + ${'packagist'} | ${'composer/installers'} | ${'^1.2'} | ${'https://packagist.org/packages/composer/installers'} + ${'drupal'} | ${'drupal/bootstrap'} | ${'3.x-dev'} | ${'https://www.drupal.org/project/bootstrap'} + `( + 'mutates the input value by wrapping dependency names in anchors and altering path when needed', + ({ type, dependency, version, expectedHref }) => { + const inputValue = getInputValue(dependency, version); + const outputValue = getOutputValue(dependency, version, expectedHref); + const hljsResultMock = { value: inputValue }; + + const output = composerJsonLinker(hljsResultMock, COMPOSER_JSON_EXAMPLES[type]); + expect(output).toBe(outputValue); + }, + ); +}); diff --git a/spec/frontend/vue_shared/components/source_viewer/plugins/utils/dependency_linker_util_spec.js b/spec/frontend/vue_shared/components/source_viewer/plugins/utils/dependency_linker_util_spec.js index e4ce07ec668..66e2020da27 100644 --- a/spec/frontend/vue_shared/components/source_viewer/plugins/utils/dependency_linker_util_spec.js +++ b/spec/frontend/vue_shared/components/source_viewer/plugins/utils/dependency_linker_util_spec.js @@ -1,13 +1,15 @@ import { createLink, generateHLJSOpenTag, + getObjectKeysByKeyName, } from '~/vue_shared/components/source_viewer/plugins/utils/dependency_linker_util'; +import { PODSPEC_JSON_CONTENT } from '../mock_data'; describe('createLink', () => { it('generates a link with the correct attributes', () => { const href = 'http://test.com'; const innerText = 'testing'; - const result = `<a href="${href}" rel="nofollow noreferrer noopener">${innerText}</a>`; + const result = `<a href="${href}" target="_blank" rel="nofollow noreferrer noopener">${innerText}</a>`; expect(createLink(href, innerText)).toBe(result); }); @@ -18,7 +20,7 @@ describe('createLink', () => { const escapedHref = '<script>XSS</script>'; const href = `http://test.com/${unescapedXSS}`; const innerText = `testing${unescapedXSS}`; - const result = `<a href="http://test.com/${escapedHref}" rel="nofollow noreferrer noopener">testing${escapedPackageName}</a>`; + const result = `<a href="http://test.com/${escapedHref}" target="_blank" rel="nofollow noreferrer noopener">testing${escapedPackageName}</a>`; expect(createLink(href, innerText)).toBe(result); }); @@ -32,3 +34,11 @@ describe('generateHLJSOpenTag', () => { expect(generateHLJSOpenTag(type)).toBe(result); }); }); + +describe('getObjectKeysByKeyName method', () => { + it('gets all object keys within specified key', () => { + const acc = []; + const keys = getObjectKeysByKeyName(JSON.parse(PODSPEC_JSON_CONTENT), 'dependencies', acc); + expect(keys).toEqual(['MyCheckCore', 'AFNetworking/Security']); + }); +}); diff --git a/spec/frontend/vue_shared/components/source_viewer/plugins/utils/gemfile_linker_spec.js b/spec/frontend/vue_shared/components/source_viewer/plugins/utils/gemfile_linker_spec.js new file mode 100644 index 00000000000..4e188c9af7e --- /dev/null +++ b/spec/frontend/vue_shared/components/source_viewer/plugins/utils/gemfile_linker_spec.js @@ -0,0 +1,13 @@ +import gemfileLinker from '~/vue_shared/components/source_viewer/plugins/utils/gemfile_linker'; + +describe('Highlight.js plugin for linking gemfile dependencies', () => { + it('mutates the input value by wrapping dependency names in anchors', () => { + const inputValue = 'gem </span><span class="hljs-string">'paranoia''; + const outputValue = + 'gem </span><span class="hljs-string">'<a href="https://rubygems.org/gems/paranoia" target="_blank" rel="nofollow noreferrer noopener">paranoia</a>''; + const hljsResultMock = { value: inputValue }; + + const output = gemfileLinker(hljsResultMock); + expect(output).toBe(outputValue); + }); +}); diff --git a/spec/frontend/vue_shared/components/source_viewer/plugins/utils/gemspec_linker_spec.js b/spec/frontend/vue_shared/components/source_viewer/plugins/utils/gemspec_linker_spec.js index 3f74bfa117f..4b104b0bf43 100644 --- a/spec/frontend/vue_shared/components/source_viewer/plugins/utils/gemspec_linker_spec.js +++ b/spec/frontend/vue_shared/components/source_viewer/plugins/utils/gemspec_linker_spec.js @@ -5,7 +5,7 @@ describe('Highlight.js plugin for linking gemspec dependencies', () => { const inputValue = 's.add_dependency(<span class="hljs-string">'rugged'</span>, <span class="hljs-string">'~> 0.24.0'</span>)'; const outputValue = - 's.add_dependency(<span class="hljs-string linked">'<a href="https://rubygems.org/gems/rugged" rel="nofollow noreferrer noopener">rugged</a>'</span>, <span class="hljs-string">'~> 0.24.0'</span>)'; + 's.add_dependency(<span class="hljs-string linked">'<a href="https://rubygems.org/gems/rugged" target="_blank" rel="nofollow noreferrer noopener">rugged</a>'</span>, <span class="hljs-string">'~> 0.24.0'</span>)'; const hljsResultMock = { value: inputValue }; const output = gemspecLinker(hljsResultMock); diff --git a/spec/frontend/vue_shared/components/source_viewer/plugins/utils/godeps_json_linker_spec.js b/spec/frontend/vue_shared/components/source_viewer/plugins/utils/godeps_json_linker_spec.js new file mode 100644 index 00000000000..ea7e3936846 --- /dev/null +++ b/spec/frontend/vue_shared/components/source_viewer/plugins/utils/godeps_json_linker_spec.js @@ -0,0 +1,27 @@ +import godepsJsonLinker from '~/vue_shared/components/source_viewer/plugins/utils/godeps_json_linker'; + +const getInputValue = (dependencyString) => + `<span class="hljs-attr">"ImportPath"</span><span class="hljs-punctuation">:</span><span class=""> </span><span class="hljs-string">"${dependencyString}"</span>`; +const getOutputValue = (dependencyString, expectedHref) => + `<span class="hljs-attr">"ImportPath"</span><span class="hljs-punctuation">:</span><span class=""> </span><span class="hljs-attr">"<a href="${expectedHref}" target="_blank" rel="nofollow noreferrer noopener">${dependencyString}</a>"</span>`; + +describe('Highlight.js plugin for linking Godeps.json dependencies', () => { + it.each` + dependency | expectedHref + ${'gitlab.com/group/project/path'} | ${'https://gitlab.com/group/project/_/tree/master/path'} + ${'gitlab.com/group/subgroup/project.git/path'} | ${'https://gitlab.com/group/subgroup/_/tree/master/project.git/path'} + ${'github.com/docker/docker/pkg/homedir'} | ${'https://github.com/docker/docker/tree/master/pkg/homedir'} + ${'golang.org/x/net/http2'} | ${'https://godoc.org/golang.org/x/net/http2'} + ${'gopkg.in/yaml.v1'} | ${'https://gopkg.in/yaml.v1'} + `( + 'mutates the input value by wrapping dependency names in anchors and altering path when needed', + ({ dependency, expectedHref }) => { + const inputValue = getInputValue(dependency); + const outputValue = getOutputValue(dependency, expectedHref); + const hljsResultMock = { value: inputValue }; + + const output = godepsJsonLinker(hljsResultMock); + expect(output).toBe(outputValue); + }, + ); +}); diff --git a/spec/frontend/vue_shared/components/source_viewer/plugins/utils/package_json_linker_spec.js b/spec/frontend/vue_shared/components/source_viewer/plugins/utils/package_json_linker_spec.js index e83c129818c..170a44f8ee2 100644 --- a/spec/frontend/vue_shared/components/source_viewer/plugins/utils/package_json_linker_spec.js +++ b/spec/frontend/vue_shared/components/source_viewer/plugins/utils/package_json_linker_spec.js @@ -6,7 +6,7 @@ describe('Highlight.js plugin for linking package.json dependencies', () => { const inputValue = '<span class="hljs-attr">"@babel/core"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"^7.18.5"</span>'; const outputValue = - '<span class="hljs-attr">"<a href="https://npmjs.com/package/@babel/core" rel="nofollow noreferrer noopener">@babel/core</a>"</span>: <span class="hljs-attr">"<a href="https://npmjs.com/package/@babel/core" rel="nofollow noreferrer noopener">^7.18.5</a>"</span>'; + '<span class="hljs-attr">"<a href="https://npmjs.com/package/@babel/core" target="_blank" rel="nofollow noreferrer noopener">@babel/core</a>"</span>: <span class="hljs-attr">"<a href="https://npmjs.com/package/@babel/core" target="_blank" rel="nofollow noreferrer noopener">^7.18.5</a>"</span>'; const hljsResultMock = { value: inputValue }; const output = packageJsonLinker(hljsResultMock, PACKAGE_JSON_CONTENT); diff --git a/spec/frontend/vue_shared/components/source_viewer/plugins/utils/podspec_json_linker_spec.js b/spec/frontend/vue_shared/components/source_viewer/plugins/utils/podspec_json_linker_spec.js new file mode 100644 index 00000000000..0ef63de68c6 --- /dev/null +++ b/spec/frontend/vue_shared/components/source_viewer/plugins/utils/podspec_json_linker_spec.js @@ -0,0 +1,14 @@ +import podspecJsonLinker from '~/vue_shared/components/source_viewer/plugins/utils/podspec_json_linker'; +import { PODSPEC_JSON_CONTENT } from '../mock_data'; + +describe('Highlight.js plugin for linking podspec_json dependencies', () => { + it('mutates the input value by wrapping dependency names in anchors', () => { + const inputValue = + '<span class="hljs-attr">"AFNetworking/Security"</span><span class="hljs-punctuation">:</span><span class=""> </span><span class="hljs-punctuation">['; + const outputValue = + '<span class="hljs-attr">"<a href="https://cocoapods.org/pods/AFNetworking" target="_blank" rel="nofollow noreferrer noopener">AFNetworking/Security</a>"</span><span class="hljs-punctuation">:</span><span class=""> </span><span class="hljs-punctuation">['; + const hljsResultMock = { value: inputValue }; + const output = podspecJsonLinker(hljsResultMock, PODSPEC_JSON_CONTENT); + expect(output).toBe(outputValue); + }); +}); diff --git a/spec/frontend/vue_shared/components/source_viewer/plugins/wrap_child_nodes_spec.js b/spec/frontend/vue_shared/components/source_viewer/plugins/wrap_child_nodes_spec.js index bc6df1a2565..8d072c8c8de 100644 --- a/spec/frontend/vue_shared/components/source_viewer/plugins/wrap_child_nodes_spec.js +++ b/spec/frontend/vue_shared/components/source_viewer/plugins/wrap_child_nodes_spec.js @@ -8,13 +8,14 @@ describe('Highlight.js plugin for wrapping _emitter nodes', () => { children: [ { kind: 'string', children: ['Text 1'] }, { kind: 'string', children: ['Text 2', { kind: 'comment', children: ['Text 3'] }] }, + { kind: undefined, sublanguage: true, children: ['Text 3 (sublanguage)'] }, 'Text4\nText5', ], }, }, }; - const outputValue = `<span class="hljs-string">Text 1</span><span class="hljs-string"><span class="hljs-string">Text 2</span><span class="hljs-comment">Text 3</span></span><span class="">Text4</span>\n<span class="">Text5</span>`; + const outputValue = `<span class="hljs-string">Text 1</span><span class="hljs-string"><span class="hljs-string">Text 2</span><span class="hljs-comment">Text 3</span></span><span class="">Text 3 (sublanguage)</span><span class="">Text4</span>\n<span class="">Text5</span>`; wrapChildNodes(hljsResultMock); expect(hljsResultMock.value).toBe(outputValue); diff --git a/spec/frontend/vue_shared/components/source_viewer/source_viewer_spec.js b/spec/frontend/vue_shared/components/source_viewer/source_viewer_spec.js index 6d319b37b02..33f370efdfa 100644 --- a/spec/frontend/vue_shared/components/source_viewer/source_viewer_spec.js +++ b/spec/frontend/vue_shared/components/source_viewer/source_viewer_spec.js @@ -10,6 +10,7 @@ import { EVENT_LABEL_VIEWER, EVENT_LABEL_FALLBACK, ROUGE_TO_HLJS_LANGUAGE_MAP, + LINES_PER_CHUNK, } from '~/vue_shared/components/source_viewer/constants'; import waitForPromises from 'helpers/wait_for_promises'; import LineHighlighter from '~/blob/line_highlighter'; @@ -121,6 +122,7 @@ describe('Source Viewer component', () => { it('highlights the first chunk', () => { expect(hljs.highlight).toHaveBeenCalledWith(chunk1.trim(), { language: mappedLanguage }); + expect(findChunks().at(0).props('isFirstChunk')).toBe(true); }); describe('auto-detects if a language cannot be loaded', () => { @@ -133,45 +135,27 @@ describe('Source Viewer component', () => { }); describe('rendering', () => { - it('renders the first chunk', async () => { - const firstChunk = findChunks().at(0); - - expect(firstChunk.props('content')).toContain(chunk1); - - expect(firstChunk.props()).toMatchObject({ - totalLines: 70, - startingFrom: 0, + it.each` + chunkIndex | chunkContent | totalChunks + ${0} | ${chunk1} | ${0} + ${1} | ${chunk2} | ${3} + ${2} | ${chunk3Result} | ${3} + `('renders chunk $chunkIndex', ({ chunkIndex, chunkContent, totalChunks }) => { + const chunk = findChunks().at(chunkIndex); + + expect(chunk.props('content')).toContain(chunkContent.trim()); + + expect(chunk.props()).toMatchObject({ + totalLines: LINES_PER_CHUNK, + startingFrom: LINES_PER_CHUNK * chunkIndex, + totalChunks, }); }); - it('renders the second chunk', async () => { - const secondChunk = findChunks().at(1); - - expect(secondChunk.props('content')).toContain(chunk2.trim()); - - expect(secondChunk.props()).toMatchObject({ - totalLines: 70, - startingFrom: 70, - }); + it('emits showBlobInteractionZones on the eventHub when chunk appears', () => { + findChunks().at(0).vm.$emit('appear'); + expect(eventHub.$emit).toHaveBeenCalledWith('showBlobInteractionZones', path); }); - - it('renders the third chunk', async () => { - const thirdChunk = findChunks().at(2); - - expect(thirdChunk.props('content')).toContain(chunk3Result.trim()); - - expect(chunk3Result).toEqual(chunk3.replace(/\r?\n/g, '\n')); - - expect(thirdChunk.props()).toMatchObject({ - totalLines: 70, - startingFrom: 140, - }); - }); - }); - - it('emits showBlobInteractionZones on the eventHub when chunk appears', () => { - findChunks().at(0).vm.$emit('appear'); - expect(eventHub.$emit).toHaveBeenCalledWith('showBlobInteractionZones', path); }); describe('LineHighlighter', () => { |