Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
test(http): add missing flush
Browse files Browse the repository at this point in the history
  • Loading branch information
chirayuk committed Mar 25, 2014
1 parent 91707e6 commit d663667
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions test/core_dom/http_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ void main() {
it('should do basic request', async(() {
backend.expect('GET', '/url').respond('');
http(url: '/url', method: 'GET');
flush();
}));


it('should pass data if specified', async(() {
backend.expect('POST', '/url', 'some-data').respond('');
http(url: '/url', method: 'POST', data: 'some-data');
flush();
}));


Expand All @@ -96,24 +98,28 @@ void main() {
it('should do basic request with params and encode', async(() {
backend.expect('GET', '/url?a%3D=%3F%26&b=2').respond('');
http(url: '/url', params: {'a=':'?&', 'b':2}, method: 'GET');
flush();
}));


it('should merge params if url contains some already', async(() {
backend.expect('GET', '/url?c=3&a=1&b=2').respond('');
http(url: '/url?c=3', params: {'a':1, 'b':2}, method: 'GET');
flush();
}));


it('should jsonify objects in params map', async(() {
backend.expect('GET', '/url?a=1&b=%7B%22c%22:3%7D').respond('');
http(url: '/url', params: {'a':1, 'b':{'c':3}}, method: 'GET');
flush();
}));


it('should expand arrays in params map', async(() {
backend.expect('GET', '/url?a=1&a=2&a=3').respond('');
http(url: '/url', params: {'a': [1,2,3]}, method: 'GET');
flush();
}));


Expand All @@ -125,6 +131,7 @@ void main() {

backend.expect('GET', r'/Path?!do%26h=g%3Da+h&:bar=$baz@1').respond('');
http(url: '/Path', params: {':bar': r'$baz@1', '!do&h': 'g=a h'}, method: 'GET');
flush();
}));
});

Expand Down Expand Up @@ -509,72 +516,84 @@ void main() {
it('should have get()', async(() {
backend.expect('GET', '/url').respond('');
http.get('/url');
flush();
}));


it('get() should allow config param', async(() {
backend.expect('GET', '/url', null, checkHeader('Custom', 'Header')).respond('');
http.get('/url', headers: {'Custom': 'Header'});
flush();
}));


it('should have delete()', async(() {
backend.expect('DELETE', '/url').respond('');
http.delete('/url');
flush();
}));


it('delete() should allow config param', async(() {
backend.expect('DELETE', '/url', null, checkHeader('Custom', 'Header')).respond('');
http.delete('/url', headers: {'Custom': 'Header'});
flush();
}));


it('should have head()', async(() {
backend.expect('HEAD', '/url').respond('');
http.head('/url');
flush();
}));


it('head() should allow config param', async(() {
backend.expect('HEAD', '/url', null, checkHeader('Custom', 'Header')).respond('');
http.head('/url', headers: {'Custom': 'Header'});
flush();
}));


it('should have post()', async(() {
backend.expect('POST', '/url', 'some-data').respond('');
http.post('/url', 'some-data');
flush();
}));


it('post() should allow config param', async(() {
backend.expect('POST', '/url', 'some-data', checkHeader('Custom', 'Header')).respond('');
http.post('/url', 'some-data', headers: {'Custom': 'Header'});
flush();
}));


it('should have put()', async(() {
backend.expect('PUT', '/url', 'some-data').respond('');
http.put('/url', 'some-data');
flush();
}));


it('put() should allow config param', async(() {
backend.expect('PUT', '/url', 'some-data', checkHeader('Custom', 'Header')).respond('');
http.put('/url', 'some-data', headers: {'Custom': 'Header'});
flush();
}));


it('should have jsonp()', async(() {
backend.expect('JSONP', '/url').respond('');
http.jsonp('/url');
flush();
}));


it('jsonp() should allow config param', async(() {
backend.expect('JSONP', '/url', null, checkHeader('Custom', 'Header')).respond('');
http.jsonp('/url', headers: {'Custom': 'Header'});
flush();
}));
});

Expand Down Expand Up @@ -614,7 +633,7 @@ void main() {

backend.expect('GET', '/url').respond();
http(method: 'GET', url: '/url');
microLeap();
flush();
}));


Expand All @@ -624,7 +643,7 @@ void main() {
cache.removeAll();
backend.expect('GET', '/url').respond();
http(method: 'GET', url: '/url', cache: cache);
microLeap();
flush();
}));


Expand Down Expand Up @@ -1157,12 +1176,14 @@ void main() {
it('should transform object into json', async(() {
backend.expect('POST', '/url', '{"one":"two"}').respond('');
http(method: 'POST', url: '/url', data: {'one': 'two'});
flush();
}));


it('should ignore strings', async(() {
backend.expect('POST', '/url', 'string-data').respond('');
http(method: 'POST', url: '/url', data: 'string-data');
flush();
}));


Expand All @@ -1172,6 +1193,7 @@ void main() {

backend.expect('POST', '/some', file).respond('');
http(method: 'POST', url: '/some', data: file);
flush();
}));
});

Expand Down

1 comment on commit d663667

@jbdeboer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not add this to afterEach().

Also, backend.verifyNoOutstandingRequest(); should barf if there are outstanding, un-flushed requests.

Please sign in to comment.