Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: third_party/pkg/angular/test/mock/http_backend_spec.dart

Issue 148453003: Updating Angular version (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 library angular.mock.http_backend_spec; 1 library angular.mock.http_backend_spec;
2 2
3 import '../_specs.dart'; 3 import '../_specs.dart';
4 4
5 class _Chain { 5 class _Chain {
6 var _thenFn; 6 var _thenFn;
7 _Chain({then}) { 7 _Chain({then}) {
8 _thenFn = then; 8 _thenFn = then;
9 } 9 }
10 10
(...skipping 24 matching lines...) Expand all
35 expect(response).toBe('content'); 35 expect(response).toBe('content');
36 }); 36 });
37 37
38 hb('GET', '/url1', null, callback); 38 hb('GET', '/url1', null, callback);
39 expect(callback).not.toHaveBeenCalled(); 39 expect(callback).not.toHaveBeenCalled();
40 hb.flush(); 40 hb.flush();
41 expect(callback).toHaveBeenCalledOnce(); 41 expect(callback).toHaveBeenCalledOnce();
42 }); 42 });
43 43
44 44
45 it('should respond with JSON', inject((Logger logger) {
46 hb.when('GET', '/url1').respond(200, ['abc'], {});
47 hb.when('GET', '/url2').respond(200, {'key': 'value'}, {});
48
49
50 callback.andCallFake((status, response) {
51 expect(status).toBe(200);
52 logger(response);
53 });
54
55 hb('GET', '/url1', null, callback);
56 hb('GET', '/url2', null, callback);
57 hb.flush();
58 expect(logger).toEqual(['["abc"]', '{"key":"value"}']);
59 }));
60
61
45 it('should throw error when unexpected request', () { 62 it('should throw error when unexpected request', () {
46 hb.when('GET', '/url1').respond(200, 'content'); 63 hb.when('GET', '/url1').respond(200, 'content');
47 expect(() { 64 expect(() {
48 hb('GET', '/xxx'); 65 hb('GET', '/xxx');
49 }).toThrow('Unexpected request: GET /xxx\nNo more requests expected'); 66 }).toThrow('Unexpected request: GET /xxx\nNo more requests expected');
50 }); 67 });
51 68
52 69
53 it('should throw an error on an exception in then', async(() { 70 it('should throw an error on an exception in then', async(() {
54 hb.expectGET('/url').respond(200, 'content'); 71 hb.expectGET('/url').respond(200, 'content');
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 it('should accept headers as function', () { 508 it('should accept headers as function', () {
492 var exp = new MockHttpExpectation('GET', '/url', undefined, (h) { 509 var exp = new MockHttpExpectation('GET', '/url', undefined, (h) {
493 return h['Content-Type'] == 'application/json'; 510 return h['Content-Type'] == 'application/json';
494 }); 511 });
495 512
496 expect(exp.matchHeaders({})).toBe(false); 513 expect(exp.matchHeaders({})).toBe(false);
497 expect(exp.matchHeaders({'Content-Type': 'application/json', 'X-Another': 'true'})).toBe(true); 514 expect(exp.matchHeaders({'Content-Type': 'application/json', 'X-Another': 'true'})).toBe(true);
498 }); 515 });
499 }); 516 });
500 }); 517 });
OLDNEW
« no previous file with comments | « third_party/pkg/angular/test/introspection_spec.dart ('k') | third_party/pkg/angular/test/tools/selector_spec.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698