Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: third_party/WebKit/LayoutTests/payments/payment-request-interface.html

Issue 2135633002: Moving assert_throws test cases under generate_tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 160
161 test(function() { 161 test(function() {
162 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' displayItems': []}); 162 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' displayItems': []});
163 }, 'Empty display items should not throw.'); 163 }, 'Empty display items should not throw.');
164 164
165 test(function() { 165 test(function() {
166 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('total', {' value': '0'})); 166 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('total', {' value': '0'}));
167 }, 'Non-negative total value should not throw.'); 167 }, 'Non-negative total value should not throw.');
168 168
169 test(function() { 169 test(function() {
170 assert_throws(new TypeError(), function() {
171 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('total' , {'value': '-0.01'}));
172 });
173 }, 'Negative total value should throw a TypeError.');
174
175 test(function() {
176 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('displayIte ms.0', {'value': '-0.01'})); 170 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('displayIte ms.0', {'value': '-0.01'}));
177 }, 'Negative line item value should not throw.'); 171 }, 'Negative line item value should not throw.');
178 172
179 test(function() { 173 test(function() {
180 assert_throws(new TypeError(), function() {
181 new PaymentRequest([{'supportedMethods': ['foo']}], {'displayItems': [bu ildItem()]});
182 });
183 }, 'Absence of total should throw TypeError.');
184
185 test(function() {
186 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' modifiers': undefined}); 174 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' modifiers': undefined});
187 }, 'Undefined modifiers should not throw.'); 175 }, 'Undefined modifiers should not throw.');
188 176
189 test(function() { 177 test(function() {
190 assert_throws(new TypeError(), function() {
191 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': []});
192 });
193 }, 'Empty modifiers should throw TypeError.');
194
195 test(function() {
196 assert_throws(new TypeError(), function() {
197 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'total': buildItem()}]});
198 });
199 }, 'Absence of supportedMethods in modifiers should throw TypeError.');
200
201 test(function() {
202 assert_throws(new TypeError(), function() {
203 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': []}]});
204 });
205 }, 'Empty supportedMethods in modifiers should throw TypeError.');
206
207 test(function() {
208 assert_throws(new TypeError(), function() {
209 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': undefined}]});
210 });
211 }, 'Undefined supportedMethods in modifiers should throw TypeError.');
212
213 test(function() {
214 assert_throws(new TypeError(), function() {
215 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': null}]});
216 });
217 }, 'Null supportedMethods in modifiers should throw TypeError.');
218
219 test(function() {
220 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' modifiers': [{'supportedMethods': ['foo'], 'total': buildItem({'value': '0.0'})} ]}); 178 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' modifiers': [{'supportedMethods': ['foo'], 'total': buildItem({'value': '0.0'})} ]});
221 }, 'Non-negative total value in PaymentDetailsModifier should not throw.'); 179 }, 'Non-negative total value in PaymentDetailsModifier should not throw.');
222 180
223 test(function() {
224 assert_throws(new TypeError(), function() {
225 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': ['foo'], 'total': buildItem({'value': '-0. 01'})}]});
226 });
227 }, 'Negative total value in PaymentDetailsModifier should throw a TypeError.');
228
229 promise_test(function(t) { 181 promise_test(function(t) {
230 return promise_rejects(t, null, new PaymentRequest([{'supportedMethods': ['f oo']}], buildDetails()).abort()); 182 return promise_rejects(t, null, new PaymentRequest([{'supportedMethods': ['f oo']}], buildDetails()).abort());
231 }, 'abort() without show() should reject with error'); 183 }, 'abort() without show() should reject with error');
232 184
233 generate_tests(assert_throws, [ 185 generate_tests(assert_throws, [
234 ['PaymentRequest constructor should throw for incorrect parameter types.', n ull, function() { 186 ['PaymentRequest constructor should throw for incorrect parameter types.', n ull, function() {
235 new PaymentRequest('', '', '') 187 new PaymentRequest('', '', '')
236 }], 188 }],
237 ['PaymentRequest constructor should throw for undefined required parameters. ', null, function() { 189 ['PaymentRequest constructor should throw for undefined required parameters. ', null, function() {
238 new PaymentRequest(undefined, undefined) 190 new PaymentRequest(undefined, undefined)
239 }], 191 }],
240 ['PaymentRequest constructor should throw for null required parameter.', nul l, function() { 192 ['PaymentRequest constructor should throw for null required parameter.', nul l, function() {
241 new PaymentRequest(null, null) 193 new PaymentRequest(null, null)
242 }], 194 }],
243 ['Empty list of supported payment method identifiers should throw TypeError. ', new TypeError(), function() { 195 ['Empty list of supported payment method identifiers should throw TypeError. ', new TypeError(), function() {
244 new PaymentRequest([], buildDetails()) 196 new PaymentRequest([], buildDetails())
245 }], 197 }],
246 ['Empty supported payment method identifiers should throw TypeError.', null, function() { 198 ['Empty supported payment method identifiers should throw TypeError.', null, function() {
247 new PaymentRequest([{'supportedMethods': []}], buildDetails()) 199 new PaymentRequest([{'supportedMethods': []}], buildDetails())
248 }], 200 }],
249 ['Duplicate supported payment method identifiers should throw TypeError.', n ull, function() { 201 ['Duplicate supported payment method identifiers should throw TypeError.', n ull, function() {
250 new PaymentRequest([{'supportedMethods': ['foo', 'foo']}], buildDetails( ), {}) 202 new PaymentRequest([{'supportedMethods': ['foo', 'foo']}], buildDetails( ), {})
251 }], 203 }],
252 ['Duplicate supported payment method identifiers should throw TypeError.', n ull, function() { 204 ['Duplicate supported payment method identifiers should throw TypeError.', n ull, function() {
253 new PaymentRequest([{'supportedMethods': ['foo']}, {'supportedMethods': ['foo']}], buildDetails(), {}) 205 new PaymentRequest([{'supportedMethods': ['foo']}, {'supportedMethods': ['foo']}], buildDetails(), {})
254 }], 206 }],
207 ['Absence of total should throw TypeError.', null, function() {
208 new PaymentRequest([{'supportedMethods': ['foo']}], {'displayItems': [bu ildItem()]})
209 }],
210 ['Negative total value should throw a TypeError.', null, function() {
211 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('total' , {'value': '-0.01'}))
212 }],
255 ['Duplicate supported payment method identifiers in modifiers should throw T ypeError.', null, function() { 213 ['Duplicate supported payment method identifiers in modifiers should throw T ypeError.', null, function() {
256 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': ['foo', 'foo']}]}) 214 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': ['foo', 'foo']}]})
257 }], 215 }],
258 ['Duplicate supported payment method identifiers in modifiers should throw T ypeError.', null, function() { 216 ['Duplicate supported payment method identifiers in modifiers should throw T ypeError.', null, function() {
259 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': ['foo']}, {'supportedMethods': ['foo']}]}) 217 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': ['foo']}, {'supportedMethods': ['foo']}]})
260 }], 218 }],
219 ['Negative total value in PaymentDetailsModifier should throw a TypeError.', null, function() {
220 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': ['foo'], 'total': buildItem({'value': '-0. 01'})}]})
221 }],
222 ['Null supportedMethods in modifiers should throw TypeError.', null, functio n() {
223 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': null}]})
224 }],
225 ['Undefined supportedMethods in modifiers should throw TypeError.', null, fu nction() {
226 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': undefined}]})
227 }],
228 ['Empty supportedMethods in modifiers should throw TypeError.', null, functi on() {
229 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': []}]})
230 }],
231 ['Absence of supportedMethods in modifiers should throw TypeError.', null, f unction() {
232 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'total': buildItem()}]})
233 }],
234 ['Empty modifiers should throw TypeError.', null, function() {
235 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': []})
236 }],
261 ['Empty details should throw', null, function() { 237 ['Empty details should throw', null, function() {
262 new PaymentRequest([{'supportedMethods': ['foo']}], {}) 238 new PaymentRequest([{'supportedMethods': ['foo']}], {})
263 }], 239 }],
264 ['Null items should throw', new TypeError(), function() { 240 ['Null items should throw', new TypeError(), function() {
265 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'displayItems': null}); 241 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'displayItems': null});
266 }], 242 }],
267 ['Null shipping options should throw', new TypeError(), function() { 243 ['Null shipping options should throw', new TypeError(), function() {
268 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'displayItems': [buildItem()], 'shippingOptions': null}); 244 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'displayItems': [buildItem()], 'shippingOptions': null});
269 }], 245 }],
270 246
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 }], 332 }],
357 ['Null amount should throw', null, function() { 333 ['Null amount should throw', null, function() {
358 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': null})) 334 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': null}))
359 }], 335 }],
360 ['Undefined amount should throw', null, function() { 336 ['Undefined amount should throw', null, function() {
361 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': undefined})) 337 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': undefined}))
362 }], 338 }],
363 ]); 339 ]);
364 } 340 }
365 </script> 341 </script>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698