Bug 1464102 - Uncomment the shippingOptions portion of browser_request_serialization now that todo_is is supported. r?mattn
MozReview-Commit-ID: GdOLGW2i4O1
--- a/browser/components/payments/test/browser/browser_request_serialization.js
+++ b/browser/components/payments/test/browser/browser_request_serialization.js
@@ -24,43 +24,55 @@ add_task(async function test_serializeRe
const args = {
methodData: [PTU.MethodData.basicCard],
details: PTU.Details.twoDisplayItems,
};
await spawnInDialogForMerchantTask(PTU.ContentTasks.createAndShowRequest, testTask, args);
});
add_task(async function test_serializeRequest_shippingOptions() {
- const testTask = ({methodData, details}) => {
+ const testTask = ({methodData, details, options}) => {
let contentWin = Cu.waiveXrays(content);
let store = contentWin.document.querySelector("payment-dialog").requestStore;
let state = store && store.getState();
ok(state, "got request store state");
- // let expected = details;
- // let actual = state.request.paymentDetails;
- // if (expected.shippingOptions) {
- // is(actual.shippingOptions.length, expected.shippingOptions.length,
- // "shippingOptions have same length");
- // for (let i = 0; i < actual.shippingOptions.length; i++) {
- // let item = actual.shippingOptions[i], expectedItem = expected.shippingOptions[i];
- // is(item.label, expectedItem.label, "shippingOption label matches");
- // is(item.amount.value, expectedItem.amount.value, "shippingOption label matches");
- // is(item.amount.currency, expectedItem.amount.currency, "shippingOption label matches");
- // }
- // } else {
- // is(actual.shippingOptions, null, "falsey input shippingOptions is serialized to null");
- // }
+ // The following test cases are conditionally todo because
+ // the spec currently does not state the shippingOptions
+ // should be null when requestShipping is not set. A future
+ // spec change (bug 1436903 comments 7-12) will fix this.
+ let cond_is = options && options.requestShipping ? is : todo_is;
+
+ let expected = details;
+ let actual = state.request.paymentDetails;
+ if (expected.shippingOptions) {
+ cond_is(actual.shippingOptions.length, expected.shippingOptions.length,
+ "shippingOptions have same length");
+ for (let i = 0; i < actual.shippingOptions.length; i++) {
+ let item = actual.shippingOptions[i], expectedItem = expected.shippingOptions[i];
+ cond_is(item.label, expectedItem.label, "shippingOption label matches");
+ cond_is(item.amount.value, expectedItem.amount.value, "shippingOption label matches");
+ cond_is(item.amount.currency, expectedItem.amount.currency, "shippingOption label matches");
+ }
+ } else {
+ cond_is(actual.shippingOptions, null, "falsey input shippingOptions is serialized to null");
+ }
};
- const args = {
+ const argsTestCases = [{
+ methodData: [PTU.MethodData.basicCard],
+ details: PTU.Details.twoShippingOptions,
+ }, {
methodData: [PTU.MethodData.basicCard],
details: PTU.Details.twoShippingOptions,
- };
- await spawnInDialogForMerchantTask(PTU.ContentTasks.createAndShowRequest, testTask, args);
+ options: PTU.Options.requestShippingOption,
+ }];
+ for (let args of argsTestCases) {
+ await spawnInDialogForMerchantTask(PTU.ContentTasks.createAndShowRequest, testTask, args);
+ }
});
add_task(async function test_serializeRequest_paymentMethods() {
const testTask = ({methodData, details}) => {
let contentWin = Cu.waiveXrays(content);
let store = contentWin.document.querySelector("payment-dialog").requestStore;
let state = store && store.getState();
ok(state, "got request store state");