(function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; window.FileReader = (function() { function FileReader() { this.readAsArrayBuffer = __bind(this.readAsArrayBuffer, this); } FileReader.prototype.readAsArrayBuffer = function(file) { return this.onloadend({ target: { result: 'xyz' } }); }; return FileReader; })(); describe('WebSocketRails.UploadEvent', function() { beforeEach(function() { this.file = { name: 'test_file.jpg', size: 4321, type: 'image/jpeg' }; this.conn = { trigger: function(event) { return this.called = true; } }; return this.event = new WebSocketRails.UploadEvent('test_upload', this.file, {}, 12345, {}, {}, this.conn); }); it('should call the triggerCallback function after extracting the binary data', function() { return expect(this.conn.called).toEqual(true); }); describe('.isFileUpload()', function() { return it('should be true', function() { return expect(this.event.isFileUpload()).toEqual(true); }); }); return describe('.attributes()', function() { return it('should include the raw_file_data', function() { expect(this.event.attributes().raw_file_data.filename).toEqual('test_file.jpg'); expect(this.event.attributes().raw_file_data.file_size).toEqual(4321); expect(this.event.attributes().raw_file_data.type).toEqual('image/jpeg'); return expect(this.event.attributes().raw_file_data.array_buffer).toEqual('xyz'); }); }); }); }).call(this);