diff --git a/package.json b/package.json index 7666c5561..5fdffbe48 100644 --- a/package.json +++ b/package.json @@ -164,6 +164,7 @@ "@assets(.*)$": "/assets/$1", "@locale(.*)$": "/locale/$1", "@saleor(.*)$": "/src/$1", + "@test(.*)$": "/testUtils/$1", "^lodash-es(.*)$": "lodash/$1" } }, diff --git a/src/fixtures.ts b/src/fixtures.ts index 5b45c2f75..c466112cd 100644 --- a/src/fixtures.ts +++ b/src/fixtures.ts @@ -376,3 +376,8 @@ export const permissions: ShopInfo_shop_permissions[] = [ __typename: "PermissionDisplay" as "PermissionDisplay", ...perm })); + +export const date = { + from: "2019-12-09", + to: "2019-12-38" +}; diff --git a/testUtils/filters.ts b/testUtils/filters.ts new file mode 100644 index 000000000..0c3987080 --- /dev/null +++ b/testUtils/filters.ts @@ -0,0 +1,21 @@ +import clone from "lodash-es/clone"; + +import { IFilter } from "@saleor/components/Filter"; + +export function getExistingKeys(o: object): string[] { + return Object.keys(o).filter(key => o[key] !== undefined && o[key] !== null); +} + +export function setFilterOptsStatus( + opts: IFilter, + status: boolean +): IFilter { + const newOpts = clone(opts); + for (const optName in opts) { + if (Object.prototype.hasOwnProperty.call(newOpts, optName)) { + newOpts[optName].active = status; + } + } + + return newOpts; +} diff --git a/testUtils/intl.ts b/testUtils/intl.ts new file mode 100644 index 000000000..796d46e21 --- /dev/null +++ b/testUtils/intl.ts @@ -0,0 +1,6 @@ +import { OptionalIntlConfig } from "react-intl/dist/components/provider"; + +export const config: OptionalIntlConfig = { + defaultLocale: "en", + locale: "en" +}; diff --git a/tsconfig.json b/tsconfig.json index 56464c40a..a015886ac 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,8 @@ "paths": { "@assets/*": ["assets/*"], "@locale/*": ["locale/*"], - "@saleor/*": ["src/*"] + "@saleor/*": ["src/*"], + "@test/*": ["testUtils/*"] }, "resolveJsonModule": true },