Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

feat(helpers): using translated name props #1246 #1262

Merged
merged 8 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/helpers.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ export interface SwSorting {
name: string;
// (undocumented)
order: string;
// (undocumented)
translated: any;
}

// @beta (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface NavigationElement {
count: number;
level: number;
extensions: any[];
translated: any;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface Country {
customFields: object | null;
name: string | null;
iso: string | null;
translated: object;
translated: any;
updatedAt: string | null;
versionId: string | null;
id: string;
Expand Down
13 changes: 11 additions & 2 deletions packages/composables/__tests__/useNavigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,19 @@ describe("Composables - useNavigation", () => {
mockedGetPage.getNavigation.mockResolvedValueOnce({
count: 3,
children: [
{ name: "Clothin", route: { path: "clothing/" } },
{ name: "Sports", route: { path: "sports/" } },
{
name: "Clothin",
translated: { name: "Clothin" },
route: { path: "clothing/" },
},
{
name: "Sports",
translated: { name: "Sports" },
route: { path: "sports/" },
},
{
name: "Accessories & Others",
translated: { name: "Accessories & Others" },
route: { path: "accessories-others/" },
},
],
Expand Down
23 changes: 23 additions & 0 deletions packages/helpers/__tests__/country/mapCountries.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ describe("Shopware helpers - mapCountries", () => {
id: "id",
iso: "iso",
createdAt: "date",
translated: {
name: "Norway",
},
},
{
name: "Romania",
active: true,
id: "id",
iso: "iso",
createdAt: "date",
translated: {
name: "Romania",
},
},
];
expect(mapCountries(countries)).toEqual([
Expand All @@ -42,20 +48,37 @@ describe("Shopware helpers - mapCountries", () => {
id: "id",
iso: "iso",
createdAt: "date",
translated: {
name: null,
},
},
{
name: "Romania",
active: true,
id: "id",
iso: "iso",
createdAt: "date",
translated: {
name: "Romania",
},
},
{
name: "Norway",
active: true,
id: "id2",
iso: "iso",
createdAt: "date",
},
];
expect(mapCountries(countries)).toEqual([
{
name: "Romania",
id: "id",
},
{
name: "Norway",
id: "id2",
},
]);
});
});
4 changes: 4 additions & 0 deletions packages/helpers/__tests__/listing/filters.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,15 @@ describe("Shopware helpers - getSortingSearchCriteria", () => {
it("should return proper sorting object in descending order", () => {
const result = getSortingSearchCriteria({
field: "price",
translated: {
name: "price",
},
order: "desc",
} as any);
expect(result).toEqual({
field: "price",
desc: true,
name: "price",
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,38 @@ describe("Shopware helpers - getListingAvailableFilters", () => {
entities: [
{
name: "color",
translated: {
name: "farbe",
},
options: [
{
id: "white",
name: "white",
colorHexCode: "#fff",
},
{
id: "black",
name: "black",
colorHexCode: "#000",
translated: {
name: "schwarz",
},
},
],
},
{
name: "size",

options: [
{
id: "xs",
name: "xs",
},
{
id: "xl",
name: "xl",
translated: {
name: "white",
name: "xl",
},
},
],
Expand All @@ -80,17 +105,46 @@ describe("Shopware helpers - getListingAvailableFilters", () => {
const result = getListingAvailableFilters(aggregation);
expect(result).toStrictEqual([
{
name: "color",
name: "farbe",
options: [
{
colorHexCode: "#fff",
color: "#fff",
id: "white",
label: "white",
name: "white",
translated: { name: "white" },
value: "white",
},
{
colorHexCode: "#000",
color: "#000",
id: "black",
label: "schwarz",
name: "black",
translated: { name: "schwarz" },
value: "black",
},
],
type: "entity",
},
{
name: "size",
options: [
{
color: undefined,
id: "xs",
label: "xs",
name: "xs",
value: "xs",
},
{
color: undefined,
id: "xl",
label: "xl",
name: "xl",
translated: { name: "xl" },
value: "xl",
},
],
type: "entity",
},
Expand Down
23 changes: 23 additions & 0 deletions packages/helpers/__tests__/navigation/getNavigationRoutes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ describe("Shopware helpers - navigation", () => {
route: {
path: "/navigation/7d4c679c61d5aa387c80a6a45d75c117",
},
translated: {
name: "Cloting",
},
children: null,
},
];
Expand All @@ -29,6 +32,9 @@ describe("Shopware helpers - navigation", () => {
route: {
path: "clothing/",
},
translated: {
name: "Cloting",
},
children: null,
},
];
Expand All @@ -47,13 +53,25 @@ describe("Shopware helpers - navigation", () => {
route: {
path: "clothing/",
},
translated: {
name: "Cloting",
},
children: [
{
name: "Outdoor",
translated: {
name: "Outdoor",
},
route: {
path: "clothing/outdoor/",
},
},
{
name: "Indoor",
route: {
path: "clothing/indoor/",
},
},
],
},
];
Expand All @@ -70,6 +88,11 @@ describe("Shopware helpers - navigation", () => {
routeLabel: "Outdoor",
routePath: "/clothing/outdoor/",
},
{
children: undefined,
routeLabel: "Indoor",
routePath: "/clothing/indoor/",
},
],
},
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ describe("Shopware helpers - navigation", () => {
const SWNavigationResponse = [
{
name: "Shoes",
translated: {
name: "Shoes",
},
externalLink: null,
seoUrls: [],
children: null,
Expand All @@ -26,6 +29,9 @@ describe("Shopware helpers - navigation", () => {
const SWNavigationResponse = [
{
name: "Shoes",
translated: {
name: "Shoes",
},
externalLink: null,
children: null,
},
Expand All @@ -46,6 +52,9 @@ describe("Shopware helpers - navigation", () => {
const SWNavigationResponse = [
{
name: "Shoes",
translated: {
name: "Shoes",
},
externalLink: null,
seoUrls: [
{
Expand Down Expand Up @@ -73,6 +82,9 @@ describe("Shopware helpers - navigation", () => {
const SWNavigationResponse = [
{
name: "Shoes",
translated: {
name: "Shoes",
},
externalLink: null,
seoUrls: [
{
Expand All @@ -83,6 +95,9 @@ describe("Shopware helpers - navigation", () => {
children: [
{
name: "Sneakers",
translated: {
name: "Sneakers",
},
externalLink: null,
seoUrls: [
{
Expand Down Expand Up @@ -117,6 +132,9 @@ describe("Shopware helpers - navigation", () => {
const SWNavigationResponse = [
{
name: "Divante",
translated: {
name: "Divante",
},
externalLink: "https://divante.com",
seoUrls: null,
children: null,
Expand Down
6 changes: 6 additions & 0 deletions packages/helpers/__tests__/product/getProductOption.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ describe("Shopware helpers - getProductOption", () => {
name: "greencopper",
group: {
name: "color",
translated: {
name: "color",
},
},
id: "04095b39ef07472ebd7547800c40bfd4",
},
{
name: "31",
group: {
name: "size",
translated: {
name: "size",
},
},
id: "06a7ed91305d47e1b7f3d6f7660c8316",
},
Expand Down
24 changes: 23 additions & 1 deletion packages/helpers/__tests__/product/getProductOptions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,31 @@ describe("Shopware helpers - getProductOptions", () => {
{
id: "3858d1baf2544a379c92535ea3d2fe53",
name: "blue",
translated: {
name: "blue",
},
group: {
name: "color",
},
},
{
id: "3858d1baf2544a379c92535ea3d2fe53",
id: "3858d1baf2544a379c92535ea3d2fe54",
name: "blue",
group: {
name: "color",
translated: {
name: "color",
},
},
},
{
id: "3858d1baf2544a379c92535ea3d2fe54",
name: "blue",
group: {
name: "color",
translated: {
name: "color",
},
},
},
{
Expand All @@ -42,6 +58,12 @@ describe("Shopware helpers - getProductOptions", () => {
product: productWithChildren,
});
expect(productOptions).toHaveProperty("color");
expect(productOptions.color[0]).toStrictEqual({
code: "3858d1baf2544a379c92535ea3d2fe53",
color: undefined,
label: "blue",
value: "blue",
});
});

it("should returns return an empty object if no children", () => {
Expand Down
Loading