OLD | NEW |
---|---|
(Empty) | |
1 if (self.importScripts) { | |
jkarlin
2016/08/10 13:22:45
You're going to have rebase issues.
https://coder
jsbell
2016/08/10 15:50:10
Hah, great timing. Yeah, that renders some of this
| |
2 importScripts('/resources/testharness.js'); | |
3 importScripts('../resources/test-helpers.js'); | |
4 } | |
5 | |
6 var test_url1 = 'https://example.com/foo'; | |
7 var test_body1 = 'Hello world!'; | |
8 | |
9 var test_url2 = 'https://example.com/wacko'; | |
10 var test_body2 = 'Hello nurse!'; | |
11 | |
12 cache_test(cache => { | |
13 return cache.keys() | |
14 .then(requests => { | |
15 assert_equals(requests.length, 0); | |
16 }); | |
17 }, 'Cache.keys() called on an empty cache'); | |
18 | |
19 cache_test(cache => { | |
20 return Promise.all([ | |
21 cache.put(new Request(test_url1), new Response(test_body1)), | |
22 cache.put(new Request(test_url2), new Response(test_body2)) | |
23 ]) | |
24 .then(() => cache.keys()) | |
25 .then(requests => { | |
26 assert_equals(requests.length, 2); | |
27 assert_true(requests.some(r => r.url === test_url1)); | |
28 assert_true(requests.some(r => r.url === test_url2)); | |
29 }); | |
30 }, 'Cache.keys() called on a cache with entries'); | |
31 | |
32 cache_test(cache => { | |
33 return Promise.all([ | |
34 cache.put(new Request(test_url1), new Response(test_body1)), | |
35 cache.put(new Request(test_url2), new Response(test_body2)) | |
36 ]) | |
37 .then(() => cache.keys(test_url1)) | |
38 .then(requests => { | |
39 assert_equals(requests.length, 1); | |
jkarlin
2016/08/10 13:22:45
This test fails. Why not expect 2 here?
jsbell
2016/08/10 15:50:10
keys(test_url1) should not match test_url2 so shou
jkarlin
2016/08/10 17:30:04
Acknowledged.
| |
40 assert_equals(requests[0].url, test_url1); | |
41 }); | |
42 }, 'Cache.keys() called with a string URL'); | |
43 | |
44 cache_test(cache => { | |
45 return Promise.all([ | |
46 cache.put(new Request(test_url1), new Response(test_body1)), | |
47 cache.put(new Request(test_url2), new Response(test_body2)) | |
48 ]) | |
49 .then(() => cache.keys(new Request(test_url1))) | |
50 .then(requests => { | |
51 assert_equals(requests.length, 1); | |
jkarlin
2016/08/10 13:22:45
Ditto
| |
52 assert_equals(requests[0].url, test_url1); | |
53 }); | |
54 }, 'Cache.keys() called with a Request object'); | |
55 | |
56 cache_test(cache => { | |
57 return Promise.all([ | |
58 cache.put(new Request(test_url1), new Response(test_body1)), | |
59 cache.put(new Request(test_url2), new Response(test_body2)) | |
60 ]) | |
61 .then(() => cache.keys(new Request(test_url1, {method: 'HEAD'}))) | |
62 .then(requests => { | |
63 assert_equals( | |
64 requests.length, 0, | |
65 'HEAD request should not match unless ignoreMethod option is set'); | |
66 }); | |
67 }, 'Cache.keys() called with a HEAD Request'); | |
68 | |
69 done(); | |
OLD | NEW |