UNPKG

@scayle/storefront-nuxt

Version:

Nuxt integration for the SCAYLE Commerce Engine and Storefront API

128 lines (122 loc) 3.35 kB
import { Factory } from 'fishery'; import { HashAlgorithm, Log, StorefrontAPIClient } from '@scayle/storefront-core'; export * from '@scayle/storefront-core/test/factories'; const moduleRuntimeOptionsFactory = Factory.define(({ transientParams }) => { return { sapi: { host: "sapiHost", token: "sapiToken" }, oauth: { apiHost: "oauthHost", clientId: "clientId", clientSecret: "clientSecret" }, appKeys: { basketKey: "basketKey", wishlistKey: "wishlistKey", hashAlgorithm: HashAlgorithm.MD5 }, shopSelector: "path", shops: (transientParams?.shops || []).reduce((acc, curr) => { return { [curr.shopId]: curr, ...acc }; }, {}) }; }); const moduleOptionsFactory = Factory.define(() => { return { rpcDir: void 0, rpcMethodNames: void 0, rpcMethodOverrides: void 0, apiBasePath: "/api" }; }); const shopConfigFactory = Factory.define(() => { return { shopId: 1, domain: "localhost", locale: "en-US", currency: "USD", checkout: { host: "checkoutHost", secret: "checkoutSecret", token: "checkoutToken", user: "checkoutUser" }, auth: { // eslint-disable-next-line sonarjs/no-hardcoded-passwords resetPasswordUrl: "resetPasswordUrl" }, paymentProviders: [] }; }); const rpcContextFactory = Factory.define(({ transientParams }) => { return { locale: "de", checkout: { url: "", token: "", secret: "", user: "" }, sapiClient: new StorefrontAPIClient({ host: "", shopId: 1001 }), cached: (fn, _options) => { return async (...args) => { return await fn(...args); }; }, shopId: 1001, domain: "localhost", destroySessionsForUserId: () => Promise.resolve(), generateBasketKeyForUserId: (userId) => Promise.resolve(`basket-${userId}`), generateWishlistKeyForUserId: (userId) => Promise.resolve(`wishlist-${userId}`), log: new Log(), auth: {}, runtimeConfiguration: {}, headers: new Headers(), ...transientParams.isLoggedIn ? { wishlistKey: "wishlistKey", basketKey: "basketKey", sessionId: "sessionId", user: void 0, accessToken: void 0, refreshToken: void 0, sessionCustomData: void 0, destroySession: () => Promise.resolve(), createUserBoundSession: () => Promise.resolve(), updateUser: () => Promise.resolve(), updateSessionCustomData: () => Promise.resolve(), updateTokens: () => Promise.resolve() } : { wishlistKey: "logged-out-wishlist-key", basketKey: "logged-out-basket-key", sessionId: "logged-out-session-id", user: void 0, accessToken: void 0, refreshToken: void 0, sessionCustomData: void 0, destroySession: void 0, createUserBoundSession: void 0, updateUser: void 0, updateSessionCustomData: void 0, updateTokens: void 0 } }; }); const routeFactory = Factory.define( () => ({ name: "test", params: {}, matched: [], path: "/test", fullPath: "/test", redirectedFrom: void 0, hash: "", meta: { test: "" }, query: {} }) ); export { moduleOptionsFactory, moduleRuntimeOptionsFactory, routeFactory, rpcContextFactory, shopConfigFactory };