describe("tus", function() {
    describe("#upload", function() {

        beforeEach(function() {
            jasmine.Ajax.install()
            localStorage.clear()
        })

        afterEach(function() {
            jasmine.Ajax.uninstall()
        })

        it("should throw if no error handler is available", function() {
            var upload = new tus.Upload(null)
            expect(upload.start).toThrow()
        })

        it("should upload a file", function(done) {
            var file = new Blob("hello world".split(""))
            var options = {
                endpoint: "/uploads",
                headers: {
                    Custom: "blargh"
                },
                withCredentials: true,
                onSuccess: done,
                onProgress: function() {},
                fingerprint: function() {}
            }
            spyOn(options, "fingerprint").and.returnValue("fingerprinted")
            spyOn(options, "onProgress")

            var upload = new tus.Upload(file, options)
            upload.start()

            expect(options.fingerprint).toHaveBeenCalledWith(file)

            var req = jasmine.Ajax.requests.mostRecent()
            expect(req.url).toBe("/uploads")
            expect(req.method).toBe("POST")
            expect(req.withCredentials).toBe(true)
            expect(req.requestHeaders.Custom).toBe("blargh")
            expect(req.requestHeaders["Tus-Resumable"]).toBe("1.0.0")
            expect(req.requestHeaders["Upload-Length"]).toBe(file.size)

            req.respondWith({
                status: 201,
                responseHeaders: {
                    Location: "/uploads/blargh"
                }
            })

            expect(upload.url).toBe("/uploads/blargh")

            expect(localStorage.getItem("fingerprinted")).toBe("/uploads/blargh")

            req = jasmine.Ajax.requests.mostRecent()
            expect(req.url).toBe("/uploads/blargh")
            expect(req.method).toBe("PATCH")
            expect(req.withCredentials).toBe(true)
            expect(req.requestHeaders.Custom).toBe("blargh")
            expect(req.requestHeaders["Tus-Resumable"]).toBe("1.0.0")
            expect(req.requestHeaders["Upload-Offset"]).toBe(0)
            expect(req.contentType()).toBe("application/offset+octet-stream")
            expect(req.params.size).toBe(file.size)

            req.respondWith({
                status: 204,
                responseHeaders: {
                    "Upload-Offset": file.size
                }
            })

            expect(options.onProgress).toHaveBeenCalledWith(11, 11)
        })
    })
})

@@ -2534,32 +2534,1851 @@
             %7D)%0A%0A
+            expect(options.onProgress).toHaveBeenCalledWith(11, 11)%0A        %7D)%0A%0A        it(%22should resume an upload%22, function(done) %7B%0A            localStorage.setItem(%22fingerprinted%22, %22/uploads/resuming%22)%0A%0A            var file = new Blob(%22hello world%22.split(%22%22))%0A            var options = %7B%0A                endpoint: %22/uploads%22,%0A                onSuccess: done,%0A                onProgress: function() %7B%7D,%0A                fingerprint: function() %7B%7D%0A            %7D%0A            spyOn(options, %22fingerprint%22).and.returnValue(%22fingerprinted%22)%0A            spyOn(options, %22onProgress%22)%0A%0A            var upload = new tus.Upload(file, options)%0A            upload.start()%0A%0A            expect(options.fingerprint).toHaveBeenCalledWith(file)%0A%0A            var req = jasmine.Ajax.requests.mostRecent()%0A            expect(req.url).toBe(%22/uploads/resuming%22)%0A            expect(req.method).toBe(%22HEAD%22)%0A            expect(req.requestHeaders%5B%22Tus-Resumable%22%5D).toBe(%221.0.0%22)%0A%0A            req.respondWith(%7B%0A                status: 204,%0A                responseHeaders: %7B%0A                    %22Upload-Length%22: 11,%0A                    %22Upload-Offset%22: 3%0A                %7D%0A            %7D)%0A%0A            expect(upload.url).toBe(%22/uploads/resuming%22)%0A%0A            req = jasmine.Ajax.requests.mostRecent()%0A            expect(req.url).toBe(%22/uploads/resuming%22)%0A            expect(req.method).toBe(%22PATCH%22)%0A            expect(req.requestHeaders%5B%22Tus-Resumable%22%5D).toBe(%221.0.0%22)%0A            expect(req.requestHeaders%5B%22Upload-Offset%22%5D).toBe(3)%0A            expect(req.contentType()).toBe(%22application/offset+octet-stream%22)%0A            expect(req.params.size).toBe(file.size - 3)%0A%0A            req.respondWith(%7B%0A                status: 204,%0A                responseHeaders: %7B%0A                    %22Upload-Offset%22: file.size%0A                %7D%0A            %7D)%0A%0A
             expe

add test for resuming an upload