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

Unified Diff: chrome/test/data/android/payments/dynamic_shipping.js

Issue 2623653003: [Payments] Move Payment Request test files to chrome/test/data/payments (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/android/payments/dynamic_shipping.js
diff --git a/chrome/test/data/android/payments/dynamic_shipping.js b/chrome/test/data/android/payments/dynamic_shipping.js
deleted file mode 100644
index f02c6fa03b979758fd9252691906a9781227f59e..0000000000000000000000000000000000000000
--- a/chrome/test/data/android/payments/dynamic_shipping.js
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2016 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* global PaymentRequest:false */
-/* global toDictionary:false */
-
-/**
- * Launches the PaymentRequest UI that offers free shipping in California and
- * $5.00 shipping in US. Does not allow shipping outside of US.
- */
-function buy() { // eslint-disable-line no-unused-vars
- try {
- var details = {
- total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
- displayItems: [
- {
- label: 'Pending shipping price',
- amount: {currency: 'USD', value: '0.00'},
- pending: true
- },
- {
- label: 'Subtotal',
- amount: {currency: 'USD', value: '5.00'}
- }
- ]
- };
-
- var request = new PaymentRequest(
- [{supportedMethods: ['visa']}], details, {requestShipping: true});
-
- request.addEventListener('shippingaddresschange', function(evt) {
- evt.updateWith(new Promise(function(resolve) {
- resolve(updateDetails(details, request.shippingAddress));
- }));
- });
-
- request.show()
- .then(function(resp) {
- resp.complete('success')
- .then(function() {
- print(
- resp.shippingOption + '<br>' +
- JSON.stringify(
- toDictionary(resp.shippingAddress), undefined, 2) +
- '<br>' + resp.methodName + '<br>' +
- JSON.stringify(resp.details, undefined, 2));
- })
- .catch(function(error) {
- print(error);
- });
- })
- .catch(function(error) {
- print(error);
- });
- } catch (error) {
- print(error.message);
- }
-}
-
-/**
- * Updates the shopping cart with the appropriate shipping prices according to
- * the shipping address.
- * @param {object} details - The shopping cart.
- * @param {ShippingAddress} addr - The shipping address.
- * @return {object} The updated shopping cart.
- */
-function updateDetails(details, addr) {
- if (addr.country === 'US') {
- var shippingOption = {
- id: '',
- label: '',
- amount: {currency: 'USD', value: '0.00'},
- selected: true
- };
- if (addr.region === 'CA') {
- shippingOption.id = 'californiaShippingOption';
- shippingOption.label = 'Free shipping in California';
- details.total.amount.value = '5.00';
- } else {
- shippingOption.id = 'usShippingOption';
- shippingOption.label = 'Standard shipping in US';
- shippingOption.amount.value = '5.00';
- details.total.amount.value = '10.00';
- }
- details.displayItems.splice(0, 1, shippingOption);
- details.shippingOptions = [shippingOption];
- } else {
- delete details.shippingOptions;
- }
- return details;
-}
« no previous file with comments | « chrome/test/data/android/payments/contact_details_and_free_shipping.js ('k') | chrome/test/data/android/payments/email.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698