From 08ec481739211deaee8276196e1b153ec06123a6 Mon Sep 17 00:00:00 2001 From: Juan Tejada Date: Wed, 27 Jan 2016 13:49:34 -0800 Subject: [PATCH] Fix ComposerView specs --- .../composer/lib/composer-view.cjsx | 11 ++----- .../composer/spec/composer-view-spec.cjsx | 30 +------------------ 2 files changed, 3 insertions(+), 38 deletions(-) diff --git a/internal_packages/composer/lib/composer-view.cjsx b/internal_packages/composer/lib/composer-view.cjsx index 938c9d92b..adf0e5e54 100644 --- a/internal_packages/composer/lib/composer-view.cjsx +++ b/internal_packages/composer/lib/composer-view.cjsx @@ -385,10 +385,10 @@ class ComposerView extends React.Component _renderFileAttachments: -> - nonImageFiles = @_nonImageFiles(@state.files).map((file) -> + nonImageFiles = @_nonImageFiles(@state.files).map((file) => @_renderFileAttachment(file, "Attachment") ) - imageFiles = @_imageFiles(@state.files).map((file) -> + imageFiles = @_imageFiles(@state.files).map((file) => @_renderFileAttachment(file, "Attachment:Image") ) nonImageFiles.concat(imageFiles) @@ -582,15 +582,8 @@ class ComposerView extends React.Component else return true _shouldAcceptDrop: (event) => - # TODO # Ensure that you can't pick up a file and drop it on the same draft - existingFilePaths = @state.files.map (f) -> - FileDownloadStore.pathForFile(f) - existingFilePaths = existingFilePaths.concat(@state.uploads.map (f)-> f.targetPath) - nonNativeFilePath = @_nonNativeFilePathForDrop(event) - if nonNativeFilePath and nonNativeFilePath in existingFilePaths - return false hasNativeFile = event.dataTransfer.files.length > 0 hasNonNativeFilePath = nonNativeFilePath isnt null diff --git a/internal_packages/composer/spec/composer-view-spec.cjsx b/internal_packages/composer/spec/composer-view-spec.cjsx index cff089b98..1625b8223 100644 --- a/internal_packages/composer/spec/composer-view-spec.cjsx +++ b/internal_packages/composer/spec/composer-view-spec.cjsx @@ -604,28 +604,16 @@ describe "ComposerView", -> types:[] expect(@composer._shouldAcceptDrop(event)).toBe(true) - it "should return true if the event is carrying a non-native file URL not on the draft", -> + it "should return true if the event is carrying a non-native file URL", -> event = dataTransfer: files:[] types:['text/uri-list'] spyOn(@composer, '_nonNativeFilePathForDrop').andReturn("file://one-file") - spyOn(FileUploadStore, 'linkedUpload').andReturn({filePath: "file://other-file"}) expect(@composer.state.files.length).toBe(1) expect(@composer._shouldAcceptDrop(event)).toBe(true) - it "should return false if the event is carrying a non-native file URL already on the draft", -> - event = - dataTransfer: - files:[] - types:['text/uri-list'] - spyOn(@composer, '_nonNativeFilePathForDrop').andReturn("file://one-file") - spyOn(FileUploadStore, 'linkedUpload').andReturn({filePath: "file://one-file"}) - - expect(@composer.state.files.length).toBe(1) - expect(@composer._shouldAcceptDrop(event)).toBe(false) - it "should return false otherwise", -> event = dataTransfer: @@ -715,23 +703,7 @@ describe "ComposerView", -> filename: "f3.png" size: 7890 - @up1 = - uploadTaskId: 4 - messageClientId: DRAFT_CLIENT_ID - filePath: "/foo/bar/f4.bmp" - fileName: "f4.bmp" - fileSize: 1024 - - @up2 = - uploadTaskId: 5 - messageClientId: DRAFT_CLIENT_ID - filePath: "/foo/bar/f5.zip" - fileName: "f5.zip" - fileSize: 1024 - spyOn(Actions, "fetchFile") - spyOn(FileUploadStore, "linkedUpload").andReturn null - spyOn(FileUploadStore, "uploadsForMessage").andReturn [@up1, @up2] useDraft.call @, files: [@file1, @file2] makeComposer.call @