diff options
Diffstat (limited to 'spec/javascripts/ide/components')
13 files changed, 48 insertions, 69 deletions
diff --git a/spec/javascripts/ide/components/branches/item_spec.js b/spec/javascripts/ide/components/branches/item_spec.js index 249b80bbba6..36b6736bfd4 100644 --- a/spec/javascripts/ide/components/branches/item_spec.js +++ b/spec/javascripts/ide/components/branches/item_spec.js @@ -36,7 +36,8 @@ describe('IDE branch item', () => { }); it('renders link to branch', () => { - const expectedHref = router.resolve(`/project/${TEST_PROJECT_ID}/edit/${TEST_BRANCH.name}`).href; + const expectedHref = router.resolve(`/project/${TEST_PROJECT_ID}/edit/${TEST_BRANCH.name}`) + .href; expect(vm.$el).toMatch('a'); expect(vm.$el).toHaveAttr('href', expectedHref); diff --git a/spec/javascripts/ide/components/branches/search_list_spec.js b/spec/javascripts/ide/components/branches/search_list_spec.js index c3f84ba1c24..72a3c2d5dcd 100644 --- a/spec/javascripts/ide/components/branches/search_list_spec.js +++ b/spec/javascripts/ide/components/branches/search_list_spec.js @@ -62,8 +62,9 @@ describe('IDE branches search list', () => { }); it('renders list', () => { - const elementText = Array.from(vm.$el.querySelectorAll('li strong')) - .map(x => x.textContent.trim()); + const elementText = Array.from(vm.$el.querySelectorAll('li strong')).map(x => + x.textContent.trim(), + ); expect(elementText).toEqual(testBranches.map(x => x.name)); }); diff --git a/spec/javascripts/ide/components/commit_sidebar/message_field_spec.js b/spec/javascripts/ide/components/commit_sidebar/message_field_spec.js index c06dfa46303..af67991eadd 100644 --- a/spec/javascripts/ide/components/commit_sidebar/message_field_spec.js +++ b/spec/javascripts/ide/components/commit_sidebar/message_field_spec.js @@ -36,8 +36,7 @@ describe('IDE commit message field', () => { it('removed is-focused class on blur', done => { vm.$el.querySelector('textarea').focus(); - vm - .$nextTick() + vm.$nextTick() .then(() => { expect(vm.$el.querySelector('.is-focused')).not.toBeNull(); @@ -70,8 +69,7 @@ describe('IDE commit message field', () => { it('does not highlight less than 50 characters', done => { vm.text = 'text less than 50 chars'; - vm - .$nextTick() + vm.$nextTick() .then(() => { expect(vm.$el.querySelector('.highlights span').textContent).toContain( 'text less than 50 chars', @@ -87,8 +85,7 @@ describe('IDE commit message field', () => { vm.text = 'text less than 50 chars that should not highlighted. text more than 50 should be highlighted'; - vm - .$nextTick() + vm.$nextTick() .then(() => { expect(vm.$el.querySelector('.highlights span').textContent).toContain( 'text less than 50 chars that should not highlighte', @@ -108,8 +105,7 @@ describe('IDE commit message field', () => { it('does not highlight body text less tan 72 characters', done => { vm.text = 'subject line\nbody content'; - vm - .$nextTick() + vm.$nextTick() .then(() => { expect(vm.$el.querySelectorAll('.highlights span').length).toBe(2); expect(vm.$el.querySelectorAll('mark')[1].style.display).toBe('none'); @@ -122,8 +118,7 @@ describe('IDE commit message field', () => { vm.text = 'subject line\nbody content that will be highlighted when it is more than 72 characters in length'; - vm - .$nextTick() + vm.$nextTick() .then(() => { expect(vm.$el.querySelectorAll('.highlights span').length).toBe(2); expect(vm.$el.querySelectorAll('mark')[1].style.display).not.toBe('none'); @@ -137,8 +132,7 @@ describe('IDE commit message field', () => { vm.text = 'text less than 50 chars that should not highlighted\nbody content that will be highlighted when it is more than 72 characters in length'; - vm - .$nextTick() + vm.$nextTick() .then(() => { expect(vm.$el.querySelectorAll('.highlights span').length).toBe(2); expect(vm.$el.querySelectorAll('mark').length).toBe(2); @@ -156,8 +150,7 @@ describe('IDE commit message field', () => { it('updates transform of highlights', done => { vm.text = 'subject line\n\n\n\n\n\n\n\n\n\n\nbody content'; - vm - .$nextTick() + vm.$nextTick() .then(() => { vm.$el.querySelector('textarea').scrollTo(0, 50); diff --git a/spec/javascripts/ide/components/file_finder/index_spec.js b/spec/javascripts/ide/components/file_finder/index_spec.js index 4f208e946d2..4d934f92f72 100644 --- a/spec/javascripts/ide/components/file_finder/index_spec.js +++ b/spec/javascripts/ide/components/file_finder/index_spec.js @@ -85,8 +85,7 @@ describe('IDE File finder item spec', () => { it('clear button resets searchText', done => { vm.searchText = 'index'; - vm - .$nextTick() + vm.$nextTick() .then(() => { vm.$el.querySelector('.dropdown-input-clear').click(); }) @@ -102,8 +101,7 @@ describe('IDE File finder item spec', () => { spyOn(vm.$refs.searchInput, 'focus'); vm.searchText = 'index'; - vm - .$nextTick() + vm.$nextTick() .then(() => { vm.$el.querySelector('.dropdown-input-clear').click(); }) @@ -178,8 +176,7 @@ describe('IDE File finder item spec', () => { vm.searchText = 'test'; vm.$store.state.fileFindVisible = true; - vm - .$nextTick() + vm.$nextTick() .then(() => { vm.$store.state.fileFindVisible = false; }) diff --git a/spec/javascripts/ide/components/ide_spec.js b/spec/javascripts/ide/components/ide_spec.js index 49b8e934cdd..c02a1ad246c 100644 --- a/spec/javascripts/ide/components/ide_spec.js +++ b/spec/javascripts/ide/components/ide_spec.js @@ -84,8 +84,7 @@ describe('ide component', () => { it('calls toggleFileFinder on `t` key press', done => { Mousetrap.trigger('t'); - vm - .$nextTick() + vm.$nextTick() .then(() => { expect(vm.toggleFileFinder).toHaveBeenCalled(); }) @@ -96,8 +95,7 @@ describe('ide component', () => { it('calls toggleFileFinder on `command+p` key press', done => { Mousetrap.trigger('command+p'); - vm - .$nextTick() + vm.$nextTick() .then(() => { expect(vm.toggleFileFinder).toHaveBeenCalled(); }) @@ -108,8 +106,7 @@ describe('ide component', () => { it('calls toggleFileFinder on `ctrl+p` key press', done => { Mousetrap.trigger('ctrl+p'); - vm - .$nextTick() + vm.$nextTick() .then(() => { expect(vm.toggleFileFinder).toHaveBeenCalled(); }) diff --git a/spec/javascripts/ide/components/ide_status_bar_spec.js b/spec/javascripts/ide/components/ide_status_bar_spec.js index 9874e7b597e..ab032b4cb98 100644 --- a/spec/javascripts/ide/components/ide_status_bar_spec.js +++ b/spec/javascripts/ide/components/ide_status_bar_spec.js @@ -78,8 +78,7 @@ describe('ideStatusBar', () => { }, }); - vm - .$nextTick() + vm.$nextTick() .then(() => { vm.$el.querySelector('.ide-status-pipeline button').click(); diff --git a/spec/javascripts/ide/components/jobs/detail_spec.js b/spec/javascripts/ide/components/jobs/detail_spec.js index 8f8d4b9709e..a4e6b81acba 100644 --- a/spec/javascripts/ide/components/jobs/detail_spec.js +++ b/spec/javascripts/ide/components/jobs/detail_spec.js @@ -109,8 +109,7 @@ describe('IDE jobs detail view', () => { vm.scrollPos = 1; - vm - .$nextTick() + vm.$nextTick() .then(() => vm.$el.querySelector('.btn-scroll').click()) .then(() => vm.$nextTick()) .then(() => { diff --git a/spec/javascripts/ide/components/merge_requests/item_spec.js b/spec/javascripts/ide/components/merge_requests/item_spec.js index c92e6b89c78..155a247defb 100644 --- a/spec/javascripts/ide/components/merge_requests/item_spec.js +++ b/spec/javascripts/ide/components/merge_requests/item_spec.js @@ -29,7 +29,9 @@ describe('IDE merge request item', () => { }); it('renders link with href', () => { - const expectedHref = router.resolve(`/project/${vm.item.projectPathWithNamespace}/merge_requests/${vm.item.iid}`).href; + const expectedHref = router.resolve( + `/project/${vm.item.projectPathWithNamespace}/merge_requests/${vm.item.iid}`, + ).href; expect(vm.$el).toMatch('a'); expect(vm.$el).toHaveAttr('href', expectedHref); diff --git a/spec/javascripts/ide/components/merge_requests/list_spec.js b/spec/javascripts/ide/components/merge_requests/list_spec.js index c761315444c..55e4f46d9ca 100644 --- a/spec/javascripts/ide/components/merge_requests/list_spec.js +++ b/spec/javascripts/ide/components/merge_requests/list_spec.js @@ -118,8 +118,9 @@ describe('IDE merge requests list', () => { vm.$nextTick() .then(() => { const expectedSearchTypes = vm.$options.searchTypes.map(x => x.label); - const renderedSearchTypes = Array.from(vm.$el.querySelectorAll('li')) - .map(x => x.textContent.trim()); + const renderedSearchTypes = Array.from(vm.$el.querySelectorAll('li')).map(x => + x.textContent.trim(), + ); expect(renderedSearchTypes).toEqual(expectedSearchTypes); }) diff --git a/spec/javascripts/ide/components/new_dropdown/upload_spec.js b/spec/javascripts/ide/components/new_dropdown/upload_spec.js index 70b885ede26..878e17ac805 100644 --- a/spec/javascripts/ide/components/new_dropdown/upload_spec.js +++ b/spec/javascripts/ide/components/new_dropdown/upload_spec.js @@ -40,21 +40,10 @@ describe('new dropdown upload', () => { describe('readFile', () => { beforeEach(() => { - spyOn(FileReader.prototype, 'readAsText'); spyOn(FileReader.prototype, 'readAsDataURL'); }); - it('calls readAsText for text files', () => { - const file = { - type: 'text/html', - }; - - vm.readFile(file); - - expect(FileReader.prototype.readAsText).toHaveBeenCalledWith(file); - }); - - it('calls readAsDataURL for non-text files', () => { + it('calls readAsDataURL for all files', () => { const file = { type: 'images/png', }; @@ -66,32 +55,37 @@ describe('new dropdown upload', () => { }); describe('createFile', () => { - const target = { - result: 'content', + const textTarget = { + result: 'base64,cGxhaW4gdGV4dA==', }; const binaryTarget = { - result: 'base64,base64content', + result: 'base64,w4I=', + }; + const textFile = { + name: 'textFile', + type: 'text/plain', }; - const file = { - name: 'file', + const binaryFile = { + name: 'binaryFile', + type: 'image/png', }; - it('creates new file', () => { - vm.createFile(target, file, true); + it('creates file in plain text (without encoding) if the file content is plain text', () => { + vm.createFile(textTarget, textFile); expect(vm.$emit).toHaveBeenCalledWith('create', { - name: file.name, + name: textFile.name, type: 'blob', - content: target.result, + content: 'plain text', base64: false, }); }); it('splits content on base64 if binary', () => { - vm.createFile(binaryTarget, file, false); + vm.createFile(binaryTarget, binaryFile); expect(vm.$emit).toHaveBeenCalledWith('create', { - name: file.name, + name: binaryFile.name, type: 'blob', content: binaryTarget.result.split('base64,')[1], base64: true, diff --git a/spec/javascripts/ide/components/preview/clientside_spec.js b/spec/javascripts/ide/components/preview/clientside_spec.js index d6983f5a3b8..b9bf5c51ffe 100644 --- a/spec/javascripts/ide/components/preview/clientside_spec.js +++ b/spec/javascripts/ide/components/preview/clientside_spec.js @@ -59,8 +59,7 @@ describe('IDE clientside preview', () => { }), ); - vm - .$nextTick() + vm.$nextTick() .then(() => vm.initPreview()) .then(vm.$nextTick) .then(done) diff --git a/spec/javascripts/ide/components/repo_editor_spec.js b/spec/javascripts/ide/components/repo_editor_spec.js index d9136d636d0..002b5a005b8 100644 --- a/spec/javascripts/ide/components/repo_editor_spec.js +++ b/spec/javascripts/ide/components/repo_editor_spec.js @@ -125,8 +125,7 @@ describe('RepoEditor', () => { vm.file.path = `${vm.file.path}.md`; vm.$store.state.entries[vm.file.path] = vm.file; - vm - .$nextTick() + vm.$nextTick() .then(() => { vm.$el.querySelectorAll('.ide-mode-tabs .nav-links a')[1].click(); }) @@ -297,8 +296,7 @@ describe('RepoEditor', () => { it('calls updateDimensions when panelResizing is false', done => { vm.$store.state.panelResizing = true; - vm - .$nextTick() + vm.$nextTick() .then(() => { vm.$store.state.panelResizing = false; }) @@ -366,8 +364,7 @@ describe('RepoEditor', () => { vm.file.pending = true; - vm - .$nextTick() + vm.$nextTick() .then(() => { vm.file = file('testing'); diff --git a/spec/javascripts/ide/components/shared/tokened_input_spec.js b/spec/javascripts/ide/components/shared/tokened_input_spec.js index 935ee0beea8..b09bf760543 100644 --- a/spec/javascripts/ide/components/shared/tokened_input_spec.js +++ b/spec/javascripts/ide/components/shared/tokened_input_spec.js @@ -44,8 +44,7 @@ describe('IDE shared/TokenedInput', () => { }); it('renders tokens', () => { - const renderedTokens = getTokenElements(vm) - .map(x => x.textContent.trim()); + const renderedTokens = getTokenElements(vm).map(x => x.textContent.trim()); expect(renderedTokens).toEqual(TEST_TOKENS.map(x => x.label)); }); |