Add test utils
This commit is contained in:
parent
a503f08538
commit
ed5cd00062
5 changed files with 35 additions and 1 deletions
|
@ -164,6 +164,7 @@
|
|||
"@assets(.*)$": "<rootDir>/assets/$1",
|
||||
"@locale(.*)$": "<rootDir>/locale/$1",
|
||||
"@saleor(.*)$": "<rootDir>/src/$1",
|
||||
"@test(.*)$": "<rootDir>/testUtils/$1",
|
||||
"^lodash-es(.*)$": "lodash/$1"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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"
|
||||
};
|
||||
|
|
21
testUtils/filters.ts
Normal file
21
testUtils/filters.ts
Normal file
|
@ -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<T extends string>(
|
||||
opts: IFilter<T>,
|
||||
status: boolean
|
||||
): IFilter<T> {
|
||||
const newOpts = clone(opts);
|
||||
for (const optName in opts) {
|
||||
if (Object.prototype.hasOwnProperty.call(newOpts, optName)) {
|
||||
newOpts[optName].active = status;
|
||||
}
|
||||
}
|
||||
|
||||
return newOpts;
|
||||
}
|
6
testUtils/intl.ts
Normal file
6
testUtils/intl.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
import { OptionalIntlConfig } from "react-intl/dist/components/provider";
|
||||
|
||||
export const config: OptionalIntlConfig = {
|
||||
defaultLocale: "en",
|
||||
locale: "en"
|
||||
};
|
|
@ -12,7 +12,8 @@
|
|||
"paths": {
|
||||
"@assets/*": ["assets/*"],
|
||||
"@locale/*": ["locale/*"],
|
||||
"@saleor/*": ["src/*"]
|
||||
"@saleor/*": ["src/*"],
|
||||
"@test/*": ["testUtils/*"]
|
||||
},
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue