1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
describe('progress events', function () {
beforeEach(function () {
jasmine.Ajax.install();
});
afterEach(function () {
jasmine.Ajax.uninstall();
});
it('should add a download progress handler', function (done) {
var progressSpy = jasmine.createSpy('progress');
axios('/foo', { onDownloadProgress: progressSpy } );
getAjaxRequest().then(function (request) {
request.respondWith({
status: 200,
responseText: '{"foo": "bar"}'
});
expect(progressSpy).toHaveBeenCalled();
done();
});
});
it('should add a upload progress handler', function (done) {
var progressSpy = jasmine.createSpy('progress');
axios('/foo', { onUploadProgress: progressSpy } );
getAjaxRequest().then(function (request) {
// Jasmine AJAX doesn't trigger upload events. Waiting for upstream fix
// expect(progressSpy).toHaveBeenCalled();
done();
});
});
it('should add both upload and download progress handlers', function (done) {
var downloadProgressSpy = jasmine.createSpy('downloadProgress');
var uploadProgressSpy = jasmine.createSpy('uploadProgress');
axios('/foo', { onDownloadProgress: downloadProgressSpy, onUploadProgress: uploadProgressSpy });
getAjaxRequest().then(function (request) {
// expect(uploadProgressSpy).toHaveBeenCalled();
expect(downloadProgressSpy).not.toHaveBeenCalled();
request.respondWith({
status: 200,
responseText: '{"foo": "bar"}'
});
expect(downloadProgressSpy).toHaveBeenCalled();
done();
});
});
it('should add a download progress handler from instance config', function (done) {
var progressSpy = jasmine.createSpy('progress');
var instance = axios.create({
onDownloadProgress: progressSpy,
});
instance.get('/foo');
getAjaxRequest().then(function (request) {
request.respondWith({
status: 200,
responseText: '{"foo": "bar"}'
});
expect(progressSpy).toHaveBeenCalled();
done();
});
});
it('should add a upload progress handler from instance config', function (done) {
var progressSpy = jasmine.createSpy('progress');
var instance = axios.create({
onUploadProgress: progressSpy,
});
instance.get('/foo');
getAjaxRequest().then(function (request) {
// expect(progressSpy).toHaveBeenCalled();
done();
});
});
it('should add upload and download progress handlers from instance config', function (done) {
var downloadProgressSpy = jasmine.createSpy('downloadProgress');
var uploadProgressSpy = jasmine.createSpy('uploadProgress');
var instance = axios.create({
onDownloadProgress: downloadProgressSpy,
onUploadProgress: uploadProgressSpy,
});
instance.get('/foo');
getAjaxRequest().then(function (request) {
// expect(uploadProgressSpy).toHaveBeenCalled();
expect(downloadProgressSpy).not.toHaveBeenCalled();
request.respondWith({
status: 200,
responseText: '{"foo": "bar"}'
});
expect(downloadProgressSpy).toHaveBeenCalled();
done();
});
});
});
|