Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <meta charset="utf-8"> | 2 <meta charset="utf-8"> |
| 3 <title>Tests for PaymentRequest interface</title> | 3 <title>Tests for PaymentRequest interface</title> |
| 4 <script src="../resources/testharness.js"></script> | 4 <script src="../resources/testharness.js"></script> |
| 5 <script src="../resources/testharnessreport.js"></script> | 5 <script src="../resources/testharnessreport.js"></script> |
| 6 <script> | 6 <script> |
| 7 function substitute(originalObject, substituteKeyValuePairs) { | 7 function substitute(originalObject, substituteKeyValuePairs) { |
| 8 for (var key in originalObject) { | 8 for (var key in originalObject) { |
| 9 if (originalObject.hasOwnProperty(key) && substituteKeyValuePairs.hasOwn Property(key)) { | 9 if (originalObject.hasOwnProperty(key) && substituteKeyValuePairs.hasOwn Property(key)) { |
| 10 originalObject[key] = substituteKeyValuePairs[key]; | 10 originalObject[key] = substituteKeyValuePairs[key]; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 test(function() { | 174 test(function() { |
| 175 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('displayIte ms', {'value': '-0.01'})); | 175 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('displayIte ms', {'value': '-0.01'})); |
| 176 }, 'Negative line item value should not throw.'); | 176 }, 'Negative line item value should not throw.'); |
| 177 | 177 |
| 178 test(function() { | 178 test(function() { |
| 179 assert_throws(new TypeError(), function() { | 179 assert_throws(new TypeError(), function() { |
| 180 new PaymentRequest([{'supportedMethods': ['foo']}], {'displayItems': [bu ildItem()]}); | 180 new PaymentRequest([{'supportedMethods': ['foo']}], {'displayItems': [bu ildItem()]}); |
| 181 }); | 181 }); |
| 182 }, 'Absence of total should throw TypeError.'); | 182 }, 'Absence of total should throw TypeError.'); |
| 183 | 183 |
| 184 test(function() { | |
| 185 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' modifiers': undefined}); | |
| 186 }, 'Undefined modifiers should not throw.'); | |
| 187 | |
| 188 test(function() { | |
| 189 assert_throws(new TypeError(), function() { | |
| 190 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': []}); | |
| 191 }); | |
| 192 }, 'Empty modifiers should throw TypeError.'); | |
| 193 | |
| 194 test(function() { | |
| 195 assert_throws(new TypeError(), function() { | |
| 196 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'total' : buildItem()}]}); | |
|
please use gerrit instead
2016/06/26 19:45:24
no space between the second 'total' and :
zino
2016/06/27 17:29:23
Done.
| |
| 197 }); | |
| 198 }, 'Absence of supportedMethods in modifiers should throw TypeError.'); | |
| 199 | |
| 200 test(function() { | |
| 201 assert_throws(new TypeError(), function() { | |
| 202 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': []}]}); | |
| 203 }); | |
| 204 }, 'Empty supportedMethods in modifiers should throw TypeError.'); | |
| 205 | |
| 206 test(function() { | |
| 207 assert_throws(new TypeError(), function() { | |
| 208 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': undefined}]}); | |
| 209 }); | |
| 210 }, 'Undefined supportedMethods in modifiers should throw TypeError.'); | |
| 211 | |
| 212 test(function() { | |
| 213 assert_throws(new TypeError(), function() { | |
| 214 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': null}]}); | |
| 215 }); | |
| 216 }, 'Null supportedMethods in modifiers should throw TypeError.'); | |
| 217 | |
| 218 test(function() { | |
| 219 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' modifiers': [{'supportedMethods': ['foo'], 'total': buildItem({'value': '0.0'})} ]}); | |
|
please use gerrit instead
2016/06/26 19:45:24
Value format checks should really be done in "Inva
zino
2016/06/27 17:29:23
I added tests :)
Done.
| |
| 220 }, 'Non-negative total value in PaymentDetailsModifier should not throw.'); | |
| 221 | |
| 222 test(function() { | |
| 223 assert_throws(new TypeError(), function() { | |
| 224 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': ['foo'], 'total': buildItem({'value': '-0. 01'})}]}); | |
| 225 }); | |
| 226 }, 'Negative total value in PaymentDetailsModifier should throw a TypeError.'); | |
| 227 | |
| 184 promise_test(function(t) { | 228 promise_test(function(t) { |
| 185 return promise_rejects(t, null, new PaymentRequest([{'supportedMethods': ['f oo']}], buildDetails()).abort()); | 229 return promise_rejects(t, null, new PaymentRequest([{'supportedMethods': ['f oo']}], buildDetails()).abort()); |
| 186 }, 'abort() without show() should reject with error'); | 230 }, 'abort() without show() should reject with error'); |
| 187 | 231 |
| 188 generate_tests(assert_throws, [ | 232 generate_tests(assert_throws, [ |
| 189 ['PaymentRequest constructor should throw for incorrect parameter types.', n ull, function() { | 233 ['PaymentRequest constructor should throw for incorrect parameter types.', n ull, function() { |
| 190 new PaymentRequest('', '', '') | 234 new PaymentRequest('', '', '') |
| 191 }], | 235 }], |
| 192 ['PaymentRequest constructor should throw for undefined required parameters. ', null, function() { | 236 ['PaymentRequest constructor should throw for undefined required parameters. ', null, function() { |
| 193 new PaymentRequest(undefined, undefined) | 237 new PaymentRequest(undefined, undefined) |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 }], | 340 }], |
| 297 ['Null amount should throw', null, function() { | 341 ['Null amount should throw', null, function() { |
| 298 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': null})) | 342 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': null})) |
| 299 }], | 343 }], |
| 300 ['Undefined amount should throw', null, function() { | 344 ['Undefined amount should throw', null, function() { |
| 301 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': undefined})) | 345 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': undefined})) |
| 302 }], | 346 }], |
| 303 ]); | 347 ]); |
| 304 } | 348 } |
| 305 </script> | 349 </script> |
| OLD | NEW |