diff --git a/jest.config.ts b/jest.config.ts index 810f028..da2fb18 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -14,7 +14,7 @@ export default { '/guillotine/(.*)': '/src/main/resources/guillotine/$1', '/lib/common/(.*)': '/src/main/resources/lib/common/$1', '/lib/metadata/(.*)': '/src/main/resources/lib/metadata/$1', - '/lib/brand(.*)': '/src/main/resources/lib/brand$1', + '/lib/types(.*)': '/src/main/resources/lib/types$1', }, preset: 'ts-jest/presets/js-with-babel-legacy', testEnvironment: 'node', diff --git a/src/main/resources/guillotine/guillotine.ts b/src/main/resources/guillotine/guillotine.ts index 1b7e634..32b70b4 100644 --- a/src/main/resources/guillotine/guillotine.ts +++ b/src/main/resources/guillotine/guillotine.ts @@ -1,10 +1,10 @@ import type { Extensions, GraphQL, -} from '/guillotine/guillotine.d'; +} from '../lib/types/Guillotine'; -import {GraphQLFieldName, GraphQLTypeName} from '/guillotine/guillotine.d'; +import {GraphQLFieldName, GraphQLTypeName} from '../lib/types/Guillotine'; import {contentMetaFieldsResolver} from '/guillotine/typeFieldResolvers/contentMetaFieldsResolver'; import {metaFieldsImagesResolver} from '/guillotine/typeFieldResolvers/metaFieldsImagesResolver'; diff --git a/src/main/resources/guillotine/typeFieldResolvers/contentMetaFieldsResolver.ts b/src/main/resources/guillotine/typeFieldResolvers/contentMetaFieldsResolver.ts index cd12a8d..c734d48 100644 --- a/src/main/resources/guillotine/typeFieldResolvers/contentMetaFieldsResolver.ts +++ b/src/main/resources/guillotine/typeFieldResolvers/contentMetaFieldsResolver.ts @@ -1,5 +1,5 @@ import type {Content} from '/lib/xp/content'; -import type {Resolver} from '/guillotine/guillotine.d'; +import type {Resolver} from '../../lib/types/Guillotine'; import { diff --git a/src/main/resources/guillotine/typeFieldResolvers/metaFieldsImagesResolver.ts b/src/main/resources/guillotine/typeFieldResolvers/metaFieldsImagesResolver.ts index 642fe56..d65a569 100644 --- a/src/main/resources/guillotine/typeFieldResolvers/metaFieldsImagesResolver.ts +++ b/src/main/resources/guillotine/typeFieldResolvers/metaFieldsImagesResolver.ts @@ -1,10 +1,10 @@ -import type {Content} from '/lib/xp/content'; +import type {Content, Site} from '/lib/xp/content'; import type { // Content, Resolver -} from '/guillotine/guillotine.d'; -import type {MetafieldsSiteConfig} from '/lib/common/MetafieldsSiteConfig.d'; +} from '../../lib/types/Guillotine'; +import type {MetafieldsSiteConfig} from '../../lib/types/MetafieldsSiteConfig'; import {get as getContentByKey} from '/lib/xp/content'; @@ -14,13 +14,14 @@ import { } from '/lib/xp/context'; import {commaStringToArray} from '/lib/common/commaStringToArray'; import {findStringValueInObject} from '/lib/common/findStringValueInObject'; +import {getImageId} from '/lib/common/getImageId'; export const metaFieldsImagesResolver: Resolver< {}, // args { // source _content: Content - _site: Record + _site: Site _siteConfig: MetafieldsSiteConfig // images: string[] } @@ -63,43 +64,20 @@ export const metaFieldsImagesResolver: Resolver< }, () => { const images = []; - if (_siteConfig.seoImage) { - const imageContent = getContentByKey({ key: _siteConfig.seoImage }); + const imageId = getImageId({ + content: _content, + site: _site, + siteConfig: _siteConfig + }); + if (imageId) { + const imageContent = getContentByKey({ key: imageId }); if (imageContent) { images.push(imageContent); } else { - log.error(`_siteConfig.seoImage for site with _path:${_site._path} references a non-existing image with key:${_siteConfig.seoImage}`); - } - } else { - // Try to find image contentKey in content - const userDefinedPaths = _siteConfig.pathsImages || ''; - const userDefinedArray = userDefinedPaths ? commaStringToArray(userDefinedPaths) : []; - const userDefinedValue = userDefinedPaths ? findStringValueInObject(_content, userDefinedArray, _siteConfig.fullPath) : null; - if (userDefinedValue) { - const imageContent = getContentByKey({ key: userDefinedValue }); - if (imageContent) { - images.push(imageContent); - } else { - log.error(`content with _path:${_content._path} references a non-existing image with key:${userDefinedValue}}`); - } - } else { - if (_content.data.image) { - const imageContent = getContentByKey({ key: _content.data.image as string }); - if (imageContent) { - images.push(imageContent); - } else { - log.error(`content with _path:${_content._path} references a non-existing image with key:${_content.data.image}}`); - } - } else if (_content.data.images) { - const imageContent = getContentByKey({ key: _content.data.images as string }); - if (imageContent) { - images.push(imageContent); - } else { - log.error(`content with _path:${_content._path} references a non-existing image with key:${_content.data.images}}`); - } - } + log.error(`content with _path:${_content._path} or site with path: ${_site._path} references a non-existing image with key:${imageId}`); } } + if (_siteConfig.frontpageImage) { const imageContent = getContentByKey({ key: _siteConfig.frontpageImage }); if (imageContent) { @@ -108,6 +86,7 @@ export const metaFieldsImagesResolver: Resolver< log.error(`siteConfig.frontpageImage for site with _path:${_site._path} references a non-existing image with key:${_siteConfig.frontpageImage}`); } } + return images; }); } diff --git a/src/main/resources/lib/common/commaStringToArray.ts b/src/main/resources/lib/common/commaStringToArray.ts index 144a8b5..15e9495 100644 --- a/src/main/resources/lib/common/commaStringToArray.ts +++ b/src/main/resources/lib/common/commaStringToArray.ts @@ -1,9 +1,9 @@ import {forceArray} from '@enonic/js-utils/array/forceArray'; -export function commaStringToArray(str) { - var commas = str || ''; - var arr = commas.split(','); +export function commaStringToArray(str: string): string[] { + const commas = str || ''; + let arr = commas.split(','); if (arr) { arr = arr.map(function (s) { return s.trim() }); } else { diff --git a/src/main/resources/lib/common/findImageIdInContent.ts b/src/main/resources/lib/common/findImageIdInContent.ts new file mode 100644 index 0000000..8b146f3 --- /dev/null +++ b/src/main/resources/lib/common/findImageIdInContent.ts @@ -0,0 +1,26 @@ +import type {Content} from '/lib/xp/content'; +import type {ImageId} from '/lib/types'; +import type {MetafieldsSiteConfig} from '../types/MetafieldsSiteConfig'; + + +import {commaStringToArray} from '/lib/common/commaStringToArray'; +import {findStringValueInObject} from '/lib/common/findStringValueInObject'; +import {ImageIdBuilder} from '/lib/types'; + + +export function findImageIdInContent({ + content, + siteConfig +}: { + content: Content + siteConfig: MetafieldsSiteConfig +}): ImageId|undefined { + const userDefinedPaths = siteConfig.pathsImages || ''; + const userDefinedArray = userDefinedPaths ? commaStringToArray(userDefinedPaths) : []; + const userDefinedValue = userDefinedPaths ? findStringValueInObject(content, userDefinedArray, siteConfig.fullPath) : null; + return ImageIdBuilder.from( + userDefinedValue + || content.data.image as string + || content.data.images as string + ) || undefined; +} diff --git a/src/main/resources/lib/common/getAppendix.ts b/src/main/resources/lib/common/getAppendix.ts index 3e58982..f97d324 100644 --- a/src/main/resources/lib/common/getAppendix.ts +++ b/src/main/resources/lib/common/getAppendix.ts @@ -1,5 +1,5 @@ import type {Site} from '@enonic-types/lib-portal'; -import type {MetafieldsSiteConfig} from '/lib/common/MetafieldsSiteConfig.d'; +import type {MetafieldsSiteConfig} from '../types/MetafieldsSiteConfig'; import {getTheConfig} from '/lib/common/getTheConfig'; diff --git a/src/main/resources/lib/common/getFullTitle.ts b/src/main/resources/lib/common/getFullTitle.ts index 1e3f131..efe56a0 100644 --- a/src/main/resources/lib/common/getFullTitle.ts +++ b/src/main/resources/lib/common/getFullTitle.ts @@ -1,6 +1,6 @@ import type {Content} from '/lib/xp/content'; import type {Site} from '/lib/xp/portal'; -import type {MetafieldsSiteConfig} from '/lib/common/MetafieldsSiteConfig.d'; +import type {MetafieldsSiteConfig} from '../types/MetafieldsSiteConfig'; import {getAppendix} from '/lib/common/getAppendix'; diff --git a/src/main/resources/lib/common/getImageId.ts b/src/main/resources/lib/common/getImageId.ts new file mode 100644 index 0000000..412edc8 --- /dev/null +++ b/src/main/resources/lib/common/getImageId.ts @@ -0,0 +1,38 @@ +import type {Content, Site} from '/lib/xp/content'; +import type {ImageId} from '/lib/types'; +import type {MetafieldsSiteConfig} from '../types/MetafieldsSiteConfig'; + + +import {APP_NAME_PATH, MIXIN_PATH} from '/lib/common/constants'; +import {findImageIdInContent} from '/lib/common/findImageIdInContent'; +import {ImageIdBuilder} from '/lib/types'; + + +export function getImageId({ + content, + site, + siteConfig +} :{ + content: Content + site: Site + siteConfig: MetafieldsSiteConfig +}): ImageId|undefined { + // 1. Override image set on content + if(content.x?.[APP_NAME_PATH]?.[MIXIN_PATH]?.seoImage) { + return ImageIdBuilder.from(content.x[APP_NAME_PATH][MIXIN_PATH].seoImage as string); + } + + // 2. Try to find an image within the content isself + const imageId = findImageIdInContent({content, siteConfig}); + if (imageId) { + return imageId; + } + + // 3. Fallback to siteConfig image + if (siteConfig.seoImage) { + return ImageIdBuilder.from(siteConfig.seoImage); + } + + // 4. Fallback to image on siteContent + return findImageIdInContent({content: site, siteConfig}) +} diff --git a/src/main/resources/lib/common/getImageUrl.ts b/src/main/resources/lib/common/getImageUrl.ts index 9586997..8418ca1 100644 --- a/src/main/resources/lib/common/getImageUrl.ts +++ b/src/main/resources/lib/common/getImageUrl.ts @@ -1,7 +1,7 @@ import type {Content, Site} from '/lib/xp/content'; import type {ImageUrlParams} from '/lib/xp/portal'; // import type {MediaImage} from '/guillotine/guillotine.d'; -import type {MetafieldsSiteConfig} from '/lib/common/MetafieldsSiteConfig'; +import type {MetafieldsSiteConfig} from '../types/MetafieldsSiteConfig'; import {forceArray} from '@enonic/js-utils/array/forceArray'; diff --git a/src/main/resources/lib/common/getMetaDescription.ts b/src/main/resources/lib/common/getMetaDescription.ts index 05aedba..9f7ee8e 100644 --- a/src/main/resources/lib/common/getMetaDescription.ts +++ b/src/main/resources/lib/common/getMetaDescription.ts @@ -1,6 +1,6 @@ import type {Content} from '/lib/xp/content'; import type {Site} from '/lib/xp/portal'; -import type {MetafieldsSiteConfig} from '/lib/common/MetafieldsSiteConfig.d'; +import type {MetafieldsSiteConfig} from '../types/MetafieldsSiteConfig'; // import type {Content} from '/guillotine/guillotine.d'; diff --git a/src/main/resources/lib/common/getPageTitle.ts b/src/main/resources/lib/common/getPageTitle.ts index 57c4a6a..7e6d853 100644 --- a/src/main/resources/lib/common/getPageTitle.ts +++ b/src/main/resources/lib/common/getPageTitle.ts @@ -1,6 +1,6 @@ import type {Content} from '/lib/xp/content'; import type {Site} from '@enonic-types/lib-portal'; -import type {MetafieldsSiteConfig} from '/lib/common/MetafieldsSiteConfig.d'; +import type {MetafieldsSiteConfig} from '../types/MetafieldsSiteConfig'; import {commaStringToArray} from '/lib/common/commaStringToArray'; diff --git a/src/main/resources/lib/common/getSite.ts b/src/main/resources/lib/common/getSite.ts index cf6cb27..8f29785 100644 --- a/src/main/resources/lib/common/getSite.ts +++ b/src/main/resources/lib/common/getSite.ts @@ -1,5 +1,5 @@ import type {Site} from '/lib/xp/portal'; -import type { MetafieldsSiteConfig } from '/lib/common/MetafieldsSiteConfig.d'; +import type { MetafieldsSiteConfig } from '../types/MetafieldsSiteConfig'; import {query} from '/lib/xp/content'; diff --git a/src/main/resources/lib/common/getSiteConfigFromSite.ts b/src/main/resources/lib/common/getSiteConfigFromSite.ts index f7e79e0..72621a5 100644 --- a/src/main/resources/lib/common/getSiteConfigFromSite.ts +++ b/src/main/resources/lib/common/getSiteConfigFromSite.ts @@ -1,5 +1,5 @@ import type {Site} from '/lib/xp/portal'; -import type {MetafieldsSiteConfig} from '/lib/common/MetafieldsSiteConfig.d'; +import type {MetafieldsSiteConfig} from '../types/MetafieldsSiteConfig'; import {forceArray} from '@enonic/js-utils/array/forceArray'; diff --git a/src/main/resources/lib/common/getTheConfig.ts b/src/main/resources/lib/common/getTheConfig.ts index 018c842..6e9c93b 100644 --- a/src/main/resources/lib/common/getTheConfig.ts +++ b/src/main/resources/lib/common/getTheConfig.ts @@ -1,5 +1,5 @@ import type {Site} from '/lib/xp/portal'; -import type { MetafieldsSiteConfig } from '/lib/common/MetafieldsSiteConfig.d'; +import type { MetafieldsSiteConfig } from '../types/MetafieldsSiteConfig'; import {getSiteConfig as libPortalGetSiteConfig} from '/lib/xp/portal'; diff --git a/src/main/resources/lib/metadata/getMetaData.ts b/src/main/resources/lib/metadata/getMetaData.ts index 06b6876..e7492cd 100644 --- a/src/main/resources/lib/metadata/getMetaData.ts +++ b/src/main/resources/lib/metadata/getMetaData.ts @@ -1,6 +1,6 @@ import type {Content} from '/lib/xp/content'; import type {Site} from '/lib/xp/portal'; -import type {MetafieldsSiteConfig} from '/lib/common/MetafieldsSiteConfig.d'; +import type {MetafieldsSiteConfig} from '../types/MetafieldsSiteConfig'; import {pageUrl} from '/lib/xp/portal'; diff --git a/src/main/resources/lib/metadata/getTitleHtml.ts b/src/main/resources/lib/metadata/getTitleHtml.ts index 34dd3df..f9791fb 100644 --- a/src/main/resources/lib/metadata/getTitleHtml.ts +++ b/src/main/resources/lib/metadata/getTitleHtml.ts @@ -1,6 +1,6 @@ import type {Content} from '/lib/xp/content'; import type {Site} from '/lib/xp/portal'; -import type {MetafieldsSiteConfig} from '/lib/common/MetafieldsSiteConfig.d'; +import type {MetafieldsSiteConfig} from '../types/MetafieldsSiteConfig'; import {getFullTitle} from '/lib/common/getFullTitle'; diff --git a/src/main/resources/lib/brand.d.ts b/src/main/resources/lib/types/Branded.d.ts similarity index 100% rename from src/main/resources/lib/brand.d.ts rename to src/main/resources/lib/types/Branded.d.ts diff --git a/src/main/resources/guillotine/guillotine.d.ts b/src/main/resources/lib/types/Guillotine.d.ts similarity index 92% rename from src/main/resources/guillotine/guillotine.d.ts rename to src/main/resources/lib/types/Guillotine.d.ts index 2905384..7ee5ea3 100644 --- a/src/main/resources/guillotine/guillotine.d.ts +++ b/src/main/resources/lib/types/Guillotine.d.ts @@ -2,23 +2,6 @@ import type {Content} from '@enonic-types/lib-content'; import type {Branded} from '/lib/brand.d'; -export declare type BaseFolder = Content<{}, 'base:folder'>; - -export declare type MediaImage = Content<{ - media: { - altText?: string - artist?: string - attachment: string - caption?: string - copyright?: string - focalPoint: { - x: number - y: number - } - tags?: string // with comma? - } -}, 'media:image'>; - export const enum GraphQLTypeName { CONTENT = 'Content', // IMAGE = 'Image', diff --git a/src/main/resources/lib/common/MetafieldsSiteConfig.d.ts b/src/main/resources/lib/types/MetafieldsSiteConfig.d.ts similarity index 100% rename from src/main/resources/lib/common/MetafieldsSiteConfig.d.ts rename to src/main/resources/lib/types/MetafieldsSiteConfig.d.ts diff --git a/src/main/resources/lib/brand.ts b/src/main/resources/lib/types/brand.ts similarity index 80% rename from src/main/resources/lib/brand.ts rename to src/main/resources/lib/types/brand.ts index 255de41..a048bc4 100644 --- a/src/main/resources/lib/brand.ts +++ b/src/main/resources/lib/types/brand.ts @@ -1,9 +1,11 @@ -import type {BrandBase, BrandBuilder, BrandBuilderOptions, Branded} from '/lib/brand.d'; +import type {BrandBase, BrandBuilder, BrandBuilderOptions, Branded} from '/lib/types/Branded'; -export function brand, Base = BrandBase>({ - validate = () => true, -}: BrandBuilderOptions = {}): BrandBuilder { +export function brand, Base = BrandBase>( + { + validate = () => true, + }: BrandBuilderOptions = {} +): BrandBuilder { function assertIsBrand(value: Base): asserts value is T { const result = validate(value) if (typeof result === 'string') { diff --git a/src/main/resources/lib/types/index.ts b/src/main/resources/lib/types/index.ts new file mode 100644 index 0000000..79d846e --- /dev/null +++ b/src/main/resources/lib/types/index.ts @@ -0,0 +1,71 @@ +//────────────────────────────────────────────────────────────────────────────── +// Type imports +//────────────────────────────────────────────────────────────────────────────── +import type {Content} from '@enonic-types/lib-content'; +import type {Branded} from '/lib/types/Branded'; +import type { + GraphQLBoolean, + GraphQLContent, + GraphQLID, + GraphQLInt, + GraphQLFloat, + GraphQLJson, + GraphQLDateTime, + GraphQLDate, + GraphQLLocalTime, + GraphQLLocalDateTime, + GraphQLMediaImage, + GraphQLMetaFields, + GraphQLString, +} from '/lib/types/Guillotine'; + + +//────────────────────────────────────────────────────────────────────────────── +// Value imports +//────────────────────────────────────────────────────────────────────────────── +import {brand} from '/lib/types/brand'; + + +//────────────────────────────────────────────────────────────────────────────── +// ExportedtTypes +//────────────────────────────────────────────────────────────────────────────── +export type {MetafieldsSiteConfig} from '/lib/types/MetafieldsSiteConfig'; + +export declare type BaseFolder = Content<{}, 'base:folder'>; + +export declare type ImageId = Branded; + +export declare type MediaImage = Content<{ + media: { + altText?: string + artist?: string + attachment: string + caption?: string + copyright?: string + focalPoint: { + x: number + y: number + } + tags?: string // with comma? + } +}, 'media:image'>; + +//────────────────────────────────────────────────────────────────────────────── +// Exported values +//────────────────────────────────────────────────────────────────────────────── +export const ImageIdBuilder = brand(); + +export const GraphQLBooleanBuilder = brand(); +export const GraphQLDateBuilder = brand(); +export const GraphQLDateTimeBuilder = brand(); +export const GraphQLFloatBuilder = brand(); +export const GraphQLIDBuilder = brand(); +export const GraphQLIntBuilder = brand(); +export const GraphQLJsonBuilder = brand(); +export const GraphQLLocalDateTimeBuilder = brand(); +export const GraphQLLocalTimeBuilder = brand(); +export const GraphQLStringBuilder = brand(); + +export const GraphQLContentBuilder = brand(); +export const GraphQLMediaImageBuilder = brand(); +export const GraphQLMetaFieldsBuilder = brand(); diff --git a/test/guillotine/guillotine.test.ts b/test/guillotine/guillotine.test.ts index 670dc16..5e9238e 100644 --- a/test/guillotine/guillotine.test.ts +++ b/test/guillotine/guillotine.test.ts @@ -1,6 +1,5 @@ -import type {MetafieldsSiteConfig} from '/lib/common/MetafieldsSiteConfig'; +import type {MetafieldsSiteConfig} from '/lib/types/MetafieldsSiteConfig'; import type { - Content, getSite as ContentGetSite, Site } from '/lib/xp/content'; @@ -12,25 +11,13 @@ import type { getSiteConfig } from '/lib/xp/portal'; import type { - BaseFolder, GraphQL, - GraphQLBoolean, - GraphQLContent, - GraphQLID, - GraphQLInt, - GraphQLFloat, - GraphQLJson, - GraphQLDateTime, - GraphQLDate, - GraphQLLocalTime, - GraphQLLocalDateTime, - GraphQLMediaImage, - GraphQLMetaFields, - GraphQLString, - MediaImage, MetaFields -} from '/guillotine/guillotine.d'; -// import type {Brand} from '/lib/brand.d'; +} from '/lib/types/Guillotine'; +import type { + BaseFolder, + MediaImage, +} from '/lib/types' import { @@ -40,7 +27,21 @@ import { jest, test as it, } from '@jest/globals'; -import {brand} from '/lib/brand'; +import { + GraphQLBooleanBuilder, + GraphQLContentBuilder, + GraphQLDateBuilder, + GraphQLDateTimeBuilder, + GraphQLFloatBuilder, + GraphQLIDBuilder, + GraphQLIntBuilder, + GraphQLJsonBuilder, + GraphQLLocalDateTimeBuilder, + GraphQLLocalTimeBuilder, + GraphQLMediaImageBuilder, + GraphQLMetaFieldsBuilder, + GraphQLStringBuilder, +} from '/lib/types'; import {mockLibUtil} from '../mocks/mockLibUtil'; // @ts-ignore TS2339: Property 'log' does not exist on type 'typeof globalThis'. @@ -219,28 +220,28 @@ const folderMetaFields: MetaFields = { }, }; -const graphQLContent = brand().from(siteContent); +const graphQLContent = GraphQLContentBuilder.from(siteContent); const graphQL: GraphQL = { - GraphQLBoolean: brand().from(true), - GraphQLInt: brand().from(1), - GraphQLString: brand().from('string'), - GraphQLID: brand().from('id'), - GraphQLFloat: brand().from(1.1), - Json: brand().from('{"json": "value"}'), - DateTime: brand().from('2021-01-01T00:00:00Z'), - Date: brand().from('2021-01-01'), - LocalTime: brand().from('00:00:00'), - LocalDateTime: brand().from('2021-01-01T00:00:00'), + GraphQLBoolean: GraphQLBooleanBuilder.from(true), + GraphQLInt: GraphQLIntBuilder.from(1), + GraphQLString: GraphQLStringBuilder.from('string'), + GraphQLID: GraphQLIDBuilder.from('id'), + GraphQLFloat: GraphQLFloatBuilder.from(1.1), + Json: GraphQLJsonBuilder.from('{"json": "value"}'), + DateTime: GraphQLDateTimeBuilder.from('2021-01-01T00:00:00Z'), + Date: GraphQLDateBuilder.from('2021-01-01'), + LocalTime: GraphQLLocalTimeBuilder.from('00:00:00'), + LocalDateTime: GraphQLLocalDateTimeBuilder.from('2021-01-01T00:00:00'), nonNull: (type) => type, list: (type) => type, reference: (typeName) => { // console.debug('reference typeName', typeName); if (typeName === 'media_Image') { - return brand().from(imageContent); + return GraphQLMediaImageBuilder.from(imageContent); } if (typeName === 'MetaFields') { - return brand().from(folderMetaFields); + return GraphQLMetaFieldsBuilder.from(folderMetaFields); } return graphQLContent; }, diff --git a/test/lib/common/getImageUrl.test.ts b/test/lib/common/getImageUrl.test.ts index 9ae8627..0e55b4d 100644 --- a/test/lib/common/getImageUrl.test.ts +++ b/test/lib/common/getImageUrl.test.ts @@ -2,8 +2,10 @@ import type { get as GetContentByKey, Site } from '/lib/xp/content'; -import type {MetafieldsSiteConfig} from '/lib/common/MetafieldsSiteConfig'; -import type {MediaImage} from '/guillotine/guillotine.d'; +import type { + MetafieldsSiteConfig, + MediaImage +} from '/lib/types'; import { @@ -98,7 +100,7 @@ const imageContent4 = mockImage({ prefix: 'four' }); -describe('getImage', () => { +describe('getImageUrl', () => { beforeAll(() => { jest.mock( '/lib/xp/content', diff --git a/test/lib/metadata/getMetaData.test.ts b/test/lib/metadata/getMetaData.test.ts index 9b251a8..9b9ef8f 100644 --- a/test/lib/metadata/getMetaData.test.ts +++ b/test/lib/metadata/getMetaData.test.ts @@ -3,7 +3,7 @@ import type { get as GetContentByKey, // Site } from '/lib/xp/content'; -import type {MetafieldsSiteConfig} from '/lib/common/MetafieldsSiteConfig'; +import type {MetafieldsSiteConfig} from '/lib/types'; import { diff --git a/test/mocks/mockImage.ts b/test/mocks/mockImage.ts index 08dff94..d9da73c 100644 --- a/test/mocks/mockImage.ts +++ b/test/mocks/mockImage.ts @@ -1,4 +1,4 @@ -import type {MediaImage} from '/guillotine/guillotine.d'; +import type {MediaImage} from '/lib/types'; import {mockContent} from './mockContent'; diff --git a/test/mocks/mockLibXpPortal.ts b/test/mocks/mockLibXpPortal.ts index e532eca..4bec4d6 100644 --- a/test/mocks/mockLibXpPortal.ts +++ b/test/mocks/mockLibXpPortal.ts @@ -4,7 +4,7 @@ import type { imageUrl, pageUrl, } from '/lib/xp/portal'; -import type {MetafieldsSiteConfig} from '/lib/common/MetafieldsSiteConfig'; +import type {MetafieldsSiteConfig} from '/lib/types'; import {jest} from '@jest/globals'; diff --git a/test/mocks/mockSite.ts b/test/mocks/mockSite.ts index 2dd92d2..427c6bf 100644 --- a/test/mocks/mockSite.ts +++ b/test/mocks/mockSite.ts @@ -1,5 +1,5 @@ import type {Site} from '/lib/xp/content'; -import type {MetafieldsSiteConfig} from '/lib/common/MetafieldsSiteConfig'; +import type {MetafieldsSiteConfig} from '/lib/types'; import {mockContent} from './mockContent';