fontdue-js 3.5.1 → 3.7.0
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/CHANGELOG.md +19 -0
- package/README.md +2 -0
- package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.d.ts +3 -1
- package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.js +1 -1
- package/dist/__generated__/CustomerSignInRequestLoginCodeMutation.graphql.d.ts +24 -0
- package/dist/__generated__/CustomerSignInRequestLoginCodeMutation.graphql.js +71 -0
- package/dist/__generated__/CustomerSignInVerifyLoginCodeMutation.graphql.d.ts +30 -0
- package/dist/__generated__/CustomerSignInVerifyLoginCodeMutation.graphql.js +98 -0
- package/dist/__generated__/FontFamiliesQuery.graphql.d.ts +4 -1
- package/dist/__generated__/FontFamiliesQuery.graphql.js +46 -39
- package/dist/__generated__/NewsletterSignupUpdateCustomerMutation.graphql.d.ts +3 -1
- package/dist/__generated__/NewsletterSignupUpdateCustomerMutation.graphql.js +1 -1
- package/dist/__generated__/PriceBar_node.graphql.d.ts +4 -1
- package/dist/__generated__/PriceBar_node.graphql.js +23 -16
- package/dist/__generated__/StoreModalFamily_collection.graphql.d.ts +3 -2
- package/dist/__generated__/StoreModalFamily_collection.graphql.js +3 -3
- package/dist/__generated__/StoreModalIndexPaginationQuery.graphql.d.ts +23 -0
- package/dist/__generated__/StoreModalIndexPaginationQuery.graphql.js +303 -0
- package/dist/__generated__/StoreModalIndexQuery.graphql.d.ts +4 -9
- package/dist/__generated__/StoreModalIndexQuery.graphql.js +90 -53
- package/dist/__generated__/StoreModalIndex_viewer.graphql.d.ts +24 -0
- package/dist/__generated__/StoreModalIndex_viewer.graphql.js +134 -0
- package/dist/__generated__/StoreModalProductContent_collection.graphql.d.ts +4 -1
- package/dist/__generated__/StoreModalProductContent_collection.graphql.js +12 -5
- package/dist/__generated__/StoreModalProductLicenseSelection_collection.graphql.d.ts +2 -1
- package/dist/__generated__/StoreModalProductLicenseSelection_collection.graphql.js +27 -24
- package/dist/__generated__/StoreModalProductQuery.graphql.d.ts +2 -19
- package/dist/__generated__/StoreModalProductQuery.graphql.js +143 -174
- package/dist/__generated__/StoreModalProductRefetchQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalProductRefetchQuery.graphql.js +54 -53
- package/dist/__generated__/StoreModalProductSlugQuery.graphql.d.ts +38 -0
- package/dist/__generated__/StoreModalProductSlugQuery.graphql.js +750 -0
- package/dist/__generated__/StoreModalProductViewer.graphql.d.ts +34 -0
- package/dist/__generated__/StoreModalProductViewer.graphql.js +149 -0
- package/dist/__generated__/StoreModalUnifiedCheckoutUpdateCustomerMutation.graphql.d.ts +3 -1
- package/dist/__generated__/StoreModalUnifiedCheckoutUpdateCustomerMutation.graphql.js +1 -1
- package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.d.ts +3 -1
- package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.js +1 -1
- package/dist/__generated__/TypeTestersIDQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersIDQuery.graphql.js +17 -10
- package/dist/__generated__/TypeTestersRefetchQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersRefetchQuery.graphql.js +17 -10
- package/dist/__generated__/TypeTestersSlugQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersSlugQuery.graphql.js +17 -10
- package/dist/__generated__/storefrontEventsTrackStorefrontEventMutation.graphql.d.ts +41 -0
- package/dist/__generated__/storefrontEventsTrackStorefrontEventMutation.graphql.js +65 -0
- package/dist/__generated__/useCurrentCustomerQuery.graphql.d.ts +23 -0
- package/dist/__generated__/{ServerConfigProviderQuery.graphql.js → useCurrentCustomerQuery.graphql.js} +24 -39
- package/dist/__tests__/bundleSelectionOrder.test.js +92 -0
- package/dist/__tests__/collectionBundleSelection.test.js +441 -1446
- package/dist/__tests__/customerSession.test.js +456 -0
- package/dist/__tests__/infiniteScroll.test.js +180 -0
- package/dist/__tests__/licenseExclusions.test.js +2 -1
- package/dist/__tests__/storeModalRoutes.test.js +118 -0
- package/dist/__tests__/storefrontEvents.test.js +167 -0
- package/dist/__tests__/stripeElements.test.js +173 -0
- package/dist/__tests__/typeTesterAutofitFeatures.test.js +138 -0
- package/dist/__tests__/typeTesterInitialSize.test.js +82 -0
- package/dist/__tests__/typeTesterTruncate.test.js +218 -0
- package/dist/auth/session.d.ts +42 -0
- package/dist/auth/session.js +139 -0
- package/dist/auth/tokenStore.d.ts +61 -0
- package/dist/auth/tokenStore.js +162 -0
- package/dist/components/Cart/Checkout.js +19 -9
- package/dist/components/Cart/storefrontEvents.d.ts +34 -0
- package/dist/components/Cart/storefrontEvents.js +138 -0
- package/dist/components/ConfigContext.d.ts +2 -2
- package/dist/components/CustomerSignIn/index.d.ts +33 -0
- package/dist/components/CustomerSignIn/index.js +170 -0
- package/dist/components/FontFamilies/index.js +4 -3
- package/dist/components/NewsletterSignup/index.js +5 -1
- package/dist/components/Precart/index.js +6 -0
- package/dist/components/PriceBar/index.js +5 -3
- package/dist/components/Root/index.js +4 -34
- package/dist/components/Root/productState.d.ts +2 -8
- package/dist/components/Root/productState.js +46 -57
- package/dist/components/SKUPrice/index.js +7 -8
- package/dist/components/StoreModal/StoreModalFamily.js +4 -2
- package/dist/components/StoreModal/StoreModalIndex.js +48 -7
- package/dist/components/StoreModal/StoreModalProduct.d.ts +5 -1
- package/dist/components/StoreModal/StoreModalProduct.js +69 -16
- package/dist/components/StoreModal/index.js +14 -14
- package/dist/components/StoreModal/routes.js +9 -1
- package/dist/components/StoreModalProductLicenseSelection/StoreModalProductLicense.d.ts +2 -1
- package/dist/components/StoreModalProductLicenseSelection/StoreModalProductLicense.js +8 -3
- package/dist/components/StoreModalProductLicenseSelection/index.js +3 -2
- package/dist/components/TestFontsForm/index.js +5 -1
- package/dist/components/TypeTester/TypeTesterContent.js +9 -2
- package/dist/components/TypeTester/TypeTesterContext.js +17 -4
- package/dist/components/TypeTester/TypeTesterFitter.js +7 -2
- package/dist/components/TypeTester/TypeTesterStandalone.d.ts +2 -0
- package/dist/components/TypeTester/TypeTesterStandalone.js +2 -0
- package/dist/components/TypeTester/TypeTesterStandaloneElement.d.ts +1 -0
- package/dist/components/TypeTester/TypeTesterStandaloneElement.js +4 -1
- package/dist/components/TypeTester/TypeTesterVariableAxes.js +16 -10
- package/dist/components/TypeTester/index.d.ts +3 -1
- package/dist/components/TypeTester/index.js +2 -1
- package/dist/components/TypeTester/truncate.d.ts +12 -0
- package/dist/components/TypeTester/truncate.js +95 -0
- package/dist/components/TypeTester/useTypeTesterStyler.d.ts +3 -1
- package/dist/components/TypeTester/useTypeTesterStyler.js +36 -7
- package/dist/components/TypeTesters/TypeTestersElement.d.ts +2 -1
- package/dist/components/TypeTesters/TypeTestersElement.js +4 -1
- package/dist/components/TypeTesters/index.d.ts +2 -0
- package/dist/components/elements/StoreModalContainer/StoreModalContainerContext.d.ts +1 -0
- package/dist/components/elements/StoreModalContainer/index.js +9 -4
- package/dist/components/elements/StoreModalIndexLoadMore/index.d.ts +8 -0
- package/dist/components/elements/StoreModalIndexLoadMore/index.js +21 -0
- package/dist/components/elements/StoreModalUnifiedCheckout.d.ts +1 -1
- package/dist/components/elements/StoreModalUnifiedCheckout.js +20 -17
- package/dist/components/useInfiniteScroll.d.ts +28 -0
- package/dist/components/useInfiniteScroll.js +50 -0
- package/dist/fontdue.css +63 -0
- package/dist/hooks/useAutofit.d.ts +2 -1
- package/dist/hooks/useAutofit.js +10 -4
- package/dist/hooks/useCurrentCustomer.d.ts +34 -0
- package/dist/hooks/useCurrentCustomer.js +93 -0
- package/dist/reducer.d.ts +5 -5
- package/dist/reducer.js +9 -87
- package/dist/relay/environment.js +91 -50
- package/dist/selection.d.ts +40 -0
- package/dist/selection.js +494 -0
- package/dist/storeModalRoutes.d.ts +38 -0
- package/dist/storeModalRoutes.js +110 -0
- package/dist/stripeElements.d.ts +18 -0
- package/dist/stripeElements.js +49 -0
- package/dist/utils.d.ts +1 -12
- package/dist/utils.js +1 -36
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/__generated__/NodePasswordFormIDQuery.graphql.d.ts +0 -21
- package/dist/__generated__/NodePasswordFormIDQuery.graphql.js +0 -86
- package/dist/__generated__/NodePasswordFormSlugQuery.graphql.d.ts +0 -25
- package/dist/__generated__/NodePasswordFormSlugQuery.graphql.js +0 -108
- package/dist/__generated__/ServerConfigProviderQuery.graphql.d.ts +0 -24
- package/dist/__generated__/TestModeBannerQuery.graphql.d.ts +0 -20
- package/dist/__generated__/TestModeBannerQuery.graphql.js +0 -87
- package/dist/__generated__/ThemeConfigQuery.graphql.d.ts +0 -20
- package/dist/__generated__/ThemeConfigQuery.graphql.js +0 -87
- package/dist/components/CartButton/index.server.d.ts +0 -3
- package/dist/components/CartButton/index.server.js +0 -18
- package/dist/components/CorsErrorModal.d.ts +0 -1
- package/dist/components/CorsErrorModal.js +0 -92
- package/dist/components/FontdueProvider/FontdueProviderClientComponent.d.ts +0 -14
- package/dist/components/FontdueProvider/FontdueProviderClientComponent.js +0 -61
- package/dist/components/ThemeConfig/index.server.d.ts +0 -2
- package/dist/components/ThemeConfig/index.server.js +0 -17
- package/dist/components/TypeTester/features.d.ts +0 -5
- package/dist/components/TypeTester/features.js +0 -143
- package/dist/data/unicodeData.d.ts +0 -4
- package/dist/data/unicodeData.js +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @generated SignedSource<<9ae3ba7e6860093c0576aa023d6951d2>>
|
|
3
|
+
* @lightSyntaxTransform
|
|
4
|
+
* @nogrep
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* tslint:disable */
|
|
8
|
+
/* eslint-disable */
|
|
9
|
+
// @ts-nocheck
|
|
10
|
+
|
|
11
|
+
const node = function () {
|
|
12
|
+
var v0 = [{
|
|
13
|
+
"defaultValue": null,
|
|
14
|
+
"kind": "LocalArgument",
|
|
15
|
+
"name": "input"
|
|
16
|
+
}],
|
|
17
|
+
v1 = [{
|
|
18
|
+
"alias": null,
|
|
19
|
+
"args": [{
|
|
20
|
+
"kind": "Variable",
|
|
21
|
+
"name": "input",
|
|
22
|
+
"variableName": "input"
|
|
23
|
+
}],
|
|
24
|
+
"concreteType": "TrackStorefrontEventPayload",
|
|
25
|
+
"kind": "LinkedField",
|
|
26
|
+
"name": "trackStorefrontEvent",
|
|
27
|
+
"plural": false,
|
|
28
|
+
"selections": [{
|
|
29
|
+
"alias": null,
|
|
30
|
+
"args": null,
|
|
31
|
+
"kind": "ScalarField",
|
|
32
|
+
"name": "success",
|
|
33
|
+
"storageKey": null
|
|
34
|
+
}],
|
|
35
|
+
"storageKey": null
|
|
36
|
+
}];
|
|
37
|
+
return {
|
|
38
|
+
"fragment": {
|
|
39
|
+
"argumentDefinitions": v0 /*: any*/,
|
|
40
|
+
"kind": "Fragment",
|
|
41
|
+
"metadata": null,
|
|
42
|
+
"name": "storefrontEventsTrackStorefrontEventMutation",
|
|
43
|
+
"selections": v1 /*: any*/,
|
|
44
|
+
"type": "RootMutationType",
|
|
45
|
+
"abstractKey": null
|
|
46
|
+
},
|
|
47
|
+
"kind": "Request",
|
|
48
|
+
"operation": {
|
|
49
|
+
"argumentDefinitions": v0 /*: any*/,
|
|
50
|
+
"kind": "Operation",
|
|
51
|
+
"name": "storefrontEventsTrackStorefrontEventMutation",
|
|
52
|
+
"selections": v1 /*: any*/
|
|
53
|
+
},
|
|
54
|
+
"params": {
|
|
55
|
+
"cacheID": "12055553008f9ecb33d23e0a70e7760b",
|
|
56
|
+
"id": null,
|
|
57
|
+
"metadata": {},
|
|
58
|
+
"name": "storefrontEventsTrackStorefrontEventMutation",
|
|
59
|
+
"operationKind": "mutation",
|
|
60
|
+
"text": "mutation storefrontEventsTrackStorefrontEventMutation(\n $input: TrackStorefrontEventInput!\n) {\n trackStorefrontEvent(input: $input) {\n success\n }\n}\n"
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}();
|
|
64
|
+
node.hash = "340cc13477a15b926e2307d36c644053";
|
|
65
|
+
export default node;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @generated SignedSource<<381b4b431e552f7023d2cafdf5a2e346>>
|
|
3
|
+
* @lightSyntaxTransform
|
|
4
|
+
* @nogrep
|
|
5
|
+
*/
|
|
6
|
+
import { ConcreteRequest } from 'relay-runtime';
|
|
7
|
+
export type useCurrentCustomerQuery$variables = Record<PropertyKey, never>;
|
|
8
|
+
export type useCurrentCustomerQuery$data = {
|
|
9
|
+
readonly viewer: {
|
|
10
|
+
readonly currentCustomer: {
|
|
11
|
+
readonly email: string | null;
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly name: string | null;
|
|
14
|
+
readonly newsletterOptIn: boolean | null;
|
|
15
|
+
} | null;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type useCurrentCustomerQuery = {
|
|
19
|
+
response: useCurrentCustomerQuery$data;
|
|
20
|
+
variables: useCurrentCustomerQuery$variables;
|
|
21
|
+
};
|
|
22
|
+
declare const node: ConcreteRequest;
|
|
23
|
+
export default node;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
1
|
/**
|
|
8
|
-
* @generated SignedSource<<
|
|
2
|
+
* @generated SignedSource<<381b4b431e552f7023d2cafdf5a2e346>>
|
|
9
3
|
* @lightSyntaxTransform
|
|
10
4
|
* @nogrep
|
|
11
5
|
*/
|
|
@@ -16,48 +10,46 @@ exports.default = void 0;
|
|
|
16
10
|
|
|
17
11
|
const node = function () {
|
|
18
12
|
var v0 = {
|
|
19
|
-
"alias": null,
|
|
20
|
-
"args": null,
|
|
21
|
-
"concreteType": "FontdueConfig",
|
|
22
|
-
"kind": "LinkedField",
|
|
23
|
-
"name": "fontdueConfig",
|
|
24
|
-
"plural": false,
|
|
25
|
-
"selections": [{
|
|
26
13
|
"alias": null,
|
|
27
14
|
"args": null,
|
|
28
|
-
"
|
|
15
|
+
"kind": "ScalarField",
|
|
16
|
+
"name": "id",
|
|
17
|
+
"storageKey": null
|
|
18
|
+
},
|
|
19
|
+
v1 = {
|
|
20
|
+
"alias": null,
|
|
21
|
+
"args": null,
|
|
22
|
+
"concreteType": "Customer",
|
|
29
23
|
"kind": "LinkedField",
|
|
30
|
-
"name": "
|
|
24
|
+
"name": "currentCustomer",
|
|
31
25
|
"plural": false,
|
|
32
|
-
"selections": [{
|
|
26
|
+
"selections": [v0 /*: any*/, {
|
|
33
27
|
"alias": null,
|
|
34
28
|
"args": null,
|
|
35
29
|
"kind": "ScalarField",
|
|
36
|
-
"name": "
|
|
30
|
+
"name": "name",
|
|
37
31
|
"storageKey": null
|
|
38
32
|
}, {
|
|
39
33
|
"alias": null,
|
|
40
34
|
"args": null,
|
|
41
35
|
"kind": "ScalarField",
|
|
42
|
-
"name": "
|
|
36
|
+
"name": "email",
|
|
43
37
|
"storageKey": null
|
|
44
38
|
}, {
|
|
45
39
|
"alias": null,
|
|
46
40
|
"args": null,
|
|
47
41
|
"kind": "ScalarField",
|
|
48
|
-
"name": "
|
|
42
|
+
"name": "newsletterOptIn",
|
|
49
43
|
"storageKey": null
|
|
50
44
|
}],
|
|
51
45
|
"storageKey": null
|
|
52
|
-
}
|
|
53
|
-
"storageKey": null
|
|
54
|
-
};
|
|
46
|
+
};
|
|
55
47
|
return {
|
|
56
48
|
"fragment": {
|
|
57
49
|
"argumentDefinitions": [],
|
|
58
50
|
"kind": "Fragment",
|
|
59
51
|
"metadata": null,
|
|
60
|
-
"name": "
|
|
52
|
+
"name": "useCurrentCustomerQuery",
|
|
61
53
|
"selections": [{
|
|
62
54
|
"alias": null,
|
|
63
55
|
"args": null,
|
|
@@ -65,7 +57,7 @@ const node = function () {
|
|
|
65
57
|
"kind": "LinkedField",
|
|
66
58
|
"name": "viewer",
|
|
67
59
|
"plural": false,
|
|
68
|
-
"selections": [
|
|
60
|
+
"selections": [v1 /*: any*/],
|
|
69
61
|
"storageKey": null
|
|
70
62
|
}],
|
|
71
63
|
"type": "RootQueryType",
|
|
@@ -75,7 +67,7 @@ const node = function () {
|
|
|
75
67
|
"operation": {
|
|
76
68
|
"argumentDefinitions": [],
|
|
77
69
|
"kind": "Operation",
|
|
78
|
-
"name": "
|
|
70
|
+
"name": "useCurrentCustomerQuery",
|
|
79
71
|
"selections": [{
|
|
80
72
|
"alias": null,
|
|
81
73
|
"args": null,
|
|
@@ -83,26 +75,19 @@ const node = function () {
|
|
|
83
75
|
"kind": "LinkedField",
|
|
84
76
|
"name": "viewer",
|
|
85
77
|
"plural": false,
|
|
86
|
-
"selections": [
|
|
87
|
-
"alias": null,
|
|
88
|
-
"args": null,
|
|
89
|
-
"kind": "ScalarField",
|
|
90
|
-
"name": "id",
|
|
91
|
-
"storageKey": null
|
|
92
|
-
}],
|
|
78
|
+
"selections": [v1 /*: any*/, v0 /*: any*/],
|
|
93
79
|
"storageKey": null
|
|
94
80
|
}]
|
|
95
81
|
},
|
|
96
82
|
"params": {
|
|
97
|
-
"cacheID": "
|
|
83
|
+
"cacheID": "de0bab935a204bfab8d75cb6ac56b264",
|
|
98
84
|
"id": null,
|
|
99
85
|
"metadata": {},
|
|
100
|
-
"name": "
|
|
86
|
+
"name": "useCurrentCustomerQuery",
|
|
101
87
|
"operationKind": "query",
|
|
102
|
-
"text": "query
|
|
88
|
+
"text": "query useCurrentCustomerQuery {\n viewer {\n currentCustomer {\n id\n name\n email\n newsletterOptIn\n }\n id\n }\n}\n"
|
|
103
89
|
}
|
|
104
90
|
};
|
|
105
91
|
}();
|
|
106
|
-
node.hash = "
|
|
107
|
-
|
|
108
|
-
exports.default = _default;
|
|
92
|
+
node.hash = "bbd9b896d31a326af6b8525fdd4464c0";
|
|
93
|
+
export default node;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
// Mock react-relay's graphql tag since productState.ts uses it at import time
|
|
4
|
+
vi.mock('react-relay', () => ({
|
|
5
|
+
graphql: () => null,
|
|
6
|
+
fetchQuery: vi.fn()
|
|
7
|
+
}));
|
|
8
|
+
import reducer from '../reducer.js';
|
|
9
|
+
// A family shaped like a real foundry catalog: 7 uprights + 7 italics at
|
|
10
|
+
// 9000 each, with overlapping style bundles – every pair of uprights (15%
|
|
11
|
+
// off), each upright with its italic (20% off), a handful of upright
|
|
12
|
+
// triples (25% off), and the upright / italic halves.
|
|
13
|
+
const UPRIGHTS = ['Thin', 'Light', 'Book', 'Regular', 'Medium', 'Semibold', 'Bold'];
|
|
14
|
+
const ITALICS = UPRIGHTS.map(name => name === 'Regular' ? 'Italic' : `${name} Italic`);
|
|
15
|
+
const STYLE_PRICE = 9000;
|
|
16
|
+
const pairs = items => items.flatMap((a, i) => items.slice(i + 1).map(b => [a, b]));
|
|
17
|
+
const BUNDLES = [[UPRIGHTS, 45000], [ITALICS, 45000], ...UPRIGHTS.map((name, i) => [[name, ITALICS[i]], 14400]), ...pairs(UPRIGHTS).map(styles => [styles, 15300]), ...[['Light', 'Regular', 'Bold'], ['Book', 'Regular', 'Bold'], ['Light', 'Semibold', 'Italic'], ['Book', 'Semibold', 'Italic'], ['Regular', 'Bold', 'Italic'], ['Thin', 'Regular', 'Bold'], ['Light', 'Book', 'Semibold'], ['Book', 'Semibold', 'Bold']].map(styles => [styles, 20250])];
|
|
18
|
+
const sku = (id, amount) => ({
|
|
19
|
+
id,
|
|
20
|
+
price: {
|
|
21
|
+
amount
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const styleSku = name => `sku:${name}`;
|
|
25
|
+
const style = name => ({
|
|
26
|
+
id: `style:${name}`,
|
|
27
|
+
sku: sku(styleSku(name), STYLE_PRICE)
|
|
28
|
+
});
|
|
29
|
+
const catalog = {
|
|
30
|
+
node: {
|
|
31
|
+
__typename: 'FontCollection',
|
|
32
|
+
id: 'family',
|
|
33
|
+
name: 'Family',
|
|
34
|
+
sku: sku('sku:family', 90000),
|
|
35
|
+
fontStyles: [...UPRIGHTS, ...ITALICS].map(style),
|
|
36
|
+
bundles: BUNDLES.map(_ref => {
|
|
37
|
+
let [styles, price] = _ref;
|
|
38
|
+
return {
|
|
39
|
+
id: `bundle:${styles.join('+')}`,
|
|
40
|
+
name: styles.join(' + '),
|
|
41
|
+
sku: sku(`sku:bundle:${styles.join('+')}`, price),
|
|
42
|
+
fontStyles: styles.map(style)
|
|
43
|
+
};
|
|
44
|
+
}),
|
|
45
|
+
collectionBundles: [],
|
|
46
|
+
children: []
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
function loadedState() {
|
|
50
|
+
const empty = {
|
|
51
|
+
cartOpen: false,
|
|
52
|
+
precartOpen: false,
|
|
53
|
+
selectedSkuIds: {},
|
|
54
|
+
requestedSkuIds: [],
|
|
55
|
+
licenseOptions: [],
|
|
56
|
+
skuStyleIds: {},
|
|
57
|
+
collectionSkus: {},
|
|
58
|
+
skuPrices: {},
|
|
59
|
+
fetchedCollectionIds: [],
|
|
60
|
+
storeModalRoute: {
|
|
61
|
+
name: 'index'
|
|
62
|
+
},
|
|
63
|
+
storeModalHistory: [],
|
|
64
|
+
orderVariableSelections: [],
|
|
65
|
+
licenseeIsBillingIdentity: null
|
|
66
|
+
};
|
|
67
|
+
return reducer(empty, {
|
|
68
|
+
type: 'POPULATE_PRODUCT_STATE',
|
|
69
|
+
data: catalog
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const clickStyles = names => names.reduce((state, name) => reducer(state, {
|
|
73
|
+
type: 'SELECT_SKU_ID',
|
|
74
|
+
skuId: styleSku(name),
|
|
75
|
+
selected: true
|
|
76
|
+
}), loadedState());
|
|
77
|
+
const selectionTotal = state => Object.keys(state.selectedSkuIds).filter(id => state.selectedSkuIds[id] === true).reduce((sum, id) => sum + state.skuPrices[id], 0);
|
|
78
|
+
const permutations = items => items.length <= 1 ? [items] : items.flatMap((item, i) => permutations([...items.slice(0, i), ...items.slice(i + 1)]).map(rest => [item, ...rest]));
|
|
79
|
+
describe('style bundle discounts do not depend on click order', () => {
|
|
80
|
+
it.each(permutations(['Bold', 'Regular', 'Light']))('Light + Regular + Bold bundle price when clicked %s, %s, %s', function () {
|
|
81
|
+
for (var _len = arguments.length, order = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
82
|
+
order[_key] = arguments[_key];
|
|
83
|
+
}
|
|
84
|
+
expect(selectionTotal(clickStyles(order))).toBe(20250);
|
|
85
|
+
});
|
|
86
|
+
it.each(permutations(['Bold', 'Bold Italic', 'Regular', 'Italic']))('two upright + italic pairs when clicked %s, %s, %s, %s', function () {
|
|
87
|
+
for (var _len2 = arguments.length, order = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
88
|
+
order[_key2] = arguments[_key2];
|
|
89
|
+
}
|
|
90
|
+
expect(selectionTotal(clickStyles(order))).toBe(28800);
|
|
91
|
+
});
|
|
92
|
+
});
|