| 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, substituteKeyValuePair) { | 7 function substitute(originalObject, substituteKeyValuePair) { |
| 8 for (var key in originalObject) { | 8 for (var key in originalObject) { |
| 9 if (originalObject.hasOwnProperty(key) && substituteKeyValuePair.hasOwnP
roperty(key)) { | 9 if (originalObject.hasOwnProperty(key) && substituteKeyValuePair.hasOwnP
roperty(key)) { |
| 10 originalObject[key] = substituteKeyValuePair[key]; | 10 originalObject[key] = substituteKeyValuePair[key]; |
| 11 } | 11 } |
| 12 } | 12 } |
| 13 } | 13 } |
| 14 | 14 |
| 15 function buildItem(optionalSubstituteKeyValuePair) { | 15 function buildItem(optionalSubstituteKeyValuePair) { |
| 16 var item = {'id': 'item_id', 'label': 'Item Description', 'amount': {'curren
cyCode': 'USD', 'value': '10.00'}}; | 16 var item = {'id': 'item_id', 'label': 'Item Description', 'amount': {'curren
cy': 'USD', 'value': '10.00'}}; |
| 17 | 17 |
| 18 if (optionalSubstituteKeyValuePair) { | 18 if (optionalSubstituteKeyValuePair) { |
| 19 substitute(item, optionalSubstituteKeyValuePair); | 19 substitute(item, optionalSubstituteKeyValuePair); |
| 20 substitute(item['amount'], optionalSubstituteKeyValuePair); | 20 substitute(item['amount'], optionalSubstituteKeyValuePair); |
| 21 } | 21 } |
| 22 | 22 |
| 23 return item; | 23 return item; |
| 24 } | 24 } |
| 25 | 25 |
| 26 function buildDetails(optionalDetailName, optionalSubstituteKeyValuePair) { | 26 function buildDetails(optionalDetailName, optionalSubstituteKeyValuePair) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 ['Numeric value for one of the payment method specific data pieces should th
row', null, function() { | 166 ['Numeric value for one of the payment method specific data pieces should th
row', null, function() { |
| 167 new PaymentRequest(['foo'], buildDetails(), {}, {'foo': 42}) | 167 new PaymentRequest(['foo'], buildDetails(), {}, {'foo': 42}) |
| 168 }], | 168 }], |
| 169 ]); | 169 ]); |
| 170 | 170 |
| 171 var detailNames = ['items', 'shippingOptions']; | 171 var detailNames = ['items', 'shippingOptions']; |
| 172 for (var i in detailNames) { | 172 for (var i in detailNames) { |
| 173 generate_tests(assert_throws, [ | 173 generate_tests(assert_throws, [ |
| 174 // Invalid currency code formats. | 174 // Invalid currency code formats. |
| 175 ['Invalid currency code US1 should throw', null, function() { | 175 ['Invalid currency code US1 should throw', null, function() { |
| 176 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currencyC
ode': 'US1'})) | 176 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currency'
: 'US1'})) |
| 177 }], | 177 }], |
| 178 ['Invalid currency code US should throw', null, function() { | 178 ['Invalid currency code US should throw', null, function() { |
| 179 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currencyC
ode': 'US'})) | 179 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currency'
: 'US'})) |
| 180 }], | 180 }], |
| 181 ['Invalid currency code USDO should throw', null, function() { | 181 ['Invalid currency code USDO should throw', null, function() { |
| 182 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currencyC
ode': 'USDO'})) | 182 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currency'
: 'USDO'})) |
| 183 }], | 183 }], |
| 184 ['Invalid currency code usd should throw', null, function() { | 184 ['Invalid currency code usd should throw', null, function() { |
| 185 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currencyC
ode': 'usd'})) | 185 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currency'
: 'usd'})) |
| 186 }], | 186 }], |
| 187 ['Empty currency code should throw', null, function() { | 187 ['Empty currency code should throw', null, function() { |
| 188 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currencyC
ode': ''})) | 188 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currency'
: ''})) |
| 189 }], | 189 }], |
| 190 ['Null currency code should throw', null, function() { | 190 ['Null currency code should throw', null, function() { |
| 191 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currencyC
ode': null})) | 191 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currency'
: null})) |
| 192 }], | 192 }], |
| 193 ['Undefined currency code should throw', null, function() { | 193 ['Undefined currency code should throw', null, function() { |
| 194 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currencyC
ode': undefined})) | 194 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currency'
: undefined})) |
| 195 }], | 195 }], |
| 196 | 196 |
| 197 // Invalid amount formats. | 197 // Invalid amount formats. |
| 198 ['Invalid amount "-" should throw', null, function() { | 198 ['Invalid amount "-" should throw', null, function() { |
| 199 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': '
-'})) | 199 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': '
-'})) |
| 200 }], | 200 }], |
| 201 ['Invalid amount "notdigits" should throw', null, function() { | 201 ['Invalid amount "notdigits" should throw', null, function() { |
| 202 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': '
notdigits'})) | 202 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': '
notdigits'})) |
| 203 }], | 203 }], |
| 204 ['Invalid amount "ALSONOTDIGITS" should throw', null, function() { | 204 ['Invalid amount "ALSONOTDIGITS" should throw', null, function() { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 233 }], | 233 }], |
| 234 ['Null amount should throw', null, function() { | 234 ['Null amount should throw', null, function() { |
| 235 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': n
ull})) | 235 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': n
ull})) |
| 236 }], | 236 }], |
| 237 ['Undefined amount should throw', null, function() { | 237 ['Undefined amount should throw', null, function() { |
| 238 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': u
ndefined})) | 238 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': u
ndefined})) |
| 239 }], | 239 }], |
| 240 ]); | 240 ]); |
| 241 } | 241 } |
| 242 </script> | 242 </script> |
| OLD | NEW |