@lookiero/checkout 0.1.2 → 0.2.1
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/dist/infrastructure/delivery/_mock/bootstrap.mock.js +2 -1
- package/dist/infrastructure/delivery/bootstrap.d.ts +2 -1
- package/dist/infrastructure/delivery/bootstrap.js +3 -2
- package/dist/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.js +2 -1
- package/dist/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.js +2 -1
- package/dist/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.js +2 -1
- package/dist/infrastructure/projection/react/useViewUiSettingByKey.js +3 -1
- package/dist/infrastructure/ui/Root.js +8 -10
- package/dist/infrastructure/ui/components/atoms/spinner/Spinner.js +9 -0
- package/dist/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +4 -4
- package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +12 -9
- package/dist/infrastructure/ui/routing/Routing.js +11 -14
- package/dist/infrastructure/ui/views/intro/Intro.js +5 -7
- package/dist/infrastructure/ui/views/item/Item.js +6 -8
- package/dist/infrastructure/ui/views/summary/Summary.js +5 -7
- package/package.json +7 -5
- package/.eslintignore +0 -7
- package/.eslintrc +0 -72
- package/.expo-shared/assets.json +0 -4
- package/.github/CODEOWNERS +0 -1
- package/.github/actions/version/action.yaml +0 -32
- package/.github/dependabot.yaml +0 -10
- package/.github/workflows/build.yaml +0 -71
- package/.github/workflows/publish.yaml +0 -52
- package/.husky/pre-commit +0 -4
- package/.husky/prepare-commit-msg +0 -26
- package/.husky/prepush +0 -12
- package/.lintstagedrc.json +0 -4
- package/.nvmrc +0 -1
- package/.prettierignore +0 -2
- package/.prettierrc.json +0 -6
- package/@types/aurora-next.d.ts +0 -1
- package/app.config.js +0 -4
- package/app.json +0 -31
- package/assets/adaptive-icon.png +0 -0
- package/assets/favicon.png +0 -0
- package/assets/icon.png +0 -0
- package/assets/splash.png +0 -0
- package/babel.config.js +0 -6
- package/dist/infrastructure/ui/components/atoms/spiner/Spinner.js +0 -11
- package/dist/infrastructure/ui/test/render.d.ts +0 -19
- package/dist/infrastructure/ui/test/render.js +0 -14
- package/jest.config.js +0 -9
- package/jest.setup.js +0 -3
- package/src/Expo.tsx +0 -59
- package/src/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -26
- package/src/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.ts +0 -35
- package/src/domain/checkoutBooking/model/checkoutBooking.test.ts +0 -30
- package/src/domain/checkoutBooking/model/checkoutBooking.ts +0 -33
- package/src/domain/checkoutBooking/model/checkoutBookingBooked.test.ts +0 -23
- package/src/domain/checkoutBooking/model/checkoutBookingBooked.ts +0 -23
- package/src/domain/checkoutBooking/model/checkoutBookings.ts +0 -8
- package/src/domain/uiSetting/command/updateUiSetting.test.ts +0 -19
- package/src/domain/uiSetting/command/updateUiSetting.ts +0 -25
- package/src/domain/uiSetting/model/uiSetting.test.ts +0 -26
- package/src/domain/uiSetting/model/uiSetting.ts +0 -24
- package/src/domain/uiSetting/model/uiSettingUpdated.test.ts +0 -17
- package/src/domain/uiSetting/model/uiSettingUpdated.ts +0 -21
- package/src/domain/uiSetting/model/uiSettings.ts +0 -8
- package/src/index.ts +0 -44
- package/src/infrastructure/delivery/_mock/bootstrap.mock.ts +0 -38
- package/src/infrastructure/delivery/_mock/checkout.mock.ts +0 -81
- package/src/infrastructure/delivery/bootstrap.ts +0 -42
- package/src/infrastructure/delivery/http/fetchHttpClient.test.ts +0 -51
- package/src/infrastructure/delivery/http/fetchHttpClient.ts +0 -41
- package/src/infrastructure/delivery/http/httpClient.ts +0 -18
- package/src/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.test.ts +0 -45
- package/src/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.ts +0 -34
- package/src/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -38
- package/src/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.ts +0 -46
- package/src/infrastructure/domain/react/useSetCheckoutIntroShown.test.ts +0 -34
- package/src/infrastructure/domain/react/useSetCheckoutIntroShown.ts +0 -30
- package/src/infrastructure/domain/react/useUpdateUiSetting.test.ts +0 -31
- package/src/infrastructure/domain/react/useUpdateUiSetting.ts +0 -45
- package/src/infrastructure/domain/uiSetting/model/storageUiSettings.test.ts +0 -50
- package/src/infrastructure/domain/uiSetting/model/storageUiSettings.ts +0 -52
- package/src/infrastructure/persistence/asyncStorageStorage.ts +0 -13
- package/src/infrastructure/persistence/storage.ts +0 -9
- package/src/infrastructure/persistence/uiSettingData.ts +0 -7
- package/src/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.test.ts +0 -65
- package/src/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.ts +0 -102
- package/src/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.test.ts +0 -99
- package/src/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.ts +0 -128
- package/src/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.test.ts +0 -32
- package/src/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.ts +0 -27
- package/src/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -51
- package/src/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.ts +0 -25
- package/src/infrastructure/projection/react/useViewCheckoutIntroShown.test.ts +0 -41
- package/src/infrastructure/projection/react/useViewCheckoutIntroShown.ts +0 -9
- package/src/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.test.ts +0 -28
- package/src/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.ts +0 -22
- package/src/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.test.ts +0 -44
- package/src/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.ts +0 -24
- package/src/infrastructure/projection/react/useViewUiSettingByKey.test.ts +0 -30
- package/src/infrastructure/projection/react/useViewUiSettingByKey.ts +0 -24
- package/src/infrastructure/projection/storageUiSettingByKeyView.test.ts +0 -32
- package/src/infrastructure/projection/storageUiSettingByKeyView.ts +0 -37
- package/src/infrastructure/ui/Root.tsx +0 -53
- package/src/infrastructure/ui/components/atoms/spiner/Spinner.style.ts +0 -12
- package/src/infrastructure/ui/components/atoms/spiner/Spinner.tsx +0 -35
- package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.test.tsx +0 -70
- package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.tsx +0 -31
- package/src/infrastructure/ui/routing/CheckoutMiddleware.test.tsx +0 -100
- package/src/infrastructure/ui/routing/CheckoutMiddleware.tsx +0 -52
- package/src/infrastructure/ui/routing/Routing.tsx +0 -64
- package/src/infrastructure/ui/routing/router/Router.native.ts +0 -1
- package/src/infrastructure/ui/routing/router/Router.ts +0 -1
- package/src/infrastructure/ui/routing/routes.ts +0 -6
- package/src/infrastructure/ui/settings/UISettings.ts +0 -5
- package/src/infrastructure/ui/test/render.tsx +0 -47
- package/src/infrastructure/ui/views/intro/Intro.test.tsx +0 -15
- package/src/infrastructure/ui/views/intro/Intro.tsx +0 -27
- package/src/infrastructure/ui/views/item/Item.tsx +0 -31
- package/src/infrastructure/ui/views/summary/Summary.tsx +0 -27
- package/src/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -40
- package/src/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.ts +0 -85
- package/src/projection/checkout/viewFirstAvailableCheckoutByCustomerId.test.ts +0 -22
- package/src/projection/checkout/viewFirstAvailableCheckoutByCustomerId.ts +0 -149
- package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.test.ts +0 -54
- package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.ts +0 -46
- package/src/projection/checkout/viewIsCheckoutEnabledByCustomerId.test.ts +0 -20
- package/src/projection/checkout/viewIsCheckoutEnabledByCustomerId.ts +0 -51
- package/src/projection/uiSetting/viewUiSettingByKey.test.ts +0 -22
- package/src/projection/uiSetting/viewUiSettingByKey.ts +0 -55
- package/tsconfig.build.json +0 -16
- package/tsconfig.json +0 -19
- package/webpack.config.js +0 -17
- /package/dist/infrastructure/ui/components/atoms/{spiner → spinner}/Spinner.d.ts +0 -0
- /package/dist/infrastructure/ui/components/atoms/{spiner → spinner}/Spinner.style.d.ts +0 -0
- /package/dist/infrastructure/ui/components/atoms/{spiner → spinner}/Spinner.style.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { NativeRouter as Router } from "react-router-native";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { BrowserRouter as Router } from "react-router-dom";
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Aurora } from "@lookiero/aurora-next/build/components/primitives/Aurora/Aurora";
|
|
2
|
-
import { FC, Fragment, ReactElement } from "react";
|
|
3
|
-
import { render, RenderAPI } from "@testing-library/react-native";
|
|
4
|
-
import { IntlProvider } from "react-intl";
|
|
5
|
-
import { TranslationMessages } from "@lookiero/i18n/domain/translation/model/translationMessages";
|
|
6
|
-
import { MessagingRoot } from "@lookiero/messaging-react/bootstrap";
|
|
7
|
-
|
|
8
|
-
interface Viewport {
|
|
9
|
-
readonly height: number;
|
|
10
|
-
readonly width: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const defaultViewport: Viewport = { width: 1200, height: 800 };
|
|
14
|
-
|
|
15
|
-
interface RenderArgs {
|
|
16
|
-
readonly locale?: string;
|
|
17
|
-
readonly viewport?: Viewport;
|
|
18
|
-
readonly messages?: TranslationMessages;
|
|
19
|
-
readonly messaging?: MessagingRoot;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface RenderWrapperFunction {
|
|
23
|
-
(args: RenderArgs): FC<{ children: ReactElement }>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const renderWrapper: RenderWrapperFunction =
|
|
27
|
-
({ locale, viewport, messages = {}, messaging: Messaging = Fragment }) =>
|
|
28
|
-
// eslint-disable-next-line react/display-name, react/prop-types
|
|
29
|
-
({ children }) =>
|
|
30
|
-
(
|
|
31
|
-
<Aurora forceViewport={viewport}>
|
|
32
|
-
<IntlProvider messages={messages} locale={locale as string} onError={() => void 0}>
|
|
33
|
-
<Messaging>{children}</Messaging>
|
|
34
|
-
</IntlProvider>
|
|
35
|
-
</Aurora>
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
interface RenderWithProvidersFunction {
|
|
39
|
-
(ui: ReactElement, args?: RenderArgs): RenderAPI;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const renderWithProviders: RenderWithProvidersFunction = (
|
|
43
|
-
ui: ReactElement,
|
|
44
|
-
{ locale, viewport, messages, messaging } = { locale: "en", viewport: defaultViewport },
|
|
45
|
-
): RenderAPI => render(ui, { wrapper: renderWrapper({ locale, viewport, messages, messaging }) });
|
|
46
|
-
|
|
47
|
-
export { renderWithProviders as render };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { screen } from "@testing-library/react-native";
|
|
2
|
-
import { render } from "../../test/render";
|
|
3
|
-
import { Intro } from "./Intro";
|
|
4
|
-
|
|
5
|
-
const messages = { intro: "Intro text" };
|
|
6
|
-
|
|
7
|
-
describe("Intro component", () => {
|
|
8
|
-
it("renders Intro component", async () => {
|
|
9
|
-
render(<Intro />, { messages });
|
|
10
|
-
|
|
11
|
-
const text = await screen.findByText(messages.intro);
|
|
12
|
-
|
|
13
|
-
expect(text).toBeTruthy();
|
|
14
|
-
});
|
|
15
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
2
|
-
import { ReactIntl } from "@lookiero/i18n-react";
|
|
3
|
-
import { FC } from "react";
|
|
4
|
-
import { StyleSheet, View } from "react-native";
|
|
5
|
-
|
|
6
|
-
const Intro: FC = () => {
|
|
7
|
-
const introText = ReactIntl.useI18nMessage({ id: "intro" });
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<View style={styles.container}>
|
|
11
|
-
<Text heading={true} level={3}>
|
|
12
|
-
{introText}
|
|
13
|
-
</Text>
|
|
14
|
-
</View>
|
|
15
|
-
);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const styles = StyleSheet.create({
|
|
19
|
-
container: {
|
|
20
|
-
flex: 1,
|
|
21
|
-
backgroundColor: "#fff",
|
|
22
|
-
alignItems: "center",
|
|
23
|
-
justifyContent: "center",
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export { Intro };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
2
|
-
import { ReactIntl } from "@lookiero/i18n-react";
|
|
3
|
-
import { FC } from "react";
|
|
4
|
-
import { StyleSheet, View } from "react-native";
|
|
5
|
-
import { useParams } from "react-router-native";
|
|
6
|
-
|
|
7
|
-
const Item: FC = () => {
|
|
8
|
-
const { id } = useParams();
|
|
9
|
-
|
|
10
|
-
const itemText = ReactIntl.useI18nMessage({ id: "item" });
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<View style={styles.container}>
|
|
14
|
-
<Text heading={true} level={3}>
|
|
15
|
-
{itemText}
|
|
16
|
-
</Text>
|
|
17
|
-
<Text level={2}>{id}</Text>
|
|
18
|
-
</View>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const styles = StyleSheet.create({
|
|
23
|
-
container: {
|
|
24
|
-
flex: 1,
|
|
25
|
-
backgroundColor: "#fff",
|
|
26
|
-
alignItems: "center",
|
|
27
|
-
justifyContent: "center",
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export { Item };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
2
|
-
import { ReactIntl } from "@lookiero/i18n-react";
|
|
3
|
-
import { FC } from "react";
|
|
4
|
-
import { StyleSheet, View } from "react-native";
|
|
5
|
-
|
|
6
|
-
const Summary: FC = () => {
|
|
7
|
-
const summaryText = ReactIntl.useI18nMessage({ id: "summary" });
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<View style={styles.container}>
|
|
11
|
-
<Text heading={true} level={3}>
|
|
12
|
-
{summaryText}
|
|
13
|
-
</Text>
|
|
14
|
-
</View>
|
|
15
|
-
);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const styles = StyleSheet.create({
|
|
19
|
-
container: {
|
|
20
|
-
flex: 1,
|
|
21
|
-
backgroundColor: "#fff",
|
|
22
|
-
alignItems: "center",
|
|
23
|
-
justifyContent: "center",
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export { Summary };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { QueryBus } from "@lookiero/messaging";
|
|
2
|
-
import { mock } from "jest-mock-extended";
|
|
3
|
-
import {
|
|
4
|
-
BookedSizeReplaceableProductVariantsProjection,
|
|
5
|
-
viewBookedSizeReplaceableProductVariantsForCheckoutItem,
|
|
6
|
-
viewBookedSizeReplaceableProductVariantsForCheckoutItemHandler,
|
|
7
|
-
} from "./viewBookedSizeReplaceableProductVariantsForCheckoutItem";
|
|
8
|
-
|
|
9
|
-
const checkoutItemId = "6f720954-8039-4bed-9596-34fc5a02131b";
|
|
10
|
-
const bookedSizeReplaceableProductVariants: BookedSizeReplaceableProductVariantsProjection = {
|
|
11
|
-
booking: "b00e2c2d-7d9c-4808-88a4-e1c845ae6889",
|
|
12
|
-
productVariants: [
|
|
13
|
-
{
|
|
14
|
-
id: "383fab95-56eb-4639-bb18-530ab792b4d3",
|
|
15
|
-
size: {
|
|
16
|
-
id: "4f8a26b8-8d2d-4012-b49a-7d2820095598",
|
|
17
|
-
europe: { size: "36", format: "36" },
|
|
18
|
-
lookiero: { size: "S", format: "S" },
|
|
19
|
-
uk: { size: "8", format: "8" },
|
|
20
|
-
it: { size: "M", format: "M" },
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
};
|
|
25
|
-
const queryBus = mock<QueryBus>();
|
|
26
|
-
|
|
27
|
-
describe("viewBookedSizeReplaceableProductVariantsForCheckoutItem", () => {
|
|
28
|
-
it("returns booked size replaceable product variants for checkout item", async () => {
|
|
29
|
-
const query = viewBookedSizeReplaceableProductVariantsForCheckoutItem({ checkoutItemId });
|
|
30
|
-
const view = jest.fn(() => Promise.resolve(bookedSizeReplaceableProductVariants));
|
|
31
|
-
|
|
32
|
-
const bookedSizeReplaceableProductVariantsResult =
|
|
33
|
-
await viewBookedSizeReplaceableProductVariantsForCheckoutItemHandler({
|
|
34
|
-
view,
|
|
35
|
-
queryBus,
|
|
36
|
-
})(query);
|
|
37
|
-
|
|
38
|
-
expect(bookedSizeReplaceableProductVariantsResult).toBe(bookedSizeReplaceableProductVariants);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { query, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
|
|
2
|
-
|
|
3
|
-
interface SizeFormat {
|
|
4
|
-
readonly format: string;
|
|
5
|
-
readonly length?: string;
|
|
6
|
-
readonly size: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface Size {
|
|
10
|
-
readonly id: string;
|
|
11
|
-
readonly europe: SizeFormat;
|
|
12
|
-
readonly it: SizeFormat;
|
|
13
|
-
readonly lookiero: SizeFormat;
|
|
14
|
-
readonly uk: SizeFormat;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface ProductVariant {
|
|
18
|
-
readonly id: string;
|
|
19
|
-
readonly size: Size;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface BookedSizeReplaceableProductVariantsProjection {
|
|
23
|
-
readonly booking: string | null;
|
|
24
|
-
readonly productVariants: ProductVariant[];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM =
|
|
28
|
-
"view_booked_size_replaceable_product_variants_for_checkout_item";
|
|
29
|
-
|
|
30
|
-
interface ViewBookedSizeReplaceableProductVariantsForCheckoutItemPayload {
|
|
31
|
-
readonly checkoutItemId: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface ViewBookedSizeReplaceableProductVariantsForCheckoutItem
|
|
35
|
-
extends Query<typeof VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM>,
|
|
36
|
-
ViewBookedSizeReplaceableProductVariantsForCheckoutItemPayload {}
|
|
37
|
-
|
|
38
|
-
interface ViewBookedSizeReplaceableProductVariantsForCheckoutItemFunction {
|
|
39
|
-
(
|
|
40
|
-
payload: ViewBookedSizeReplaceableProductVariantsForCheckoutItemPayload,
|
|
41
|
-
): ViewBookedSizeReplaceableProductVariantsForCheckoutItem;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const viewBookedSizeReplaceableProductVariantsForCheckoutItem: ViewBookedSizeReplaceableProductVariantsForCheckoutItemFunction =
|
|
45
|
-
(payload) => ({
|
|
46
|
-
...query({ name: VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM }),
|
|
47
|
-
...payload,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
type ViewBookedSizeReplaceableProductVariantsForCheckoutItemResult =
|
|
51
|
-
| BookedSizeReplaceableProductVariantsProjection
|
|
52
|
-
| undefined;
|
|
53
|
-
|
|
54
|
-
interface BookedSizeReplaceableProductVariantsForCheckoutItemViewArgs {
|
|
55
|
-
readonly checkoutItemId: string;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
interface BookedSizeReplaceableProductVariantsForCheckoutItemView {
|
|
59
|
-
(
|
|
60
|
-
args: BookedSizeReplaceableProductVariantsForCheckoutItemViewArgs,
|
|
61
|
-
): Promise<ViewBookedSizeReplaceableProductVariantsForCheckoutItemResult>;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
interface ViewBookedSizeReplaceableProductVariantsForCheckoutItemHandlerFunctionArgs extends QueryHandlerFunctionArgs {
|
|
65
|
-
readonly view: BookedSizeReplaceableProductVariantsForCheckoutItemView;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const viewBookedSizeReplaceableProductVariantsForCheckoutItemHandler: QueryHandlerFunction<
|
|
69
|
-
ViewBookedSizeReplaceableProductVariantsForCheckoutItem,
|
|
70
|
-
ViewBookedSizeReplaceableProductVariantsForCheckoutItemResult,
|
|
71
|
-
ViewBookedSizeReplaceableProductVariantsForCheckoutItemHandlerFunctionArgs
|
|
72
|
-
> =
|
|
73
|
-
({ view }) =>
|
|
74
|
-
async ({ checkoutItemId }) =>
|
|
75
|
-
view({ checkoutItemId });
|
|
76
|
-
|
|
77
|
-
export {
|
|
78
|
-
Size,
|
|
79
|
-
ProductVariant,
|
|
80
|
-
BookedSizeReplaceableProductVariantsProjection,
|
|
81
|
-
VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM,
|
|
82
|
-
viewBookedSizeReplaceableProductVariantsForCheckoutItem,
|
|
83
|
-
BookedSizeReplaceableProductVariantsForCheckoutItemView,
|
|
84
|
-
viewBookedSizeReplaceableProductVariantsForCheckoutItemHandler,
|
|
85
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { QueryBus } from "@lookiero/messaging";
|
|
2
|
-
import { mock } from "jest-mock-extended";
|
|
3
|
-
import {
|
|
4
|
-
CheckoutProjection,
|
|
5
|
-
viewFirstAvailableCheckoutByCustomerId,
|
|
6
|
-
viewFirstAvailableCheckoutByCustomerIdHandler as sut,
|
|
7
|
-
} from "./viewFirstAvailableCheckoutByCustomerId";
|
|
8
|
-
|
|
9
|
-
const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
10
|
-
const checkoutProjection: CheckoutProjection = { id: "75574065-5838-42de-9924-c712f7854347" } as CheckoutProjection;
|
|
11
|
-
const queryBus = mock<QueryBus>();
|
|
12
|
-
|
|
13
|
-
describe("viewFirstAvailableCheckoutByCustomerId", () => {
|
|
14
|
-
it("returns the first available checkout by customer id", async () => {
|
|
15
|
-
const query = viewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
16
|
-
const view = jest.fn(() => Promise.resolve(checkoutProjection));
|
|
17
|
-
|
|
18
|
-
const checkoutProjectionResult = await sut({ view, queryBus })(query);
|
|
19
|
-
|
|
20
|
-
expect(checkoutProjectionResult).toBe(checkoutProjection);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { query, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
|
|
2
|
-
|
|
3
|
-
enum MediaPerspective {
|
|
4
|
-
BACK = "BACK",
|
|
5
|
-
BOTTOM_UP = "BOTTOM_UP",
|
|
6
|
-
COLLAGE = "COLLAGE",
|
|
7
|
-
DETAIL = "DETAIL",
|
|
8
|
-
FLAT_BACK = "FLAT_BACK",
|
|
9
|
-
FRONT = "FRONT",
|
|
10
|
-
FRONT_FAR = "FRONT_FAR",
|
|
11
|
-
LABEL = "LABEL",
|
|
12
|
-
MAIN = "MAIN",
|
|
13
|
-
MAIN_TRANSPARENT = "MAIN_TRANSPARENT",
|
|
14
|
-
OTHER = "OTHER",
|
|
15
|
-
SIDE = "SIDE",
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface MediaProjection {
|
|
19
|
-
readonly id: string;
|
|
20
|
-
readonly url: string;
|
|
21
|
-
readonly perspective: MediaPerspective;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
enum Currency {
|
|
25
|
-
EUR = "EUR",
|
|
26
|
-
GBP = "GBP",
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface PriceProjection {
|
|
30
|
-
readonly amount: number;
|
|
31
|
-
readonly currency: Currency;
|
|
32
|
-
readonly discountedPrice?: {
|
|
33
|
-
readonly amount: number;
|
|
34
|
-
readonly percentage: number;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
interface SizeProjection {
|
|
39
|
-
readonly id: string;
|
|
40
|
-
readonly lookiero: string;
|
|
41
|
-
readonly uk: string;
|
|
42
|
-
readonly it: string;
|
|
43
|
-
readonly europe: string;
|
|
44
|
-
readonly unique: boolean;
|
|
45
|
-
readonly visualOrder?: number;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
interface ColorProjection {
|
|
49
|
-
readonly id: string;
|
|
50
|
-
readonly label: string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface CheckoutItemProductVariantProjection {
|
|
54
|
-
readonly id: string;
|
|
55
|
-
readonly media: MediaProjection[];
|
|
56
|
-
readonly brand: string;
|
|
57
|
-
readonly name: string;
|
|
58
|
-
readonly price: PriceProjection;
|
|
59
|
-
readonly size: SizeProjection;
|
|
60
|
-
readonly color: ColorProjection;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
enum CheckoutItemStatus {
|
|
64
|
-
INITIAL = "INITIAL",
|
|
65
|
-
KEPT = "KEPT",
|
|
66
|
-
RETURNED = "RETURNED",
|
|
67
|
-
REPLACED = "REPLACED",
|
|
68
|
-
EXPIRED = "EXPIRED",
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
interface CheckoutItemProjection {
|
|
72
|
-
readonly id: string;
|
|
73
|
-
readonly status: CheckoutItemStatus;
|
|
74
|
-
readonly replacedFor?: string;
|
|
75
|
-
readonly productVariant: CheckoutItemProductVariantProjection;
|
|
76
|
-
// readonly feedbacks: Feedback[];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
enum CheckoutStatus {
|
|
80
|
-
AVAILABLE = "AVAILABLE",
|
|
81
|
-
NOTIFIED = "NOTIFIED",
|
|
82
|
-
STARTED = "STARTED",
|
|
83
|
-
COMPLETED = "COMPLETED",
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
interface CheckoutProjection {
|
|
87
|
-
readonly id: string;
|
|
88
|
-
readonly customerId: string;
|
|
89
|
-
readonly boxId: string;
|
|
90
|
-
readonly bookingId: string;
|
|
91
|
-
readonly status: CheckoutStatus;
|
|
92
|
-
readonly expiresOn: Date;
|
|
93
|
-
readonly items: CheckoutItemProjection[];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID = "view_first_available_checkout_by_customer_id";
|
|
97
|
-
|
|
98
|
-
interface ViewFirstAvailableCheckoutByCustomerIdPayload {
|
|
99
|
-
readonly customerId: string;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
interface ViewFirstAvailableCheckoutByCustomerId
|
|
103
|
-
extends Query<typeof VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID>,
|
|
104
|
-
ViewFirstAvailableCheckoutByCustomerIdPayload {}
|
|
105
|
-
|
|
106
|
-
interface ViewFirstAvailableCheckoutByCustomerIdFunction {
|
|
107
|
-
(payload: ViewFirstAvailableCheckoutByCustomerIdPayload): ViewFirstAvailableCheckoutByCustomerId;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const viewFirstAvailableCheckoutByCustomerId: ViewFirstAvailableCheckoutByCustomerIdFunction = (payload) => ({
|
|
111
|
-
...query({ name: VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID }),
|
|
112
|
-
...payload,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
type ViewFirstAvailableCheckoutByCustomerIdResult = CheckoutProjection | undefined;
|
|
116
|
-
|
|
117
|
-
interface FirstAvailableCheckoutByCustomerIdViewArgs {
|
|
118
|
-
readonly customerId: string;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
interface FirstAvailableCheckoutByCustomerIdView {
|
|
122
|
-
(args: FirstAvailableCheckoutByCustomerIdViewArgs): Promise<ViewFirstAvailableCheckoutByCustomerIdResult>;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
interface ViewFirstAvailableCheckoutByCustomerIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
|
|
126
|
-
readonly view: FirstAvailableCheckoutByCustomerIdView;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const viewFirstAvailableCheckoutByCustomerIdHandler: QueryHandlerFunction<
|
|
130
|
-
ViewFirstAvailableCheckoutByCustomerId,
|
|
131
|
-
ViewFirstAvailableCheckoutByCustomerIdResult,
|
|
132
|
-
ViewFirstAvailableCheckoutByCustomerIdHandlerFunctionArgs
|
|
133
|
-
> =
|
|
134
|
-
({ view }) =>
|
|
135
|
-
async ({ customerId }) =>
|
|
136
|
-
view({ customerId });
|
|
137
|
-
|
|
138
|
-
export {
|
|
139
|
-
CheckoutProjection,
|
|
140
|
-
CheckoutStatus,
|
|
141
|
-
CheckoutItemProjection,
|
|
142
|
-
CheckoutItemStatus,
|
|
143
|
-
MediaPerspective,
|
|
144
|
-
Currency,
|
|
145
|
-
VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID,
|
|
146
|
-
viewFirstAvailableCheckoutByCustomerId,
|
|
147
|
-
FirstAvailableCheckoutByCustomerIdView,
|
|
148
|
-
viewFirstAvailableCheckoutByCustomerIdHandler,
|
|
149
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { bootstrap } from "@lookiero/messaging";
|
|
2
|
-
import {
|
|
3
|
-
CheckoutProjection,
|
|
4
|
-
viewFirstAvailableCheckoutByCustomerIdHandler,
|
|
5
|
-
VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID,
|
|
6
|
-
} from "./viewFirstAvailableCheckoutByCustomerId";
|
|
7
|
-
import {
|
|
8
|
-
viewIsCheckoutAccessibleByCustomerId,
|
|
9
|
-
viewIsCheckoutAccessibleByCustomerIdHandler,
|
|
10
|
-
VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID,
|
|
11
|
-
} from "./viewIsCheckoutAccessibleByCustomerId";
|
|
12
|
-
import {
|
|
13
|
-
viewIsCheckoutEnabledByCustomerIdHandler,
|
|
14
|
-
VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID,
|
|
15
|
-
} from "./viewIsCheckoutEnabledByCustomerId";
|
|
16
|
-
|
|
17
|
-
const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
18
|
-
const checkoutProjection: CheckoutProjection = { id: "75574065-5838-42de-9924-c712f7854347" };
|
|
19
|
-
const firstAvailableCheckoutByCustomerIdViewMock = jest.fn();
|
|
20
|
-
const isCheckoutEnabledByCustomerIdViewMock = jest.fn();
|
|
21
|
-
|
|
22
|
-
const { queryBus } = bootstrap()
|
|
23
|
-
.query(VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerIdHandler, {
|
|
24
|
-
view: firstAvailableCheckoutByCustomerIdViewMock,
|
|
25
|
-
})
|
|
26
|
-
.query(VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, viewIsCheckoutEnabledByCustomerIdHandler, {
|
|
27
|
-
view: isCheckoutEnabledByCustomerIdViewMock,
|
|
28
|
-
})
|
|
29
|
-
.query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler, {})
|
|
30
|
-
.build();
|
|
31
|
-
|
|
32
|
-
// expectedResult, customerId, CheckoutProjection, isCheckoutEnabled
|
|
33
|
-
type Scenarios = [boolean, string | undefined, CheckoutProjection | undefined, boolean][];
|
|
34
|
-
const scenarios: Scenarios = [
|
|
35
|
-
[false, undefined, checkoutProjection, true],
|
|
36
|
-
[false, customerId, undefined, true],
|
|
37
|
-
[false, customerId, checkoutProjection, false],
|
|
38
|
-
[true, customerId, checkoutProjection, true],
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
describe("viewIsCheckoutAccessibleByCustomerId", () => {
|
|
42
|
-
test.each(scenarios)(
|
|
43
|
-
"Returns %s when customer is %s, checkout projection is %s and the checkout is enabled: %s",
|
|
44
|
-
async (expectedResult, customerId, checkout, isEnabled) => {
|
|
45
|
-
firstAvailableCheckoutByCustomerIdViewMock.mockReturnValue(checkout);
|
|
46
|
-
isCheckoutEnabledByCustomerIdViewMock.mockReturnValue(isEnabled);
|
|
47
|
-
const query = viewIsCheckoutAccessibleByCustomerId({ customerId });
|
|
48
|
-
|
|
49
|
-
const result = await queryBus(query);
|
|
50
|
-
|
|
51
|
-
expect(result).toBe(expectedResult);
|
|
52
|
-
},
|
|
53
|
-
);
|
|
54
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { query, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
|
|
2
|
-
import { viewFirstAvailableCheckoutByCustomerId } from "./viewFirstAvailableCheckoutByCustomerId";
|
|
3
|
-
import { viewIsCheckoutEnabledByCustomerId } from "./viewIsCheckoutEnabledByCustomerId";
|
|
4
|
-
|
|
5
|
-
type IsCheckoutAccessibleByCustomerIdProjection = boolean;
|
|
6
|
-
|
|
7
|
-
const VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID = "view_is_checkout_accessible_by_customer_id";
|
|
8
|
-
|
|
9
|
-
interface ViewIsCheckoutAccessibleByCustomerIdPayload {
|
|
10
|
-
readonly customerId: string | undefined;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface ViewIsCheckoutAccessibleByCustomerId
|
|
14
|
-
extends Query<typeof VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID>,
|
|
15
|
-
ViewIsCheckoutAccessibleByCustomerIdPayload {}
|
|
16
|
-
|
|
17
|
-
interface ViewIsCheckoutAccessibleByCustomerIdFunction {
|
|
18
|
-
(payload: ViewIsCheckoutAccessibleByCustomerIdPayload): ViewIsCheckoutAccessibleByCustomerId;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const viewIsCheckoutAccessibleByCustomerId: ViewIsCheckoutAccessibleByCustomerIdFunction = (payload) => ({
|
|
22
|
-
...query({ name: VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID }),
|
|
23
|
-
...payload,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
interface ViewIsCheckoutAccessibleByCustomerIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {}
|
|
27
|
-
|
|
28
|
-
const isNonEmptyCustomerId = (customerId: string | undefined): customerId is string => Boolean(customerId);
|
|
29
|
-
|
|
30
|
-
const viewIsCheckoutAccessibleByCustomerIdHandler: QueryHandlerFunction<
|
|
31
|
-
ViewIsCheckoutAccessibleByCustomerId,
|
|
32
|
-
IsCheckoutAccessibleByCustomerIdProjection,
|
|
33
|
-
ViewIsCheckoutAccessibleByCustomerIdHandlerFunctionArgs
|
|
34
|
-
> =
|
|
35
|
-
({ queryBus }) =>
|
|
36
|
-
async ({ customerId }) =>
|
|
37
|
-
isNonEmptyCustomerId(customerId) &&
|
|
38
|
-
Boolean(await queryBus(viewFirstAvailableCheckoutByCustomerId({ customerId }))) &&
|
|
39
|
-
Boolean(await queryBus(viewIsCheckoutEnabledByCustomerId({ customerId })));
|
|
40
|
-
|
|
41
|
-
export {
|
|
42
|
-
IsCheckoutAccessibleByCustomerIdProjection,
|
|
43
|
-
VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID,
|
|
44
|
-
viewIsCheckoutAccessibleByCustomerId,
|
|
45
|
-
viewIsCheckoutAccessibleByCustomerIdHandler,
|
|
46
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { QueryBus } from "@lookiero/messaging";
|
|
2
|
-
import { mock } from "jest-mock-extended";
|
|
3
|
-
import {
|
|
4
|
-
viewIsCheckoutEnabledByCustomerId,
|
|
5
|
-
viewIsCheckoutEnabledByCustomerIdHandler as sut,
|
|
6
|
-
} from "./viewIsCheckoutEnabledByCustomerId";
|
|
7
|
-
|
|
8
|
-
const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
9
|
-
const queryBus = mock<QueryBus>();
|
|
10
|
-
|
|
11
|
-
describe("viewIsCheckoutEnabledByCustomerId", () => {
|
|
12
|
-
it("returns true/false if the checkout is enabled/not by customer id", async () => {
|
|
13
|
-
const query = viewIsCheckoutEnabledByCustomerId({ customerId });
|
|
14
|
-
const view = jest.fn(() => Promise.resolve(true));
|
|
15
|
-
|
|
16
|
-
const result = await sut({ view, queryBus })(query);
|
|
17
|
-
|
|
18
|
-
expect(result).toBe(true);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { query, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
|
|
2
|
-
|
|
3
|
-
type IsCheckoutEnabledByCustomerIdProjection = boolean;
|
|
4
|
-
|
|
5
|
-
const VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID = "view_is_checkout_enabled_by_customer_id";
|
|
6
|
-
|
|
7
|
-
interface ViewIsCheckoutEnabledByCustomerIdPayload {
|
|
8
|
-
readonly customerId: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface ViewIsCheckoutEnabledByCustomerId
|
|
12
|
-
extends Query<typeof VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID>,
|
|
13
|
-
ViewIsCheckoutEnabledByCustomerIdPayload {}
|
|
14
|
-
|
|
15
|
-
interface ViewIsCheckoutEnabledByCustomerIdFunction {
|
|
16
|
-
(payload: ViewIsCheckoutEnabledByCustomerIdPayload): ViewIsCheckoutEnabledByCustomerId;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const viewIsCheckoutEnabledByCustomerId: ViewIsCheckoutEnabledByCustomerIdFunction = (payload) => ({
|
|
20
|
-
...query({ name: VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID }),
|
|
21
|
-
...payload,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
interface IsCheckoutEnabledByCustomerIdViewArgs {
|
|
25
|
-
readonly customerId: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface IsCheckoutEnabledByCustomerIdView {
|
|
29
|
-
(args: IsCheckoutEnabledByCustomerIdViewArgs): Promise<IsCheckoutEnabledByCustomerIdProjection>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface ViewIsCheckoutEnabledByCustomerIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
|
|
33
|
-
readonly view: IsCheckoutEnabledByCustomerIdView;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const viewIsCheckoutEnabledByCustomerIdHandler: QueryHandlerFunction<
|
|
37
|
-
ViewIsCheckoutEnabledByCustomerId,
|
|
38
|
-
IsCheckoutEnabledByCustomerIdProjection,
|
|
39
|
-
ViewIsCheckoutEnabledByCustomerIdHandlerFunctionArgs
|
|
40
|
-
> =
|
|
41
|
-
({ view }) =>
|
|
42
|
-
async ({ customerId }) =>
|
|
43
|
-
view({ customerId });
|
|
44
|
-
|
|
45
|
-
export {
|
|
46
|
-
IsCheckoutEnabledByCustomerIdProjection,
|
|
47
|
-
VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID,
|
|
48
|
-
viewIsCheckoutEnabledByCustomerId,
|
|
49
|
-
IsCheckoutEnabledByCustomerIdView,
|
|
50
|
-
viewIsCheckoutEnabledByCustomerIdHandler,
|
|
51
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { QueryBus } from "@lookiero/messaging";
|
|
2
|
-
import { mock } from "jest-mock-extended";
|
|
3
|
-
import { viewUiSettingByKey, viewUiSettingByKeyHandler as sut, UiSettingProjection } from "./viewUiSettingByKey";
|
|
4
|
-
|
|
5
|
-
const uiSettingKey = "ui_setting_key";
|
|
6
|
-
const uiSettingProjection: UiSettingProjection = {
|
|
7
|
-
id: "this-should-be-a-uuid",
|
|
8
|
-
key: uiSettingKey,
|
|
9
|
-
value: "ui_setting_value",
|
|
10
|
-
};
|
|
11
|
-
const queryBus = mock<QueryBus>();
|
|
12
|
-
|
|
13
|
-
describe("viewUiSettingByKey", () => {
|
|
14
|
-
it("returns ui setting by key", async () => {
|
|
15
|
-
const query = viewUiSettingByKey({ key: uiSettingKey });
|
|
16
|
-
const view = jest.fn(() => Promise.resolve(uiSettingProjection));
|
|
17
|
-
|
|
18
|
-
const uiSettingProjectionResult = await sut({ view, queryBus })(query);
|
|
19
|
-
|
|
20
|
-
expect(uiSettingProjectionResult).toBe(uiSettingProjection);
|
|
21
|
-
});
|
|
22
|
-
});
|