https://github.com/web-platform-tests/wpt
Raw File
Tip revision: cf94be3b1a0f78b0ecb5e812ecc81f9d5f561cef authored by Eric Willigers on 03 October 2017, 02:38:14 UTC
CSS Motion Path: support <size> for ray paths
Tip revision: cf94be3
payment-request-shippingType-attribute.https.html
<!DOCTYPE html>
<!-- Copyright © 2017 Mozilla and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
<meta charset="utf-8">
<title>Test for PaymentRequest's shippingType attribute</title>
<link rel="help" href="https://w3c.github.io/payment-request/#shippingtype-attribute">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
"use strict";
const paymentShipingTypes = Object.freeze(["delivery", "pickup", "shipping"]);
const basicCard = Object.freeze({ supportedMethods: "basic-card" });
const defaultMethods = Object.freeze([basicCard]);
const defaultDetails = Object.freeze({
  total: {
    label: "",
    amount: {
      currency: "USD",
      value: "1.00",
    },
  },
});

test(() => {
  const request = new PaymentRequest(defaultMethods, defaultDetails);
  assert_idl_attribute(request, "shippingType");
}, "Must have a shippingType IDL attribute");

test(() => {
  const request1 = new PaymentRequest(defaultMethods, defaultDetails, {});
  assert_equals(request1.shippingType, null, "must be null");
  const request2 = new PaymentRequest(defaultMethods, defaultDetails, {
    requestShipping: false,
  });
  assert_equals(request2.shippingType, null, "must be null");
  for (const shippingType of paymentShipingTypes) {
    const request = new PaymentRequest(defaultMethods, defaultDetails, {
      requestShipping: false,
      shippingType,
    });
    assert_equals(request.shippingType, null, "must be null");
  }
}, "If options.requestShipping is false, then request.shippingType attribute is null.");

test(() => {
  // option.shippingType defaults to 'shipping'
  const defaultRequest = new PaymentRequest(defaultMethods, defaultDetails, {
    requestShipping: true,
  });
  assert_equals(defaultRequest.shippingType, "shipping", "must be shipping");
  for (const shippingType of paymentShipingTypes) {
    const request = new PaymentRequest(defaultMethods, defaultDetails, {
      requestShipping: true,
      shippingType,
    });
    assert_equals(
      request.shippingType,
      shippingType,
      `must be ${shippingType}`
    );
  }
}, "If options.requestShipping is true, request.shippingType will be options.shippingType.");
</script>
back to top