Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 importScripts('worker-test-harness.js'); | |
| 2 | |
| 3 promise_test(function(t) { | |
| 4 var batch_operations = [{ | |
| 5 type: 'put', | |
| 6 request: new Request('http://example.com/foo', {method: 'GET'}), | |
| 7 response: new Response('Hello, world!', { | |
| 8 status: 200, | |
| 9 statusText: 'OK', | |
| 10 headers: [['Content-Type', 'text/plain']] | |
| 11 }) | |
| 12 }]; | |
| 13 return new Cache().batch(batch_operations) | |
| 14 .then(t.step_func(function(results) { | |
| 15 assert_true(Array.isArray(results), | |
| 16 'Cache.batch should return an Array'); | |
| 17 assert_array_equals(results, | |
| 18 [batch_operations[0].response], | |
| 19 'Cache.batch should resolve with an array ' + | |
| 20 'of responses'); | |
| 21 })); | |
| 22 }, 'Cache.batch put with a single request'); | |
| 23 | |
| 24 promise_test(function(t) { | |
| 25 var batch_operations = [{ | |
| 26 type: 'put', | |
| 27 request: new Request('http://example.com/foo', {method: 'HEAD'}), | |
| 28 response: new Response('Hello, world!', { | |
| 29 status: 200, | |
| 30 statusText: 'OK', | |
| 31 headers: [['Content-Type', 'text/plain']] | |
| 32 }) | |
| 33 }]; | |
| 34 return new Cache().batch(batch_operations) | |
| 35 .then(t.unreached_func('Cache.batch should not accept non-GET requests.')) | |
| 36 .catch(t.step_func(function(e) { | |
| 37 assert_true(e instanceof TypeError, | |
|
jsbell
2014/08/01 00:02:25
There's a repeated pattern here:
<operation>
.the
asanka
2014/08/13 03:30:04
I added a convenience method for the .catch(...<ch
| |
| 38 'Cache.batch should throw a TypeError for non-GET ' + | |
| 39 'requests'); | |
| 40 })); | |
| 41 }, 'Cache.batch put with a non-GET request'); | |
| 42 | |
| 43 promise_test(function(t) { | |
| 44 var batch_operations = [{ | |
| 45 type: 'put', | |
| 46 request: new Request('http://example.com/foo', {method: 'GET'}) | |
| 47 }]; | |
| 48 return new Cache().batch(batch_operations) | |
| 49 .then(t.unreached_func('Cache.batch put should not accept an empty ' + | |
| 50 'response.')) | |
| 51 .catch(t.step_func(function(e) { | |
| 52 assert_true(e instanceof TypeError, | |
| 53 'Cache.batch put should throw a TypeError for ' + | |
| 54 'an empty response'); | |
| 55 })); | |
| 56 }, 'Cache.batch put with an empty response'); | |
| 57 | |
| 58 promise_test(function(t) { | |
| 59 var batch_operations = [{ | |
| 60 type: 'put', | |
| 61 request: new Request('http://example.com/foo', {method: 'HEAD'}), | |
| 62 response: new Response('Hello, world!', { | |
| 63 status: 200, | |
| 64 statusText: 'OK', | |
| 65 headers: [['Content-Type', 'text/plain']] | |
| 66 }), | |
| 67 matchParams: {} | |
| 68 }]; | |
| 69 return new Cache().batch(batch_operations) | |
| 70 .then(t.unreached_func('Cache.batch put should not accept a ' + | |
| 71 'non-null matchParams.')) | |
| 72 .catch(t.step_func(function(e) { | |
| 73 assert_true(e instanceof TypeError, | |
| 74 'Cache.batch put should throw a TypeError for ' + | |
| 75 'a non-null matchParams'); | |
| 76 })); | |
| 77 }, 'Cache.batch put with a non-null matchParams'); | |
| 78 | |
| OLD | NEW |