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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 assert_equals('standard', request.shippingOption); | 149 assert_equals('standard', request.shippingOption); |
150 }, 'Shipping option identifier should default to the selected shipping option.')
; | 150 }, 'Shipping option identifier should default to the selected shipping option.')
; |
151 | 151 |
152 test(function() { | 152 test(function() { |
153 var shippingOptions = [buildItem({'id': 'standard', 'selected': true}), buil
dItem({'id': 'express', 'selected': true})]; | 153 var shippingOptions = [buildItem({'id': 'standard', 'selected': true}), buil
dItem({'id': 'express', 'selected': true})]; |
154 var request = new PaymentRequest([{'supportedMethods': ['foo']}], {'total':
buildItem(), 'displayItems': [buildItem()], 'shippingOptions': shippingOptions},
{'requestShipping': true}); | 154 var request = new PaymentRequest([{'supportedMethods': ['foo']}], {'total':
buildItem(), 'displayItems': [buildItem()], 'shippingOptions': shippingOptions},
{'requestShipping': true}); |
155 assert_equals('express', request.shippingOption); | 155 assert_equals('express', request.shippingOption); |
156 }, 'Shipping option identifier should default to the last selected shipping opti
on, if multiple are selected.'); | 156 }, 'Shipping option identifier should default to the last selected shipping opti
on, if multiple are selected.'); |
157 | 157 |
158 test(function() { | 158 test(function() { |
| 159 var shippingOptions = [buildItem({'id': 'express', 'selected': false}), buil
dItem({'id': 'express', 'selected': true})]; |
| 160 var request = new PaymentRequest([{'supportedMethods': ['foo']}], {'total':
buildItem(), 'displayItems': [buildItem()], 'shippingOptions': shippingOptions},
{'requestShipping': true}); |
| 161 assert_equals(null, request.shippingOption); |
| 162 }, 'No shipping option selected for duplicate shipping option identifiers.'); |
| 163 |
| 164 test(function() { |
159 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai
ls(), {'requestShipping': false}); | 165 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai
ls(), {'requestShipping': false}); |
160 assert_equals(null, request.shippingType); | 166 assert_equals(null, request.shippingType); |
161 }, 'Shipping type should be null if shipping is explicitly not requested.'); | 167 }, 'Shipping type should be null if shipping is explicitly not requested.'); |
162 | 168 |
163 test(function() { | 169 test(function() { |
164 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai
ls(), {'requestShipping': true}); | 170 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai
ls(), {'requestShipping': true}); |
165 assert_equals('shipping', request.shippingType); | 171 assert_equals('shipping', request.shippingType); |
166 }, 'Shipping type should be \'shipping\' by default if shipping type isn\'t spec
ified.'); | 172 }, 'Shipping type should be \'shipping\' by default if shipping type isn\'t spec
ified.'); |
167 | 173 |
168 test(function() { | 174 test(function() { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 }], | 264 }], |
259 ['Empty supported payment method identifiers should throw TypeError.', null,
function() { | 265 ['Empty supported payment method identifiers should throw TypeError.', null,
function() { |
260 new PaymentRequest([{'supportedMethods': []}], buildDetails()) | 266 new PaymentRequest([{'supportedMethods': []}], buildDetails()) |
261 }], | 267 }], |
262 ['Duplicate supported payment method identifiers should throw TypeError.', n
ull, function() { | 268 ['Duplicate supported payment method identifiers should throw TypeError.', n
ull, function() { |
263 new PaymentRequest([{'supportedMethods': ['foo', 'foo']}], buildDetails(
), {}) | 269 new PaymentRequest([{'supportedMethods': ['foo', 'foo']}], buildDetails(
), {}) |
264 }], | 270 }], |
265 ['Duplicate supported payment method identifiers should throw TypeError.', n
ull, function() { | 271 ['Duplicate supported payment method identifiers should throw TypeError.', n
ull, function() { |
266 new PaymentRequest([{'supportedMethods': ['foo']}, {'supportedMethods':
['foo']}], buildDetails(), {}) | 272 new PaymentRequest([{'supportedMethods': ['foo']}, {'supportedMethods':
['foo']}], buildDetails(), {}) |
267 }], | 273 }], |
268 ['Duplicate shipping option identifiers should throw TypeError.', null, func
tion() { | |
269 var shippingOptions = [buildItem({'id': 'express', 'selected': false}),
buildItem({'id': 'express', 'selected': true})]; | |
270 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(
), 'displayItems': [buildItem()], 'shippingOptions': shippingOptions}, {'request
Shipping': true}) | |
271 }], | |
272 ['Absence of total should throw TypeError.', null, function() { | 274 ['Absence of total should throw TypeError.', null, function() { |
273 new PaymentRequest([{'supportedMethods': ['foo']}], {'displayItems': [bu
ildItem()]}) | 275 new PaymentRequest([{'supportedMethods': ['foo']}], {'displayItems': [bu
ildItem()]}) |
274 }], | 276 }], |
275 ['Negative total value should throw a TypeError.', null, function() { | 277 ['Negative total value should throw a TypeError.', null, function() { |
276 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('total'
, {'value': '-0.01'})) | 278 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('total'
, {'value': '-0.01'})) |
277 }], | 279 }], |
278 ['Duplicate supported payment method identifiers in modifiers should throw T
ypeError.', null, function() { | 280 ['Duplicate supported payment method identifiers in modifiers should throw T
ypeError.', null, function() { |
279 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(
), 'modifiers': [{'supportedMethods': ['foo', 'foo']}]}) | 281 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(
), 'modifiers': [{'supportedMethods': ['foo', 'foo']}]}) |
280 }], | 282 }], |
281 ['Duplicate supported payment method identifiers in modifiers should throw T
ypeError.', null, function() { | 283 ['Duplicate supported payment method identifiers in modifiers should throw T
ypeError.', null, function() { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 }], | 381 }], |
380 ['Null amount should throw', null, function() { | 382 ['Null amount should throw', null, function() { |
381 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': null})) | 383 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': null})) |
382 }], | 384 }], |
383 ['Undefined amount should throw', null, function() { | 385 ['Undefined amount should throw', null, function() { |
384 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': undefined})) | 386 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': undefined})) |
385 }], | 387 }], |
386 ]); | 388 ]); |
387 } | 389 } |
388 </script> | 390 </script> |
OLD | NEW |