fix(spec): Stub correct method

This commit is contained in:
Evan Morikawa 2015-08-28 16:37:09 -04:00
parent 3908ba402d
commit 7ad227cd9a

View file

@ -61,24 +61,24 @@ describe "FileDownloadStore", ->
describe "_checkForDownloadedFile", ->
it "should return true if the file exists at the path and is the right size", ->
f = new File(filename: '123.png', contentType: 'image/png', id: "id", size: 100)
spyOn(fs, 'stat').andCallFake (path, callback) ->
callback(null, {size: 100})
spyOn(fs, 'statAsync').andCallFake (path) ->
Promise.resolve({size: 100})
waitsForPromise ->
FileDownloadStore._checkForDownloadedFile(f).then (downloaded) ->
expect(downloaded).toBe(true)
it "should return false if the file does not exist", ->
f = new File(filename: '123.png', contentType: 'image/png', id: "id", size: 100)
spyOn(fs, 'stat').andCallFake (path, callback) ->
callback(new Error("File does not exist"))
spyOn(fs, 'statAsync').andCallFake (path) ->
Promise.reject(new Error("File does not exist"))
waitsForPromise ->
FileDownloadStore._checkForDownloadedFile(f).then (downloaded) ->
expect(downloaded).toBe(false)
it "should return false if the file is too small", ->
f = new File(filename: '123.png', contentType: 'image/png', id: "id", size: 100)
spyOn(fs, 'stat').andCallFake (path, callback) ->
callback(null, {size: 50})
spyOn(fs, 'statAsync').andCallFake (path) ->
Promise.resolve({size: 50})
waitsForPromise ->
FileDownloadStore._checkForDownloadedFile(f).then (downloaded) ->
expect(downloaded).toBe(false)