Fix ComposerView specs

This commit is contained in:
Juan Tejada 2016-01-27 13:49:34 -08:00
parent 7b6267e0b2
commit 08ec481739
2 changed files with 3 additions and 38 deletions

View file

@ -385,10 +385,10 @@ class ComposerView extends React.Component
</div>
_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

View file

@ -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 @