OLD | NEW |
---|---|
1 if (this.importScripts) { | 1 if (this.importScripts) { |
2 importScripts('../../../resources/testharness.js'); | 2 importScripts('../../../resources/testharness.js'); |
3 } | 3 } |
4 | 4 |
5 function compareChanges(actual, expected) { | 5 function compareChanges(actual, expected) { |
pwnall
2017/01/10 01:41:11
would it be fair to say this is assertChangesEqual
dmurph
2017/01/10 20:40:02
Done.
| |
6 assert_equals(actual.database.name, expected.dbName, 'The change record databa se should be the same as the database being acted on'); | 6 assert_equals(actual.database.name, expected.dbName, 'The change record databa se should be the same as the database being acted on'); |
7 var stores = Object.keys(expected.records); | 7 var stores = Object.keys(expected.records); |
8 assert_equals(actual.records.size, stores.length, 'Incorrect number of objectS tores recorded by observer'); | 8 assert_equals(actual.records.size, stores.length, 'Incorrect number of objectS tores recorded by observer'); |
9 | 9 |
10 var storesStr = Array.from(actual.records.keys()).join(", "); | |
pwnall
2017/01/10 01:41:11
storeNamesString?
dmurph
2017/01/10 20:40:02
Done.
| |
10 for (var i in stores) { | 11 for (var i in stores) { |
11 var key = stores[i]; | 12 var key = stores[i]; |
12 assert_true(actual.records.has(key)); | 13 assert_true(actual.records.has(key), "Store '" + key + "' not found in chang es. Stores: " + storesStr); |
13 var actual_obsv = actual.records.get(key); | 14 var actual_obsv = actual.records.get(key); |
pwnall
2017/01/10 01:41:11
camelCase instead of snake_case?
dmurph
2017/01/10 20:40:05
Done.
| |
14 var expected_obsv = expected.records[key]; | 15 var expected_obsv = expected.records[key]; |
15 assert_equals(actual_obsv.length, expected_obsv.length, 'Number of observati ons recorded for objectStore '+ key + ' should match observed operations'); | 16 assert_equals(actual_obsv.length, expected_obsv.length, 'Number of observati ons recorded for objectStore '+ key + ' should match observed operations'); |
16 for (var j in expected_obsv) | 17 for (var j in expected_obsv) |
17 compareObservations(actual_obsv[j], expected_obsv[j]); | 18 compareObservations(actual_obsv[j], expected_obsv[j]); |
18 } | 19 } |
19 } | 20 } |
20 | 21 |
21 function compareObservations(actual, expected) { | 22 function compareObservations(actual, expected) { |
22 assert_equals(actual.type, expected.type); | 23 assert_equals(actual.type, expected.type); |
23 assert_not_equals(actual.type, 'kDelete'); | 24 assert_not_equals(actual.type, 'kDelete'); |
pwnall
2017/01/10 01:41:11
Why is this here?
dmurph
2017/01/10 20:40:03
Done.
| |
24 if (actual.type == 'clear') { | 25 if (actual.type == 'clear') { |
pwnall
2017/01/10 01:41:11
I'd prefer === because it makes things slightly ea
dmurph
2017/01/10 20:40:05
Done.
| |
25 assert_equals(actual.key, undefined, 'clear operation has no key'); | 26 assert_equals(actual.key, undefined, 'clear operation has no key'); |
26 assert_equals(actual.value, null, 'clear operation has no value'); | 27 assert_equals(actual.value, null, 'clear operation has no value'); |
27 return; | 28 return; |
28 } | 29 } |
29 if (actual.type == 'delete') { | 30 if (actual.type == 'delete') { |
30 assert_equals(actual.key.lower, expected.key.lower, 'Observed operation key lower bound should match operation performed'); | 31 assert_equals(actual.key.lower, expected.key.lower, 'Observed operation key lower bound should match operation performed'); |
31 assert_equals(actual.key.upper, expected.key.upper, 'Observed operation key upper bound should match operation performed'); | 32 assert_equals(actual.key.upper, expected.key.upper, 'Observed operation key upper bound should match operation performed'); |
32 assert_equals(actual.key.lower_open, expected.key.lower_open, 'Observed oper ation key lower open should match operation performed'); | 33 assert_equals(actual.key.lower_open, expected.key.lower_open, 'Observed oper ation key lower open should match operation performed'); |
33 assert_equals(actual.key.upper_open, expected.key.upper_open, 'Observed oper ation key upper open should match operation performed'); | 34 assert_equals(actual.key.upper_open, expected.key.upper_open, 'Observed oper ation key upper open should match operation performed'); |
34 // TODO(dmurph): Value needs to be updated, once returned correctly. Issue c rbug.com/609934. | 35 // TODO(dmurph): Value needs to be updated, once returned correctly. Issue c rbug.com/609934. |
35 assert_equals(actual.value, null, 'Delete operation has no value'); | 36 assert_equals(actual.value, null, 'Delete operation has no value'); |
36 return; | 37 return; |
37 } | 38 } |
38 assert_equals(actual.key.lower, expected.key, 'Observed operation key lower bo und should match operation performed'); | 39 assert_equals(actual.key.lower, expected.key, 'Observed operation key lower bo und should match operation performed'); |
pwnall
2017/01/10 01:41:11
There doesn't seem to be any checking for add vs p
dmurph
2017/01/10 20:40:05
That's basically done above, in the assert_equals(
| |
39 assert_equals(actual.key.upper, expected.key, 'Observed operation key upper bo und should match operation performed'); | 40 assert_equals(actual.key.upper, expected.key, 'Observed operation key upper bo und should match operation performed'); |
40 // TODO(dmurph): Value needs to be updated, once returned correctly. Issue crb ug.com/609934. | 41 if (expected.value != undefined) { |
41 assert_equals(actual.value, null, 'Put/Add operation value does not match'); | 42 assert_equals(actual.value, expected.value, 'Put/Add operation value does no t match'); |
43 } else { | |
44 // TODO(dmurph): Value needs to be updated, once returned correctly. Issue c rbug.com/609934. | |
45 assert_equals(actual.value, null, 'Put/Add operation has unexpected value'); | |
46 } | |
42 } | 47 } |
43 | 48 |
44 function countCallbacks(actual, expected) { | 49 function countCallbacks(actual, expected) { |
45 assert_equals(actual, expected, 'Number of callbacks fired for observer should match number of transactions it observed') | 50 assert_equals(actual, expected, 'Number of callbacks fired for observer should match number of transactions it observed') |
46 } | 51 } |
OLD | NEW |