2015-07-18 07:36:28 +08:00
|
|
|
fs = require 'fs'
|
2016-01-12 03:39:45 +08:00
|
|
|
path = require 'path'
|
2015-11-24 14:09:17 +08:00
|
|
|
{shell} = require 'electron'
|
2015-08-11 04:36:11 +08:00
|
|
|
NylasAPI = require '../../src/flux/nylas-api'
|
2015-07-18 07:36:28 +08:00
|
|
|
File = require '../../src/flux/models/file'
|
2016-02-20 10:54:20 +08:00
|
|
|
Message = require '../../src/flux/models/message'
|
2015-07-18 07:36:28 +08:00
|
|
|
FileDownloadStore = require '../../src/flux/stores/file-download-store'
|
2016-01-12 05:40:38 +08:00
|
|
|
AccountStore = require '../../src/flux/stores/account-store'
|
|
|
|
|
2015-08-11 04:36:11 +08:00
|
|
|
Download = FileDownloadStore.Download
|
|
|
|
|
|
|
|
describe "FileDownloadStore.Download", ->
|
|
|
|
beforeEach ->
|
|
|
|
spyOn(fs, 'createWriteStream')
|
|
|
|
spyOn(NylasAPI, 'makeRequest')
|
|
|
|
|
|
|
|
describe "constructor", ->
|
|
|
|
it "should require a non-empty filename", ->
|
|
|
|
expect(-> new Download(fileId: '123', targetPath: 'test.png')).toThrow()
|
|
|
|
expect(-> new Download(filename: null, fileId: '123', targetPath: 'test.png')).toThrow()
|
|
|
|
expect(-> new Download(filename: '', fileId: '123', targetPath: 'test.png')).toThrow()
|
|
|
|
|
|
|
|
it "should require a non-empty fileId", ->
|
|
|
|
expect(-> new Download(filename: 'test.png', fileId: null, targetPath: 'test.png')).toThrow()
|
|
|
|
expect(-> new Download(filename: 'test.png', fileId: '', targetPath: 'test.png')).toThrow()
|
|
|
|
|
|
|
|
it "should require a download path", ->
|
|
|
|
expect(-> new Download(filename: 'test.png', fileId: '123')).toThrow()
|
|
|
|
expect(-> new Download(filename: 'test.png', fileId: '123', targetPath: '')).toThrow()
|
|
|
|
|
|
|
|
describe "run", ->
|
|
|
|
beforeEach ->
|
2016-01-14 09:20:34 +08:00
|
|
|
account = AccountStore.accounts()[0]
|
|
|
|
@download = new Download(fileId: '123', targetPath: 'test.png', filename: 'test.png', accountId: account.id)
|
2015-08-11 04:36:11 +08:00
|
|
|
@download.run()
|
|
|
|
expect(NylasAPI.makeRequest).toHaveBeenCalled()
|
2016-01-12 05:44:54 +08:00
|
|
|
|
2015-08-11 04:36:11 +08:00
|
|
|
it "should create a request with a null encoding to prevent the request library from attempting to parse the (potentially very large) response", ->
|
|
|
|
expect(NylasAPI.makeRequest.mostRecentCall.args[0].json).toBe(false)
|
|
|
|
expect(NylasAPI.makeRequest.mostRecentCall.args[0].encoding).toBe(null)
|
2016-01-12 05:44:54 +08:00
|
|
|
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
it "should create a request for /files/123/download", ->
|
|
|
|
expect(NylasAPI.makeRequest.mostRecentCall.args[0].path).toBe("/files/123/download")
|
2016-01-12 05:44:54 +08:00
|
|
|
|
2015-07-18 07:36:28 +08:00
|
|
|
describe "FileDownloadStore", ->
|
|
|
|
beforeEach ->
|
2016-01-14 09:20:34 +08:00
|
|
|
account = AccountStore.accounts()[0]
|
|
|
|
|
2015-07-18 07:36:28 +08:00
|
|
|
spyOn(shell, 'showItemInFolder')
|
|
|
|
spyOn(shell, 'openItem')
|
2016-01-14 09:20:34 +08:00
|
|
|
@testfile = new File({
|
|
|
|
accountId: account.id,
|
|
|
|
filename: '123.png',
|
|
|
|
contentType: 'image/png',
|
|
|
|
id: "id",
|
|
|
|
size: 100
|
|
|
|
})
|
2015-10-06 08:57:24 +08:00
|
|
|
@testdownload = new Download({
|
2016-01-14 09:20:34 +08:00
|
|
|
accountId: account.id,
|
2015-10-06 08:57:24 +08:00
|
|
|
state : 'unknown',
|
|
|
|
fileId : 'id',
|
|
|
|
percent : 0,
|
|
|
|
filename : '123.png',
|
|
|
|
filesize : 100,
|
|
|
|
targetPath : '/Users/testuser/.nylas/downloads/id/123.png'
|
|
|
|
})
|
|
|
|
|
2015-07-18 07:36:28 +08:00
|
|
|
FileDownloadStore._downloads = {}
|
2015-07-18 08:13:16 +08:00
|
|
|
FileDownloadStore._downloadDirectory = "/Users/testuser/.nylas/downloads"
|
2015-07-18 07:36:28 +08:00
|
|
|
|
|
|
|
describe "pathForFile", ->
|
|
|
|
it "should return path within the download directory with the file id and displayName", ->
|
|
|
|
f = new File(filename: '123.png', contentType: 'image/png', id: 'id')
|
|
|
|
spyOn(f, 'displayName').andCallThrough()
|
2015-07-18 08:13:16 +08:00
|
|
|
expect(FileDownloadStore.pathForFile(f)).toBe("/Users/testuser/.nylas/downloads/id/123.png")
|
2015-07-18 07:36:28 +08:00
|
|
|
expect(f.displayName).toHaveBeenCalled()
|
|
|
|
|
|
|
|
it "should return unique paths for identical filenames with different IDs", ->
|
|
|
|
f1 = new File(filename: '123.png', contentType: 'image/png', id: 'id1')
|
|
|
|
f2 = new File(filename: '123.png', contentType: 'image/png', id: 'id2')
|
2015-07-18 08:13:16 +08:00
|
|
|
expect(FileDownloadStore.pathForFile(f1)).toBe("/Users/testuser/.nylas/downloads/id1/123.png")
|
|
|
|
expect(FileDownloadStore.pathForFile(f2)).toBe("/Users/testuser/.nylas/downloads/id2/123.png")
|
2015-07-18 07:36:28 +08:00
|
|
|
|
2016-01-14 09:20:34 +08:00
|
|
|
it "should escape the displayName if it contains path separator characters", ->
|
|
|
|
f1 = new File(filename: "static#{path.sep}b#{path.sep}a.jpg", contentType: 'image/png', id: 'id1')
|
|
|
|
expect(FileDownloadStore.pathForFile(f1)).toBe("/Users/testuser/.nylas/downloads/id1/static-b-a.jpg")
|
2016-01-12 03:39:45 +08:00
|
|
|
|
2016-01-14 09:20:34 +08:00
|
|
|
f1 = new File(filename: "my:file ? Windows /hates/ me :->.jpg", contentType: 'image/png', id: 'id1')
|
|
|
|
expect(FileDownloadStore.pathForFile(f1)).toBe("/Users/testuser/.nylas/downloads/id1/my-file - Windows -hates- me ---.jpg")
|
2016-01-13 04:17:17 +08:00
|
|
|
|
2015-07-18 07:36:28 +08:00
|
|
|
describe "_checkForDownloadedFile", ->
|
|
|
|
it "should return true if the file exists at the path and is the right size", ->
|
2015-08-29 02:12:53 +08:00
|
|
|
f = new File(filename: '123.png', contentType: 'image/png', id: "id", size: 100)
|
2015-08-29 04:37:09 +08:00
|
|
|
spyOn(fs, 'statAsync').andCallFake (path) ->
|
|
|
|
Promise.resolve({size: 100})
|
2015-07-18 07:36:28 +08:00
|
|
|
waitsForPromise ->
|
|
|
|
FileDownloadStore._checkForDownloadedFile(f).then (downloaded) ->
|
|
|
|
expect(downloaded).toBe(true)
|
|
|
|
|
|
|
|
it "should return false if the file does not exist", ->
|
2015-08-29 02:12:53 +08:00
|
|
|
f = new File(filename: '123.png', contentType: 'image/png', id: "id", size: 100)
|
2015-08-29 04:37:09 +08:00
|
|
|
spyOn(fs, 'statAsync').andCallFake (path) ->
|
|
|
|
Promise.reject(new Error("File does not exist"))
|
2015-07-18 07:36:28 +08:00
|
|
|
waitsForPromise ->
|
|
|
|
FileDownloadStore._checkForDownloadedFile(f).then (downloaded) ->
|
|
|
|
expect(downloaded).toBe(false)
|
|
|
|
|
|
|
|
it "should return false if the file is too small", ->
|
2015-08-29 02:12:53 +08:00
|
|
|
f = new File(filename: '123.png', contentType: 'image/png', id: "id", size: 100)
|
2015-08-29 04:37:09 +08:00
|
|
|
spyOn(fs, 'statAsync').andCallFake (path) ->
|
|
|
|
Promise.resolve({size: 50})
|
2015-07-18 07:36:28 +08:00
|
|
|
waitsForPromise ->
|
|
|
|
FileDownloadStore._checkForDownloadedFile(f).then (downloaded) ->
|
|
|
|
expect(downloaded).toBe(false)
|
|
|
|
|
2016-02-20 10:54:20 +08:00
|
|
|
describe "_newMailReceived", ->
|
|
|
|
it "should fetch attachments if the setting is on-receive", ->
|
|
|
|
spyOn(FileDownloadStore, '_fetch')
|
|
|
|
spyOn(NylasEnv.config, 'get').andCallFake (key) ->
|
|
|
|
return 'on-receive' if key is 'core.attachments.downloadPolicy'
|
|
|
|
return null
|
|
|
|
FileDownloadStore._newMailReceived(message: [new Message(files: [new File()])])
|
|
|
|
expect(FileDownloadStore._fetch).toHaveBeenCalled()
|
|
|
|
|
|
|
|
it "should not fetch attachments otherwise", ->
|
|
|
|
spyOn(FileDownloadStore, '_fetch')
|
|
|
|
spyOn(NylasEnv.config, 'get').andCallFake (key) ->
|
|
|
|
return 'on-read' if key is 'core.attachments.downloadPolicy'
|
|
|
|
return null
|
|
|
|
FileDownloadStore._newMailReceived(message: [new Message(files: [new File()])])
|
|
|
|
expect(FileDownloadStore._fetch).not.toHaveBeenCalled()
|
|
|
|
|
2015-10-06 08:57:24 +08:00
|
|
|
describe "_runDownload", ->
|
2016-01-12 05:44:54 +08:00
|
|
|
beforeEach ->
|
2015-10-06 08:57:24 +08:00
|
|
|
spyOn(FileDownloadStore.Download.prototype, 'run').andCallFake -> Promise.resolve(@)
|
2015-07-18 07:36:28 +08:00
|
|
|
spyOn(FileDownloadStore, '_prepareFolder').andCallFake -> Promise.resolve(true)
|
|
|
|
|
|
|
|
it "should make sure that the download file path exists", ->
|
2015-10-06 08:57:24 +08:00
|
|
|
FileDownloadStore._runDownload(@testfile)
|
2015-07-18 07:36:28 +08:00
|
|
|
expect(FileDownloadStore._prepareFolder).toHaveBeenCalled()
|
|
|
|
|
|
|
|
it "should return the promise returned by download.run if the download already exists", ->
|
|
|
|
existing =
|
|
|
|
fileId: @testfile.id
|
|
|
|
run: jasmine.createSpy('existing.run').andCallFake ->
|
2015-10-06 08:57:24 +08:00
|
|
|
Promise.resolve(existing)
|
2015-07-18 07:36:28 +08:00
|
|
|
FileDownloadStore._downloads[@testfile.id] = existing
|
|
|
|
|
2015-10-06 08:57:24 +08:00
|
|
|
promise = FileDownloadStore._runDownload(@testfile)
|
2015-07-18 07:36:28 +08:00
|
|
|
expect(promise instanceof Promise).toBe(true)
|
|
|
|
waitsForPromise ->
|
|
|
|
promise.then ->
|
|
|
|
expect(existing.run).toHaveBeenCalled()
|
|
|
|
|
|
|
|
describe "when the downloaded file exists", ->
|
|
|
|
beforeEach ->
|
|
|
|
spyOn(FileDownloadStore, '_checkForDownloadedFile').andCallFake ->
|
|
|
|
Promise.resolve(true)
|
|
|
|
|
|
|
|
it "should resolve with a Download without calling download.run", ->
|
|
|
|
waitsForPromise =>
|
2015-10-06 08:57:24 +08:00
|
|
|
FileDownloadStore._runDownload(@testfile).then (download) ->
|
2015-07-18 07:36:28 +08:00
|
|
|
expect(FileDownloadStore.Download.prototype.run).not.toHaveBeenCalled()
|
|
|
|
expect(download instanceof FileDownloadStore.Download).toBe(true)
|
|
|
|
expect(download.data()).toEqual({
|
|
|
|
state : 'finished',
|
|
|
|
fileId : 'id',
|
|
|
|
percent : 0,
|
|
|
|
filename : '123.png',
|
|
|
|
filesize : 100,
|
2015-07-18 08:13:16 +08:00
|
|
|
targetPath : '/Users/testuser/.nylas/downloads/id/123.png'
|
2015-07-18 07:36:28 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
describe "when the downloaded file does not exist", ->
|
|
|
|
beforeEach ->
|
|
|
|
spyOn(FileDownloadStore, '_checkForDownloadedFile').andCallFake ->
|
|
|
|
Promise.resolve(false)
|
|
|
|
|
|
|
|
it "should register the download with the right attributes", ->
|
2015-10-06 08:57:24 +08:00
|
|
|
FileDownloadStore._runDownload(@testfile)
|
2015-07-18 07:36:28 +08:00
|
|
|
advanceClock(0)
|
|
|
|
expect(FileDownloadStore.downloadDataForFile(@testfile.id)).toEqual({
|
|
|
|
state : 'unstarted',fileId : 'id',
|
|
|
|
percent : 0,
|
|
|
|
filename : '123.png',
|
|
|
|
filesize : 100,
|
2015-07-18 08:13:16 +08:00
|
|
|
targetPath : '/Users/testuser/.nylas/downloads/id/123.png'
|
2015-07-18 07:36:28 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
it "should call download.run", ->
|
|
|
|
waitsForPromise =>
|
2015-10-06 08:57:24 +08:00
|
|
|
FileDownloadStore._runDownload(@testfile)
|
2015-07-18 07:36:28 +08:00
|
|
|
runs ->
|
|
|
|
expect(FileDownloadStore.Download.prototype.run).toHaveBeenCalled()
|
|
|
|
|
|
|
|
it "should resolve with a Download", ->
|
|
|
|
waitsForPromise =>
|
2015-10-06 08:57:24 +08:00
|
|
|
FileDownloadStore._runDownload(@testfile).then (download) ->
|
2015-07-18 07:36:28 +08:00
|
|
|
expect(download instanceof FileDownloadStore.Download).toBe(true)
|
|
|
|
expect(download.data()).toEqual({
|
|
|
|
state : 'unstarted',
|
|
|
|
fileId : 'id',
|
|
|
|
percent : 0,
|
|
|
|
filename : '123.png',
|
|
|
|
filesize : 100,
|
2015-07-18 08:13:16 +08:00
|
|
|
targetPath : '/Users/testuser/.nylas/downloads/id/123.png'
|
2015-07-18 07:36:28 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
describe "_fetch", ->
|
|
|
|
it "should call through to startDownload", ->
|
2015-10-06 08:57:24 +08:00
|
|
|
spyOn(FileDownloadStore, '_runDownload').andCallFake ->
|
|
|
|
Promise.resolve(@testdownload)
|
2015-07-18 07:36:28 +08:00
|
|
|
FileDownloadStore._fetch(@testfile)
|
2015-10-06 08:57:24 +08:00
|
|
|
expect(FileDownloadStore._runDownload).toHaveBeenCalled()
|
|
|
|
|
|
|
|
it "should fail silently since it's called passively", ->
|
|
|
|
spyOn(FileDownloadStore, '_presentError')
|
|
|
|
spyOn(FileDownloadStore, '_runDownload').andCallFake =>
|
|
|
|
Promise.reject(@testdownload)
|
|
|
|
FileDownloadStore._fetch(@testfile)
|
|
|
|
expect(FileDownloadStore._presentError).not.toHaveBeenCalled()
|
2015-07-18 07:36:28 +08:00
|
|
|
|
|
|
|
describe "_fetchAndOpen", ->
|
|
|
|
it "should open the file once it's been downloaded", ->
|
|
|
|
@savePath = "/Users/imaginary/.nylas/Downloads/a.png"
|
|
|
|
download = {targetPath: @savePath}
|
|
|
|
downloadResolve = null
|
|
|
|
|
2015-10-06 08:57:24 +08:00
|
|
|
spyOn(FileDownloadStore, '_runDownload').andCallFake =>
|
2015-07-18 07:36:28 +08:00
|
|
|
new Promise (resolve, reject) ->
|
|
|
|
downloadResolve = resolve
|
|
|
|
|
|
|
|
FileDownloadStore._fetchAndOpen(@testfile)
|
|
|
|
expect(shell.openItem).not.toHaveBeenCalled()
|
|
|
|
downloadResolve(download)
|
|
|
|
advanceClock(100)
|
|
|
|
expect(shell.openItem).toHaveBeenCalledWith(@savePath)
|
|
|
|
|
2015-10-06 08:57:24 +08:00
|
|
|
it "should open an error if the download fails", ->
|
|
|
|
spyOn(FileDownloadStore, '_presentError')
|
|
|
|
spyOn(FileDownloadStore, '_runDownload').andCallFake =>
|
|
|
|
Promise.reject(@testdownload)
|
|
|
|
FileDownloadStore._fetchAndOpen(@testfile)
|
|
|
|
advanceClock(1)
|
|
|
|
expect(FileDownloadStore._presentError).toHaveBeenCalled()
|
|
|
|
|
2015-07-18 07:36:28 +08:00
|
|
|
describe "_fetchAndSave", ->
|
|
|
|
beforeEach ->
|
2016-03-04 10:00:37 +08:00
|
|
|
@userSelectedPath = "/Users/imaginary/.nylas/Downloads/b.png"
|
|
|
|
spyOn(NylasEnv, 'showSaveDialog').andCallFake (options, callback) => callback(@userSelectedPath)
|
2015-07-18 07:36:28 +08:00
|
|
|
|
|
|
|
it "should open a save dialog and prompt the user to choose a download path", ->
|
2015-10-06 08:57:24 +08:00
|
|
|
spyOn(FileDownloadStore, '_runDownload').andCallFake =>
|
2015-07-18 07:36:28 +08:00
|
|
|
new Promise (resolve, reject) -> # never resolve
|
|
|
|
FileDownloadStore._fetchAndSave(@testfile)
|
2015-11-12 02:25:11 +08:00
|
|
|
expect(NylasEnv.showSaveDialog).toHaveBeenCalled()
|
2015-10-06 08:57:24 +08:00
|
|
|
expect(FileDownloadStore._runDownload).toHaveBeenCalledWith(@testfile)
|
2015-07-18 07:36:28 +08:00
|
|
|
|
2015-10-06 08:57:24 +08:00
|
|
|
it "should open an error if the download fails", ->
|
|
|
|
spyOn(FileDownloadStore, '_presentError')
|
|
|
|
spyOn(FileDownloadStore, '_runDownload').andCallFake =>
|
|
|
|
Promise.reject(@testdownload)
|
|
|
|
FileDownloadStore._fetchAndSave(@testfile)
|
|
|
|
advanceClock(1)
|
|
|
|
expect(FileDownloadStore._presentError).toHaveBeenCalled()
|
|
|
|
|
2016-03-04 10:00:37 +08:00
|
|
|
describe "when the user confirms a path", ->
|
|
|
|
beforeEach ->
|
|
|
|
@download = {targetPath: 'bla'}
|
|
|
|
@onEndEventCallback = null
|
|
|
|
streamStub =
|
|
|
|
pipe: ->
|
|
|
|
on: (eventName, eventCallback) =>
|
|
|
|
@onEndEventCallback = eventCallback
|
|
|
|
|
|
|
|
spyOn(FileDownloadStore, '_runDownload').andCallFake =>
|
|
|
|
Promise.resolve(@download)
|
|
|
|
spyOn(fs, 'createReadStream').andReturn(streamStub)
|
|
|
|
spyOn(fs, 'createWriteStream')
|
|
|
|
|
|
|
|
it "should copy the file to the download path after it's been downloaded and open it after the stream has ended", ->
|
|
|
|
FileDownloadStore._fetchAndSave(@testfile)
|
|
|
|
advanceClock(1)
|
|
|
|
expect(fs.createReadStream).toHaveBeenCalledWith(@download.targetPath)
|
|
|
|
expect(shell.showItemInFolder).not.toHaveBeenCalled()
|
|
|
|
@onEndEventCallback()
|
|
|
|
advanceClock(1)
|
|
|
|
expect(shell.showItemInFolder).toHaveBeenCalledWith(@userSelectedPath)
|
|
|
|
|
|
|
|
it "should update the NylasEnv.savedState.lastDownloadDirectory", ->
|
2016-03-05 02:28:48 +08:00
|
|
|
NylasEnv.savedState.lastDownloadDirectory = null
|
|
|
|
@userSelectedPath = "/Users/imaginary/.nylas/Another Random Folder/file.jpg"
|
|
|
|
FileDownloadStore._fetchAndSave(@testfile)
|
|
|
|
advanceClock(1)
|
|
|
|
expect(NylasEnv.savedState.lastDownloadDirectory).toEqual('/Users/imaginary/.nylas/Another Random Folder')
|
2016-03-04 10:00:37 +08:00
|
|
|
|
|
|
|
describe "file extensions", ->
|
|
|
|
it "should allow the user to save the file with a different extension", ->
|
|
|
|
@userSelectedPath = "/Users/imaginary/.nylas/Downloads/b-changed.tiff"
|
|
|
|
FileDownloadStore._fetchAndSave(@testfile)
|
|
|
|
advanceClock(1)
|
|
|
|
expect(fs.createWriteStream).toHaveBeenCalledWith(@userSelectedPath)
|
|
|
|
|
|
|
|
it "should restore the extension if the user removed it entirely, because it's usually an accident", ->
|
|
|
|
@userSelectedPath = "/Users/imaginary/.nylas/Downloads/b-changed"
|
|
|
|
FileDownloadStore._fetchAndSave(@testfile)
|
|
|
|
advanceClock(1)
|
|
|
|
expect(fs.createWriteStream).toHaveBeenCalledWith("#{@userSelectedPath}.png")
|
|
|
|
|
2015-07-18 07:36:28 +08:00
|
|
|
describe "_abortFetchFile", ->
|
|
|
|
beforeEach ->
|
|
|
|
@download =
|
2015-12-08 07:00:20 +08:00
|
|
|
ensureClosed: jasmine.createSpy('abort')
|
2015-07-18 07:36:28 +08:00
|
|
|
fileId: @testfile.id
|
|
|
|
FileDownloadStore._downloads[@testfile.id] = @download
|
|
|
|
|
|
|
|
it "should cancel the download for the provided file", ->
|
|
|
|
spyOn(fs, 'exists').andCallFake (path, callback) -> callback(true)
|
|
|
|
spyOn(fs, 'unlink')
|
|
|
|
FileDownloadStore._abortFetchFile(@testfile)
|
|
|
|
expect(fs.unlink).toHaveBeenCalled()
|
2015-12-08 07:00:20 +08:00
|
|
|
expect(@download.ensureClosed).toHaveBeenCalled()
|
2015-07-18 07:36:28 +08:00
|
|
|
|
|
|
|
it "should not try to delete the file if doesn't exist", ->
|
|
|
|
spyOn(fs, 'exists').andCallFake (path, callback) -> callback(false)
|
|
|
|
spyOn(fs, 'unlink')
|
|
|
|
FileDownloadStore._abortFetchFile(@testfile)
|
|
|
|
expect(fs.unlink).not.toHaveBeenCalled()
|
2015-12-08 07:00:20 +08:00
|
|
|
expect(@download.ensureClosed).toHaveBeenCalled()
|