From da406972f22e49dd717d41c14ef5b90b0cf3bdcf Mon Sep 17 00:00:00 2001 From: Konstantin Popov Date: Mon, 5 Jun 2017 17:48:26 +0300 Subject: [PATCH] Fix archive summary text. --- lib/archive-editor-view.js | 4 ++-- spec/archive-editor-view-spec.coffee | 15 +++++++++++++++ spec/fixtures/multiple-entries.zip | Bin 0 -> 704 bytes 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 spec/fixtures/multiple-entries.zip diff --git a/lib/archive-editor-view.js b/lib/archive-editor-view.js index 9476455..be41437 100644 --- a/lib/archive-editor-view.js +++ b/lib/archive-editor-view.js @@ -107,10 +107,10 @@ export default class ArchiveEditorView { } updateSummary () { - const fileCount = this.entries.filter((entry) => entry instanceof FileView) + const fileCount = this.entries.filter((entry) => entry instanceof FileView).length const fileLabel = fileCount === 1 ? '1 file' : `${humanize.intComma(fileCount)} files` - const directoryCount = this.entries.filter((entry) => entry instanceof DirectoryView) + const directoryCount = this.entries.filter((entry) => entry instanceof DirectoryView).length const directoryLabel = directoryCount === 1 ? '1 folder' : `${humanize.intComma(directoryCount)} folders` this.refs.summary.style.display = '' diff --git a/spec/archive-editor-view-spec.coffee b/spec/archive-editor-view-spec.coffee index af5d7dd..cdb5e0d 100644 --- a/spec/archive-editor-view-spec.coffee +++ b/spec/archive-editor-view-spec.coffee @@ -47,6 +47,21 @@ describe "Archive viewer", -> waitsFor -> archiveEditor.element.querySelectorAll('.entry').length > 0 runs -> expect(archiveEditor.element.querySelector('.selected').textContent).toBe 'f1.txt' + describe "archive summary", -> + beforeEach -> + waitsForPromise -> + atom.workspace.open('multiple-entries.zip') + + runs -> + archiveEditor = atom.workspace.getActivePaneItem() + jasmine.attachToDOM(atom.views.getView(atom.workspace)) + + it "shows correct archive summary", -> + waitsFor -> archiveEditor.element.querySelectorAll('.entry').length > 0 + + runs -> + expect(archiveEditor.element.querySelector('.inset-panel .panel-heading').textContent).toBe '704 bytes with 4 files and 1 folder' + describe "when core:move-up/core:move-down is triggered", -> it "selects the next/previous file", -> waitsFor -> diff --git a/spec/fixtures/multiple-entries.zip b/spec/fixtures/multiple-entries.zip new file mode 100644 index 0000000000000000000000000000000000000000..274439698c5575124c3ba7e691e93758cb86fb3c GIT binary patch literal 704 zcmWIWW@h1H00Fsd@z|X#qfGB4CNbT}Qo;m9YakY56%RsYUuA zMG&(N_Mw`^0alb(qE}J^HVUF@McW3m=1zrmT0mJ428k9IBqpa8>7{3;xqG@|NpP}lZBB1D4+x4gJc+(7=0M55%xNx`GF0nuDCQWPcJ{fn~}*LYy&o* zs(=gxf(9^&<7cMgLFh4S8y>|&tLyX21IxwRJfaa(JF*K}@ z4c0m3BFzpo5S>PLGiHdw3~m4#>H{_y628bLGbF0-YX&-5HxS}v7>#T)W-K6^Tm&>3 z5ho~S=cV)>oPL}!{usn;7>#T;W_%!