@shopify/ui-extensions 2025.10.0-rc.46 → 2025.10.0-rc.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/surfaces/checkout/preact/api.js +1 -1
- package/build/cjs/surfaces/checkout/shared.js +1 -1
- package/build/esm/surfaces/checkout/preact/api.mjs +1 -1
- package/build/esm/surfaces/checkout/shared.mjs +1 -1
- package/build/esnext/surfaces/checkout/preact/api.esnext +1 -1
- package/build/esnext/surfaces/checkout/shared.esnext +1 -1
- package/build/ts/docs/shared/components/ConsentCheckbox.d.ts +4 -0
- package/build/ts/docs/shared/components/ConsentCheckbox.d.ts.map +1 -0
- package/build/ts/docs/shared/components/ConsentPhoneField.d.ts +4 -0
- package/build/ts/docs/shared/components/ConsentPhoneField.d.ts.map +1 -0
- package/build/ts/docs/shared/components/index.d.ts +2 -0
- package/build/ts/docs/shared/components/index.d.ts.map +1 -1
- package/build/ts/surfaces/checkout/components/ConsentCheckbox/ConsentCheckbox.doc.d.ts +4 -0
- package/build/ts/surfaces/checkout/components/ConsentCheckbox/ConsentCheckbox.doc.d.ts.map +1 -0
- package/build/ts/surfaces/checkout/components/ConsentCheckbox.d.ts +84 -0
- package/build/ts/surfaces/checkout/components/ConsentPhoneField/ConsentPhoneField.doc.d.ts +4 -0
- package/build/ts/surfaces/checkout/components/ConsentPhoneField/ConsentPhoneField.doc.d.ts.map +1 -0
- package/build/ts/surfaces/checkout/components/ConsentPhoneField.d.ts +129 -0
- package/build/ts/surfaces/checkout/components/NumberField/NumberField.doc.d.ts +4 -0
- package/build/ts/surfaces/checkout/components/NumberField/NumberField.doc.d.ts.map +1 -0
- package/build/ts/surfaces/checkout/components/NumberField.d.ts +98 -0
- package/build/ts/surfaces/checkout/components/PasswordField.d.ts +1 -1
- package/build/ts/surfaces/checkout/components/components-shared.d.ts +17 -0
- package/build/ts/surfaces/checkout/components/components.d.ts +216 -144
- package/build/ts/surfaces/checkout/shared.d.ts +1 -1
- package/build/ts/surfaces/checkout/shared.d.ts.map +1 -1
- package/build/ts/surfaces/checkout/targets/Checkout::Actions::RenderBefore.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::CartLineDetails::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::CartLineDetails::RenderLineComponents.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::CartLines::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::Contact::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::CustomerInformation::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::DeliveryAddress::RenderBefore.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::Dynamic::Render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::GiftCard::Render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::PaymentMethod::HostedFields::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::PaymentMethod::Render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::PaymentMethod::RenderRequiredAction.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::PickupLocations::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::PickupLocations::RenderBefore.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::PickupPoints::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::PickupPoints::RenderBefore.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::Reductions::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::Reductions::RenderBefore.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::ShippingMethodDetails::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::ShippingMethodDetails::RenderExpanded.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::ShippingMethods::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::ShippingMethods::RenderBefore.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::ThankYou::CartLineDetails::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::ThankYou::CartLines::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::ThankYou::CustomerInformation::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::ThankYou::Dynamic::Render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.cart-line-item.line-components.render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.actions.render-before.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.block.render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.cart-line-item.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.cart-line-list.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.contact.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.delivery-address.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.delivery-address.render-before.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.footer.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.gift-card.render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.header.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.payment-method-list.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.payment-method-list.render-before.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.payment-option-item.action-required.render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.payment-option-item.details.render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.payment-option-item.hosted-fields.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.pickup-location-list.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.pickup-location-list.render-before.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.pickup-location-option-item.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.pickup-point-list.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.pickup-point-list.render-before.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.reductions.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.reductions.render-before.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.shipping-option-item.details.render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.shipping-option-item.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.shipping-option-list.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.shipping-option-list.render-before.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.thank-you.announcement.render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.thank-you.block.render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.thank-you.cart-line-item.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.thank-you.cart-line-list.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.thank-you.customer-information.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.thank-you.footer.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.thank-you.header.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/components/ConsentCheckbox.d.ts +84 -0
- package/build/ts/surfaces/customer-account/components/ConsentPhoneField.d.ts +129 -0
- package/build/ts/surfaces/customer-account/components/NumberField.d.ts +98 -0
- package/build/ts/surfaces/customer-account/components/PasswordField.d.ts +1 -1
- package/build/ts/surfaces/customer-account/components/components-shared.d.ts +17 -0
- package/build/ts/surfaces/customer-account/components/components.d.ts +216 -144
- package/build/ts/surfaces/customer-account/targets/customer-account.footer.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-index.announcement.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-index.block.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.announcement.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.block.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.cart-line-item.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.cart-line-list.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.customer-information.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.fulfillment-details.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.payment-details.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.return-details.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.unfulfilled-items.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order.action.menu-item.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order.action.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order.page.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.page.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.profile.addresses.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.profile.announcement.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.profile.block.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.profile.company-details.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.profile.company-location-addresses.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.profile.company-location-payment.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.profile.company-location-staff.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.profile.payment.render-after.d.ts +3 -0
- package/build/ts/surfaces/point-of-sale/components/Badge.d.ts +10 -1
- package/build/ts/surfaces/point-of-sale/components/Banner.d.ts +12 -4
- package/build/ts/surfaces/point-of-sale/components/Box.d.ts +51 -14
- package/build/ts/surfaces/point-of-sale/components/Button.d.ts +12 -2
- package/build/ts/surfaces/point-of-sale/components/Choice.d.ts +3 -2
- package/build/ts/surfaces/point-of-sale/components/ChoiceList.d.ts +12 -5
- package/build/ts/surfaces/point-of-sale/components/Clickable.d.ts +11 -4
- package/build/ts/surfaces/point-of-sale/components/DateField.d.ts +17 -8
- package/build/ts/surfaces/point-of-sale/components/DatePicker.d.ts +14 -6
- package/build/ts/surfaces/point-of-sale/components/DateSpinner.d.ts +10 -6
- package/build/ts/surfaces/point-of-sale/components/Divider.d.ts +4 -3
- package/build/ts/surfaces/point-of-sale/components/EmailField.d.ts +17 -7
- package/build/ts/surfaces/point-of-sale/components/Heading.d.ts +7 -4
- package/build/ts/surfaces/point-of-sale/components/Icon.d.ts +13 -3
- package/build/ts/surfaces/point-of-sale/components/Image.d.ts +12 -5
- package/build/ts/surfaces/point-of-sale/components/Modal.d.ts +28 -7
- package/build/ts/surfaces/point-of-sale/components/NumberField.d.ts +17 -7
- package/build/ts/surfaces/point-of-sale/components/Page.d.ts +25 -11
- package/build/ts/surfaces/point-of-sale/components/PosBlock.d.ts +12 -13
- package/build/ts/surfaces/point-of-sale/components/QrCode.d.ts +12 -8
- package/build/ts/surfaces/point-of-sale/components/ScrollBox.d.ts +47 -15
- package/build/ts/surfaces/point-of-sale/components/SearchField.d.ts +15 -7
- package/build/ts/surfaces/point-of-sale/components/Section.d.ts +15 -9
- package/build/ts/surfaces/point-of-sale/components/Stack.d.ts +67 -7
- package/build/ts/surfaces/point-of-sale/components/Text.d.ts +25 -4
- package/build/ts/surfaces/point-of-sale/components/TextArea.d.ts +17 -7
- package/build/ts/surfaces/point-of-sale/components/TextField.d.ts +9 -7
- package/build/ts/surfaces/point-of-sale/components/Tile.d.ts +12 -2
- package/build/ts/surfaces/point-of-sale/components/TimeField.d.ts +14 -6
- package/build/ts/surfaces/point-of-sale/components/TimePicker.d.ts +14 -6
- package/build/ts/surfaces/point-of-sale/components/components-shared.d.ts +102 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/src/docs/shared/components/ConsentCheckbox.ts +12 -0
- package/src/docs/shared/components/ConsentPhoneField.ts +12 -0
- package/src/docs/shared/components/index.ts +2 -0
- package/src/surfaces/checkout/components/ConsentCheckbox/examples/basic-consent-checkbox.example.html +5 -0
- package/src/surfaces/checkout/components/ConsentCheckbox.d.ts +84 -0
- package/src/surfaces/checkout/components/ConsentPhoneField/examples/basic-consent-phone-field.example.html +5 -0
- package/src/surfaces/checkout/components/ConsentPhoneField.d.ts +129 -0
- package/src/surfaces/checkout/components/NumberField/examples/basic-number-field.example.html +8 -0
- package/src/surfaces/checkout/components/NumberField.d.ts +98 -0
- package/src/surfaces/checkout/components/PasswordField.d.ts +1 -1
- package/src/surfaces/checkout/components/PhoneField/examples/basic-phone-field.example.html +2 -1
- package/src/surfaces/checkout/components/ProductThumbnail/examples/basic-product-thumbnail.example.html +4 -1
- package/src/surfaces/checkout/components/Stack/examples/basic-stack.example.html +20 -4
- package/src/surfaces/checkout/components/TextArea/examples/basic-text-area.example.html +5 -1
- package/src/surfaces/checkout/components/TextField/examples/basic-text-field.example.html +4 -1
- package/src/surfaces/checkout/components/components-shared.d.ts +17 -0
- package/src/surfaces/checkout/components/components.d.ts +216 -144
- package/src/surfaces/checkout/preact/api.ts +1 -1
- package/src/surfaces/checkout/preact/tests/api.test.tsx +22 -13
- package/src/surfaces/checkout/preact/tests/app-metafields.test.ts +52 -56
- package/src/surfaces/checkout/preact/tests/attributes.test.ts +34 -24
- package/src/surfaces/checkout/preact/tests/billing-address.test.ts +17 -7
- package/src/surfaces/checkout/preact/tests/buyer-identity-businessCustomer.test.ts +16 -9
- package/src/surfaces/checkout/preact/tests/buyer-identity.test.tsx +57 -26
- package/src/surfaces/checkout/preact/tests/buyer-journey.test.ts +71 -74
- package/src/surfaces/checkout/preact/tests/capabilities.test.ts +32 -28
- package/src/surfaces/checkout/preact/tests/cart-line-target.test.ts +31 -24
- package/src/surfaces/checkout/preact/tests/checkout-settings.test.ts +17 -9
- package/src/surfaces/checkout/preact/tests/checkout-token.test.ts +16 -6
- package/src/surfaces/checkout/preact/tests/configuration.test.ts +16 -6
- package/src/surfaces/checkout/preact/tests/country.test.tsx +18 -8
- package/src/surfaces/checkout/preact/tests/currency.test.tsx +18 -8
- package/src/surfaces/checkout/preact/tests/customer-privacy.test.ts +17 -8
- package/src/surfaces/checkout/preact/tests/delivery-group-list-target.test.ts +24 -18
- package/src/surfaces/checkout/preact/tests/delivery-group-target.test.ts +25 -19
- package/src/surfaces/checkout/preact/tests/delivery-group.test.ts +22 -16
- package/src/surfaces/checkout/preact/tests/delivery-groups.test.ts +17 -11
- package/src/surfaces/checkout/preact/tests/delivery-selection-groups.test.ts +31 -24
- package/src/surfaces/checkout/preact/tests/discounts.test.tsx +21 -14
- package/src/surfaces/checkout/preact/tests/extension-language.test.tsx +17 -8
- package/src/surfaces/checkout/preact/tests/gift-cards.test.tsx +17 -8
- package/src/surfaces/checkout/preact/tests/localized-fields.test.ts +58 -59
- package/src/surfaces/checkout/preact/tests/market.test.tsx +17 -7
- package/src/surfaces/checkout/preact/tests/metafield.test.tsx +33 -36
- package/src/surfaces/checkout/preact/tests/metafields.test.tsx +36 -53
- package/src/surfaces/checkout/preact/tests/mount.tsx +60 -17
- package/src/surfaces/checkout/preact/tests/notes.test.tsx +16 -6
- package/src/surfaces/checkout/preact/tests/payment-method.test.ts +87 -60
- package/src/surfaces/checkout/preact/tests/payment-options.test.tsx +26 -24
- package/src/surfaces/checkout/preact/tests/pickup-location-option-target.test.tsx +55 -46
- package/src/surfaces/checkout/preact/tests/redeemable.test.ts +30 -23
- package/src/surfaces/checkout/preact/tests/session-token.test.tsx +12 -6
- package/src/surfaces/checkout/preact/tests/shipping-address.test.ts +17 -7
- package/src/surfaces/checkout/preact/tests/shipping-option-target.test.ts +54 -50
- package/src/surfaces/checkout/preact/tests/shopping-address.test.tsx +18 -10
- package/src/surfaces/checkout/preact/tests/timezone.test.tsx +17 -7
- package/src/surfaces/checkout/preact/tests/translate.test.tsx +18 -13
- package/src/surfaces/checkout/preact/tests/tsconfig.json +1 -1
- package/src/surfaces/checkout/shared.ts +2 -0
- package/src/surfaces/point-of-sale/components/Badge.d.ts +10 -1
- package/src/surfaces/point-of-sale/components/Banner.d.ts +12 -4
- package/src/surfaces/point-of-sale/components/Box.d.ts +51 -14
- package/src/surfaces/point-of-sale/components/Button.d.ts +12 -2
- package/src/surfaces/point-of-sale/components/Choice.d.ts +3 -2
- package/src/surfaces/point-of-sale/components/ChoiceList.d.ts +12 -5
- package/src/surfaces/point-of-sale/components/Clickable.d.ts +11 -4
- package/src/surfaces/point-of-sale/components/DateField.d.ts +17 -8
- package/src/surfaces/point-of-sale/components/DatePicker.d.ts +14 -6
- package/src/surfaces/point-of-sale/components/DateSpinner.d.ts +10 -6
- package/src/surfaces/point-of-sale/components/Divider.d.ts +4 -3
- package/src/surfaces/point-of-sale/components/EmailField.d.ts +17 -7
- package/src/surfaces/point-of-sale/components/Heading.d.ts +7 -4
- package/src/surfaces/point-of-sale/components/Icon.d.ts +13 -3
- package/src/surfaces/point-of-sale/components/Image.d.ts +12 -5
- package/src/surfaces/point-of-sale/components/Modal.d.ts +28 -7
- package/src/surfaces/point-of-sale/components/NumberField.d.ts +17 -7
- package/src/surfaces/point-of-sale/components/Page.d.ts +25 -11
- package/src/surfaces/point-of-sale/components/PosBlock.d.ts +12 -13
- package/src/surfaces/point-of-sale/components/QrCode.d.ts +12 -8
- package/src/surfaces/point-of-sale/components/ScrollBox.d.ts +47 -15
- package/src/surfaces/point-of-sale/components/SearchField.d.ts +15 -7
- package/src/surfaces/point-of-sale/components/Section.d.ts +15 -9
- package/src/surfaces/point-of-sale/components/Stack.d.ts +67 -7
- package/src/surfaces/point-of-sale/components/Text.d.ts +25 -4
- package/src/surfaces/point-of-sale/components/TextArea.d.ts +17 -7
- package/src/surfaces/point-of-sale/components/TextField.d.ts +9 -7
- package/src/surfaces/point-of-sale/components/Tile.d.ts +12 -2
- package/src/surfaces/point-of-sale/components/TimeField.d.ts +14 -6
- package/src/surfaces/point-of-sale/components/TimePicker.d.ts +14 -6
- package/src/surfaces/point-of-sale/components/components-shared.d.ts +102 -1
- package/src/surfaces/point-of-sale/components.d.ts +869 -481
- package/build/ts/surfaces/checkout/errors.d.ts +0 -10
- package/build/ts/surfaces/checkout/errors.d.ts.map +0 -1
- package/src/surfaces/checkout/errors.ts +0 -13
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
DeliveryGroup,
|
|
3
|
-
ExtensionTarget,
|
|
4
|
-
ShippingOption,
|
|
5
|
-
} from '@shopify/ui-extensions/checkout';
|
|
6
|
-
|
|
1
|
+
import type {DeliveryGroup, ShippingOption} from '../../api/standard/standard';
|
|
7
2
|
import {useDeliveryGroupListTarget} from '../delivery-group-list-target';
|
|
8
3
|
|
|
9
|
-
|
|
4
|
+
// See __mocks__/preact/hooks
|
|
5
|
+
jest.mock('preact/hooks');
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
mount,
|
|
9
|
+
createMockSubscribableSignalLike,
|
|
10
|
+
setupGlobalShopifyMock,
|
|
11
|
+
tearDownGlobalShopifyMock,
|
|
12
|
+
createMockExtension,
|
|
13
|
+
} from './mount';
|
|
14
|
+
|
|
15
|
+
describe('useDeliveryGroupListTarget', () => {
|
|
16
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
10
17
|
|
|
11
|
-
describe.skip('useDeliveryGroupListTarget', () => {
|
|
12
18
|
it('returns the DeliveryGroupList target if it exists', async () => {
|
|
13
19
|
const deliveryGroup: DeliveryGroup = {
|
|
14
20
|
selectedDeliveryOption: {
|
|
@@ -57,19 +63,19 @@ describe.skip('useDeliveryGroupListTarget', () => {
|
|
|
57
63
|
],
|
|
58
64
|
};
|
|
59
65
|
|
|
60
|
-
const target
|
|
61
|
-
'purchase.checkout.shipping-option-list.render-before';
|
|
66
|
+
const target =
|
|
67
|
+
'purchase.checkout.shipping-option-list.render-before' as const;
|
|
62
68
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}) as any,
|
|
70
|
-
},
|
|
69
|
+
setupGlobalShopifyMock<typeof target>({
|
|
70
|
+
extension: createMockExtension(target),
|
|
71
|
+
target: createMockSubscribableSignalLike({
|
|
72
|
+
groupType: 'oneTimePurchase',
|
|
73
|
+
deliveryGroups: [deliveryGroup, deliveryGroup2],
|
|
74
|
+
}),
|
|
71
75
|
});
|
|
72
76
|
|
|
77
|
+
const {value} = mount.hook(() => useDeliveryGroupListTarget());
|
|
78
|
+
|
|
73
79
|
expect(value).toStrictEqual({
|
|
74
80
|
groupType: 'oneTimePurchase',
|
|
75
81
|
deliveryGroups: [deliveryGroup, deliveryGroup2],
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
DeliveryGroup,
|
|
3
|
-
ExtensionTarget,
|
|
4
|
-
ShippingOption,
|
|
5
|
-
} from '@shopify/ui-extensions/checkout';
|
|
6
|
-
|
|
1
|
+
import type {DeliveryGroup, ShippingOption} from '../../api/standard/standard';
|
|
7
2
|
// eslint-disable-next-line import-x/no-deprecated
|
|
8
3
|
import {useDeliveryGroupTarget} from '../delivery-group-target';
|
|
9
4
|
|
|
10
|
-
|
|
5
|
+
// See __mocks__/preact/hooks
|
|
6
|
+
jest.mock('preact/hooks');
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
mount,
|
|
10
|
+
createMockSubscribableSignalLike,
|
|
11
|
+
setupGlobalShopifyMock,
|
|
12
|
+
tearDownGlobalShopifyMock,
|
|
13
|
+
createMockExtension,
|
|
14
|
+
} from './mount';
|
|
15
|
+
|
|
16
|
+
describe('useDeliveryGroupTarget', () => {
|
|
17
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
11
18
|
|
|
12
|
-
describe.skip('useDeliveryGroupTarget', () => {
|
|
13
19
|
it('returns the DeliveryGroup target if it exists', async () => {
|
|
14
20
|
const deliveryGroup: DeliveryGroup = {
|
|
15
21
|
selectedDeliveryOption: {
|
|
@@ -58,20 +64,20 @@ describe.skip('useDeliveryGroupTarget', () => {
|
|
|
58
64
|
],
|
|
59
65
|
};
|
|
60
66
|
|
|
61
|
-
const target
|
|
62
|
-
'purchase.checkout.shipping-option-list.render-before';
|
|
67
|
+
const target =
|
|
68
|
+
'purchase.checkout.shipping-option-list.render-before' as const;
|
|
63
69
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
deliveryGroups: [deliveryGroup, deliveryGroup2],
|
|
71
|
-
}) as any,
|
|
72
|
-
},
|
|
70
|
+
setupGlobalShopifyMock<typeof target>({
|
|
71
|
+
extension: createMockExtension(target),
|
|
72
|
+
target: createMockSubscribableSignalLike({
|
|
73
|
+
groupType: 'oneTimePurchase',
|
|
74
|
+
deliveryGroups: [deliveryGroup, deliveryGroup2],
|
|
75
|
+
}),
|
|
73
76
|
});
|
|
74
77
|
|
|
78
|
+
// eslint-disable-next-line import-x/no-deprecated
|
|
79
|
+
const {value} = mount.hook(() => useDeliveryGroupTarget());
|
|
80
|
+
|
|
75
81
|
expect(value).toStrictEqual(deliveryGroup);
|
|
76
82
|
});
|
|
77
83
|
});
|
|
@@ -2,14 +2,23 @@ import type {
|
|
|
2
2
|
DeliveryGroup,
|
|
3
3
|
ShippingOption,
|
|
4
4
|
CartLine,
|
|
5
|
-
} from '
|
|
5
|
+
} from '../../api/standard/standard';
|
|
6
6
|
|
|
7
7
|
import {useDeliveryGroup} from '../delivery-group';
|
|
8
8
|
|
|
9
|
-
import
|
|
10
|
-
|
|
9
|
+
import {
|
|
10
|
+
mount,
|
|
11
|
+
createMockSubscribableSignalLike,
|
|
12
|
+
setupGlobalShopifyMock,
|
|
13
|
+
tearDownGlobalShopifyMock,
|
|
14
|
+
} from './mount';
|
|
15
|
+
|
|
16
|
+
// See __mocks__/preact/hooks
|
|
17
|
+
jest.mock('preact/hooks');
|
|
18
|
+
|
|
19
|
+
describe('Delivery Group API hooks', () => {
|
|
20
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
11
21
|
|
|
12
|
-
describe.skip('Delivery Group API hooks', () => {
|
|
13
22
|
describe('useDeliveryGroup', () => {
|
|
14
23
|
const defaultLine = {
|
|
15
24
|
id: 'gid://shopify/CartLine/stable_id',
|
|
@@ -35,17 +44,16 @@ describe.skip('Delivery Group API hooks', () => {
|
|
|
35
44
|
},
|
|
36
45
|
attributes: [],
|
|
37
46
|
discountAllocations: [],
|
|
47
|
+
parentRelationship: null,
|
|
38
48
|
} as CartLine;
|
|
39
49
|
|
|
40
50
|
it('returns undefined when no delivery group is provided', async () => {
|
|
41
|
-
|
|
42
|
-
lines:
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const {value} = mount.hook(() => useDeliveryGroup(undefined), {
|
|
46
|
-
extensionApi,
|
|
51
|
+
setupGlobalShopifyMock({
|
|
52
|
+
lines: createMockSubscribableSignalLike([defaultLine]),
|
|
47
53
|
});
|
|
48
54
|
|
|
55
|
+
const {value} = mount.hook(() => useDeliveryGroup(undefined));
|
|
56
|
+
|
|
49
57
|
expect(value).toBeUndefined();
|
|
50
58
|
});
|
|
51
59
|
|
|
@@ -112,14 +120,12 @@ describe.skip('Delivery Group API hooks', () => {
|
|
|
112
120
|
],
|
|
113
121
|
};
|
|
114
122
|
|
|
115
|
-
|
|
116
|
-
lines:
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const {value} = mount.hook(() => useDeliveryGroup(deliveryGroup), {
|
|
120
|
-
extensionApi,
|
|
123
|
+
setupGlobalShopifyMock({
|
|
124
|
+
lines: createMockSubscribableSignalLike([defaultLine]),
|
|
121
125
|
});
|
|
122
126
|
|
|
127
|
+
const {value} = mount.hook(() => useDeliveryGroup(deliveryGroup));
|
|
128
|
+
|
|
123
129
|
const expectedDeliveryGroup = {
|
|
124
130
|
...deliveryGroup,
|
|
125
131
|
selectedDeliveryOption: deliveryGroup.deliveryOptions[0],
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
DeliveryGroup,
|
|
3
|
-
ShippingOption,
|
|
4
|
-
} from '@shopify/ui-extensions/checkout';
|
|
1
|
+
import type {DeliveryGroup, ShippingOption} from '../../api/standard/standard';
|
|
5
2
|
|
|
6
3
|
import {useDeliveryGroups} from '../delivery-groups';
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
// See __mocks__/preact/hooks
|
|
6
|
+
jest.mock('preact/hooks');
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
mount,
|
|
10
|
+
createMockSubscribableSignalLike,
|
|
11
|
+
setupGlobalShopifyMock,
|
|
12
|
+
tearDownGlobalShopifyMock,
|
|
13
|
+
} from './mount';
|
|
14
|
+
|
|
15
|
+
describe('Delivery Groups API hooks', () => {
|
|
16
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
10
17
|
|
|
11
|
-
describe.skip('Delivery Groups API hooks', () => {
|
|
12
18
|
describe('useDeliveryGroups', () => {
|
|
13
19
|
it('returns the current devliery groups', async () => {
|
|
14
20
|
const deliveryGroups: DeliveryGroup[] = [
|
|
@@ -51,11 +57,11 @@ describe.skip('Delivery Groups API hooks', () => {
|
|
|
51
57
|
},
|
|
52
58
|
];
|
|
53
59
|
|
|
54
|
-
|
|
55
|
-
deliveryGroups:
|
|
56
|
-
};
|
|
60
|
+
setupGlobalShopifyMock({
|
|
61
|
+
deliveryGroups: createMockSubscribableSignalLike(deliveryGroups),
|
|
62
|
+
});
|
|
57
63
|
|
|
58
|
-
const {value} = mount.hook(() => useDeliveryGroups()
|
|
64
|
+
const {value} = mount.hook(() => useDeliveryGroups());
|
|
59
65
|
|
|
60
66
|
expect(value).toBe(deliveryGroups);
|
|
61
67
|
});
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import {faker} from '@faker-js/faker';
|
|
2
2
|
|
|
3
|
-
import type {ExtensionTarget} from '@shopify/ui-extensions/checkout';
|
|
4
|
-
|
|
5
3
|
import {useDeliverySelectionGroups} from '../delivery-selection-groups';
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
// See __mocks__/preact/hooks
|
|
6
|
+
jest.mock('preact/hooks');
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
mount,
|
|
10
|
+
createMockSubscribableSignalLike,
|
|
11
|
+
setupGlobalShopifyMock,
|
|
12
|
+
tearDownGlobalShopifyMock,
|
|
13
|
+
createMockExtension,
|
|
14
|
+
} from './mount';
|
|
8
15
|
|
|
9
|
-
describe
|
|
16
|
+
describe('useDeliverySelectionGroups', () => {
|
|
17
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
10
18
|
it('returns deliverySelectionGroups if it exists', async () => {
|
|
11
19
|
const deliverySelectionGroup = {
|
|
12
20
|
handle: faker.string.uuid(),
|
|
@@ -18,41 +26,40 @@ describe.skip('useDeliverySelectionGroups', () => {
|
|
|
18
26
|
],
|
|
19
27
|
cost: {
|
|
20
28
|
amount: 10,
|
|
21
|
-
currencyCode: 'USD',
|
|
29
|
+
currencyCode: 'USD' as const,
|
|
22
30
|
},
|
|
23
31
|
costAfterDiscounts: {
|
|
24
32
|
amount: 10,
|
|
25
|
-
currencyCode: 'USD',
|
|
33
|
+
currencyCode: 'USD' as const,
|
|
26
34
|
},
|
|
27
35
|
};
|
|
28
36
|
|
|
29
|
-
const target
|
|
30
|
-
'purchase.checkout.shipping-option-list.render-before';
|
|
37
|
+
const target =
|
|
38
|
+
'purchase.checkout.shipping-option-list.render-before' as const;
|
|
31
39
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
]) as any,
|
|
38
|
-
},
|
|
40
|
+
setupGlobalShopifyMock<typeof target>({
|
|
41
|
+
extension: createMockExtension(target),
|
|
42
|
+
deliverySelectionGroups: createMockSubscribableSignalLike([
|
|
43
|
+
deliverySelectionGroup,
|
|
44
|
+
]),
|
|
39
45
|
});
|
|
40
46
|
|
|
47
|
+
const {value} = mount.hook(() => useDeliverySelectionGroups());
|
|
48
|
+
|
|
41
49
|
expect(value).toStrictEqual([deliverySelectionGroup]);
|
|
42
50
|
});
|
|
43
51
|
|
|
44
52
|
it('returns undefined if delivery selection groups are missing', async () => {
|
|
45
|
-
const target
|
|
46
|
-
'purchase.checkout.shipping-option-list.render-before';
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
deliverySelectionGroups:
|
|
52
|
-
createMockStatefulRemoteSubscribable(undefined),
|
|
53
|
-
},
|
|
53
|
+
const target =
|
|
54
|
+
'purchase.checkout.shipping-option-list.render-before' as const;
|
|
55
|
+
|
|
56
|
+
setupGlobalShopifyMock<typeof target>({
|
|
57
|
+
extension: createMockExtension(target),
|
|
58
|
+
deliverySelectionGroups: createMockSubscribableSignalLike(undefined),
|
|
54
59
|
});
|
|
55
60
|
|
|
61
|
+
const {value} = mount.hook(() => useDeliverySelectionGroups());
|
|
62
|
+
|
|
56
63
|
expect(value).toBeUndefined();
|
|
57
64
|
});
|
|
58
65
|
});
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
CartDiscountCode,
|
|
3
3
|
CartDiscountAllocation,
|
|
4
|
-
} from '
|
|
4
|
+
} from '../../api/standard/standard';
|
|
5
5
|
|
|
6
6
|
import {useDiscountAllocations, useDiscountCodes} from '../discounts';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
// See __mocks__/preact/hooks
|
|
9
|
+
jest.mock('preact/hooks');
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
mount,
|
|
13
|
+
createMockSubscribableSignalLike,
|
|
14
|
+
setupGlobalShopifyMock,
|
|
15
|
+
tearDownGlobalShopifyMock,
|
|
16
|
+
} from './mount';
|
|
17
|
+
|
|
18
|
+
describe('Discounts API hooks', () => {
|
|
19
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
10
20
|
|
|
11
|
-
describe.skip('Discounts API hooks', () => {
|
|
12
21
|
describe('useDiscountCodes', () => {
|
|
13
22
|
it('returns the current discount codes', async () => {
|
|
14
23
|
const discountCodes: CartDiscountCode[] = [
|
|
@@ -16,11 +25,11 @@ describe.skip('Discounts API hooks', () => {
|
|
|
16
25
|
{code: 'free_shipping'},
|
|
17
26
|
];
|
|
18
27
|
|
|
19
|
-
|
|
20
|
-
discountCodes:
|
|
21
|
-
};
|
|
28
|
+
setupGlobalShopifyMock({
|
|
29
|
+
discountCodes: createMockSubscribableSignalLike(discountCodes),
|
|
30
|
+
});
|
|
22
31
|
|
|
23
|
-
const {value} = mount.hook(() => useDiscountCodes()
|
|
32
|
+
const {value} = mount.hook(() => useDiscountCodes());
|
|
24
33
|
|
|
25
34
|
expect(value).toBe(discountCodes);
|
|
26
35
|
});
|
|
@@ -55,15 +64,13 @@ describe.skip('Discounts API hooks', () => {
|
|
|
55
64
|
},
|
|
56
65
|
];
|
|
57
66
|
|
|
58
|
-
|
|
67
|
+
setupGlobalShopifyMock({
|
|
59
68
|
discountAllocations:
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const {value} = mount.hook(() => useDiscountAllocations(), {
|
|
64
|
-
extensionApi,
|
|
69
|
+
createMockSubscribableSignalLike(discountAllocations),
|
|
65
70
|
});
|
|
66
71
|
|
|
72
|
+
const {value} = mount.hook(() => useDiscountAllocations());
|
|
73
|
+
|
|
67
74
|
expect(value).toBe(discountAllocations);
|
|
68
75
|
});
|
|
69
76
|
});
|
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
import {useExtensionLanguage} from '../extension-language';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// See __mocks__/preact/hooks
|
|
4
|
+
jest.mock('preact/hooks');
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
mount,
|
|
8
|
+
createMockSubscribableSignalLike,
|
|
9
|
+
setupGlobalShopifyMock,
|
|
10
|
+
tearDownGlobalShopifyMock,
|
|
11
|
+
} from './mount';
|
|
12
|
+
|
|
13
|
+
describe('useExtensionLanguage', () => {
|
|
14
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
4
15
|
|
|
5
|
-
describe.skip('useExtensionLanguage', () => {
|
|
6
16
|
it('returns extension language from api', () => {
|
|
7
17
|
const extensionLanguage = {isoCode: 'en-CA'};
|
|
8
18
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
extensionLanguage:
|
|
13
|
-
createMockStatefulRemoteSubscribable(extensionLanguage),
|
|
14
|
-
},
|
|
19
|
+
setupGlobalShopifyMock({
|
|
20
|
+
localization: {
|
|
21
|
+
extensionLanguage: createMockSubscribableSignalLike(extensionLanguage),
|
|
15
22
|
},
|
|
16
23
|
});
|
|
17
24
|
|
|
25
|
+
const {value} = mount.hook(() => useExtensionLanguage());
|
|
26
|
+
|
|
18
27
|
expect(value).toStrictEqual(extensionLanguage);
|
|
19
28
|
});
|
|
20
29
|
});
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import type {AppliedGiftCard} from '
|
|
1
|
+
import type {AppliedGiftCard} from '../../api/standard/standard';
|
|
2
2
|
|
|
3
3
|
import {useAppliedGiftCards} from '../gift-cards';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
// See __mocks__/preact/hooks
|
|
6
|
+
jest.mock('preact/hooks');
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
mount,
|
|
10
|
+
createMockSubscribableSignalLike,
|
|
11
|
+
setupGlobalShopifyMock,
|
|
12
|
+
tearDownGlobalShopifyMock,
|
|
13
|
+
} from './mount';
|
|
14
|
+
|
|
15
|
+
describe('Gift cards API hooks', () => {
|
|
16
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
7
17
|
|
|
8
|
-
describe.skip('Gift cards API hooks', () => {
|
|
9
18
|
describe('useAppliedGiftCards', () => {
|
|
10
19
|
it('returns the current gift cards', async () => {
|
|
11
20
|
const giftCards: AppliedGiftCard[] = [
|
|
@@ -21,11 +30,11 @@ describe.skip('Gift cards API hooks', () => {
|
|
|
21
30
|
},
|
|
22
31
|
];
|
|
23
32
|
|
|
24
|
-
|
|
25
|
-
appliedGiftCards:
|
|
26
|
-
};
|
|
33
|
+
setupGlobalShopifyMock({
|
|
34
|
+
appliedGiftCards: createMockSubscribableSignalLike(giftCards),
|
|
35
|
+
});
|
|
27
36
|
|
|
28
|
-
const {value} = mount.hook(() => useAppliedGiftCards()
|
|
37
|
+
const {value} = mount.hook(() => useAppliedGiftCards());
|
|
29
38
|
|
|
30
39
|
expect(value).toBe(giftCards);
|
|
31
40
|
});
|
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
import type {LocalizedField} from '
|
|
1
|
+
import type {LocalizedField} from '../../api/standard/standard';
|
|
2
2
|
|
|
3
3
|
import {useLocalizedFields, useLocalizedField} from '../localized-fields';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// See __mocks__/preact/hooks
|
|
6
|
+
jest.mock('preact/hooks');
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
mount,
|
|
10
|
+
createMockSubscribableSignalLike,
|
|
11
|
+
setupGlobalShopifyMock,
|
|
12
|
+
tearDownGlobalShopifyMock,
|
|
13
|
+
} from './mount';
|
|
14
|
+
|
|
15
|
+
describe('useLocalizedFields', () => {
|
|
16
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
6
17
|
|
|
7
|
-
describe.skip('useLocalizedFields', () => {
|
|
8
18
|
it('throws an error if localized fields are not available', () => {
|
|
9
|
-
|
|
19
|
+
setupGlobalShopifyMock({
|
|
10
20
|
localizedFields: undefined,
|
|
11
|
-
};
|
|
21
|
+
});
|
|
12
22
|
|
|
13
23
|
expect(() => {
|
|
14
|
-
mount.hook(() => useLocalizedFields(['TAX_CREDENTIAL_BR'])
|
|
15
|
-
extensionApi,
|
|
16
|
-
});
|
|
24
|
+
mount.hook(() => useLocalizedFields(['TAX_CREDENTIAL_BR']));
|
|
17
25
|
}).toThrow(
|
|
18
|
-
|
|
26
|
+
expect.objectContaining({
|
|
27
|
+
name: 'ScopeNotGrantedError',
|
|
28
|
+
}),
|
|
19
29
|
);
|
|
20
30
|
});
|
|
21
31
|
|
|
@@ -33,11 +43,11 @@ describe.skip('useLocalizedFields', () => {
|
|
|
33
43
|
},
|
|
34
44
|
];
|
|
35
45
|
|
|
36
|
-
|
|
37
|
-
localizedFields:
|
|
38
|
-
};
|
|
46
|
+
setupGlobalShopifyMock({
|
|
47
|
+
localizedFields: createMockSubscribableSignalLike(localizedFields),
|
|
48
|
+
});
|
|
39
49
|
|
|
40
|
-
const {value} = mount.hook(() => useLocalizedFields()
|
|
50
|
+
const {value} = mount.hook(() => useLocalizedFields());
|
|
41
51
|
|
|
42
52
|
expect(value).toStrictEqual(localizedFields);
|
|
43
53
|
});
|
|
@@ -56,11 +66,11 @@ describe.skip('useLocalizedFields', () => {
|
|
|
56
66
|
},
|
|
57
67
|
];
|
|
58
68
|
|
|
59
|
-
|
|
60
|
-
localizedFields:
|
|
61
|
-
};
|
|
69
|
+
setupGlobalShopifyMock({
|
|
70
|
+
localizedFields: createMockSubscribableSignalLike(localizedFields),
|
|
71
|
+
});
|
|
62
72
|
|
|
63
|
-
const {value} = mount.hook(() => useLocalizedFields([])
|
|
73
|
+
const {value} = mount.hook(() => useLocalizedFields([]));
|
|
64
74
|
|
|
65
75
|
expect(value).toStrictEqual([]);
|
|
66
76
|
});
|
|
@@ -79,14 +89,11 @@ describe.skip('useLocalizedFields', () => {
|
|
|
79
89
|
},
|
|
80
90
|
];
|
|
81
91
|
|
|
82
|
-
|
|
83
|
-
localizedFields:
|
|
84
|
-
};
|
|
92
|
+
setupGlobalShopifyMock({
|
|
93
|
+
localizedFields: createMockSubscribableSignalLike(localizedFields),
|
|
94
|
+
});
|
|
85
95
|
|
|
86
|
-
const {value} = mount.hook(
|
|
87
|
-
() => useLocalizedFields(['TAX_CREDENTIAL_ES']),
|
|
88
|
-
{extensionApi},
|
|
89
|
-
);
|
|
96
|
+
const {value} = mount.hook(() => useLocalizedFields(['TAX_CREDENTIAL_ES']));
|
|
90
97
|
|
|
91
98
|
expect(value).toStrictEqual([]);
|
|
92
99
|
});
|
|
@@ -110,13 +117,12 @@ describe.skip('useLocalizedFields', () => {
|
|
|
110
117
|
},
|
|
111
118
|
];
|
|
112
119
|
|
|
113
|
-
|
|
114
|
-
localizedFields:
|
|
115
|
-
};
|
|
120
|
+
setupGlobalShopifyMock({
|
|
121
|
+
localizedFields: createMockSubscribableSignalLike(localizedFields),
|
|
122
|
+
});
|
|
116
123
|
|
|
117
|
-
const {value} = mount.hook(
|
|
118
|
-
|
|
119
|
-
{extensionApi},
|
|
124
|
+
const {value} = mount.hook(() =>
|
|
125
|
+
useLocalizedFields(['TAX_CREDENTIAL_MX', 'TAX_CREDENTIAL_USE_MX']),
|
|
120
126
|
);
|
|
121
127
|
|
|
122
128
|
expect(value).toMatchObject([localizedFields[0], localizedFields[2]]);
|
|
@@ -141,25 +147,24 @@ describe.skip('useLocalizedFields', () => {
|
|
|
141
147
|
},
|
|
142
148
|
];
|
|
143
149
|
|
|
144
|
-
|
|
145
|
-
localizedFields:
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
const {value} = mount.hook(
|
|
149
|
-
(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
]),
|
|
155
|
-
{extensionApi},
|
|
150
|
+
setupGlobalShopifyMock({
|
|
151
|
+
localizedFields: createMockSubscribableSignalLike(localizedFields),
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const {value} = mount.hook(() =>
|
|
155
|
+
useLocalizedFields([
|
|
156
|
+
'TAX_CREDENTIAL_MX',
|
|
157
|
+
'TAX_CREDENTIAL_BR',
|
|
158
|
+
'TAX_CREDENTIAL_USE_MX',
|
|
159
|
+
]),
|
|
156
160
|
);
|
|
157
161
|
|
|
158
162
|
expect(value).toMatchObject([localizedFields[0], localizedFields[2]]);
|
|
159
163
|
});
|
|
160
164
|
});
|
|
161
165
|
|
|
162
|
-
describe
|
|
166
|
+
describe('useLocalizedField', () => {
|
|
167
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
163
168
|
it('returns the localized field that matches the passed key', async () => {
|
|
164
169
|
const localizedFields: LocalizedField[] = [
|
|
165
170
|
{
|
|
@@ -179,15 +184,12 @@ describe.skip('useLocalizedField', () => {
|
|
|
179
184
|
},
|
|
180
185
|
];
|
|
181
186
|
|
|
182
|
-
|
|
183
|
-
localizedFields:
|
|
184
|
-
};
|
|
187
|
+
setupGlobalShopifyMock({
|
|
188
|
+
localizedFields: createMockSubscribableSignalLike(localizedFields),
|
|
189
|
+
});
|
|
185
190
|
|
|
186
|
-
const {value} = mount.hook(
|
|
187
|
-
|
|
188
|
-
{
|
|
189
|
-
extensionApi,
|
|
190
|
-
},
|
|
191
|
+
const {value} = mount.hook(() =>
|
|
192
|
+
useLocalizedField('TAX_CREDENTIAL_USE_MX'),
|
|
191
193
|
);
|
|
192
194
|
|
|
193
195
|
expect(value).toStrictEqual(localizedFields[2]);
|
|
@@ -196,15 +198,12 @@ describe.skip('useLocalizedField', () => {
|
|
|
196
198
|
it('returns undefined if no localized field matches the passed key', async () => {
|
|
197
199
|
const localizedFields: LocalizedField[] = [];
|
|
198
200
|
|
|
199
|
-
|
|
200
|
-
localizedFields:
|
|
201
|
-
};
|
|
201
|
+
setupGlobalShopifyMock({
|
|
202
|
+
localizedFields: createMockSubscribableSignalLike(localizedFields),
|
|
203
|
+
});
|
|
202
204
|
|
|
203
|
-
const {value} = mount.hook(
|
|
204
|
-
|
|
205
|
-
{
|
|
206
|
-
extensionApi,
|
|
207
|
-
},
|
|
205
|
+
const {value} = mount.hook(() =>
|
|
206
|
+
useLocalizedField('TAX_CREDENTIAL_USE_MX'),
|
|
208
207
|
);
|
|
209
208
|
|
|
210
209
|
expect(value).toBeUndefined();
|