@open-pioneer/test-utils 4.6.0-dev.20260420101935 → 4.6.0-dev.20260518093554

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @open-pioneer/test-utils
2
2
 
3
- ## 4.6.0-dev.20260420101935
3
+ ## 4.6.0-dev.20260518093554
4
4
 
5
5
  ## 4.5.0
6
6
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/test-utils",
4
- "version": "4.6.0-dev.20260420101935",
4
+ "version": "4.6.0-dev.20260518093554",
5
5
  "description": "Contains test utilities that make it easier to test parts of an Open Pioneer Trails application.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -14,13 +14,13 @@
14
14
  "directory": "src/packages/test-utils"
15
15
  },
16
16
  "dependencies": {
17
- "@conterra/reactivity-core": "^0.8.2",
17
+ "@conterra/reactivity-core": "^0.8.5",
18
18
  "@testing-library/react": "^16.3.2",
19
- "react": "^19.2.5",
20
- "react-dom": "^19.2.5",
19
+ "react": "^19.2.6",
20
+ "react-dom": "^19.2.6",
21
21
  "@testing-library/dom": "^10.4.1",
22
- "@formatjs/intl": "^4.1.6",
23
- "@open-pioneer/runtime": "4.6.0-dev.20260420101935"
22
+ "@formatjs/intl": "^4.1.11",
23
+ "@open-pioneer/runtime": "4.6.0-dev.20260518093554"
24
24
  },
25
25
  "exports": {
26
26
  "./package.json": "./package.json",
@@ -50,6 +50,6 @@
50
50
  "references": []
51
51
  },
52
52
  "properties": [],
53
- "packageFormatVersion": "1.0.0"
53
+ "packageFormatVersion": "1.0.1"
54
54
  }
55
55
  }
package/services.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { reactive } from '@conterra/reactivity-core';
1
2
  import { createIntl } from './vanilla.js';
2
3
 
3
4
  function createService(clazz, options) {
@@ -15,7 +16,8 @@ function createService(clazz, options) {
15
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
17
  referencesMeta,
17
18
  properties: options?.properties ?? {},
18
- intl
19
+ intl,
20
+ currentIntl: reactive(intl)
19
21
  });
20
22
  }
21
23
  function referenceMeta(referenceName, reference) {
package/services.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"services.js","sources":["services.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ReferenceMeta, Service, ServiceConstructor } from \"@open-pioneer/runtime\";\nimport { createIntl } from \"./vanilla\";\n\n/**\n * Options for the {@link createService} function.\n */\nexport interface CreateServiceOptions<References> {\n /**\n * References provided to the service constructor.\n *\n * @default {}\n */\n references?: PartialServiceReferences<References>;\n\n /**\n * Properties provided to the service constructor.\n *\n * @default {}\n */\n properties?: Record<string, unknown>;\n\n /**\n * The locale for i18n messages and formatting.\n *\n * @default \"en\"\n */\n locale?: string;\n\n /**\n * The locale for embedded default messages.\n *\n * See also https://formatjs.io/docs/intl#message-descriptor\n *\n * @default \"en\"\n */\n defaultMessageLocale?: string;\n\n /**\n * I18n messages as (messageId, message) entries.\n *\n * @default {}\n */\n messages?: Record<string, string>;\n}\n\ntype PartialServiceReferences<References> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [referenceName in keyof References]?: References[referenceName] extends any[]\n ? Partial<References[referenceName][number]>[]\n : Partial<References[referenceName]>;\n};\n\n/**\n * Creates a new service instance of `clazz`.\n *\n * The options passed into the constructor of `clazz` are taking from the `options` parameter.\n *\n * This function allows the user to define mock- or test objects as service references.\n *\n * Most type-checking features are disabled for convenience, but by default this function's types\n * enforce that a value provided for a reference must match the partial interface of the actually required type.\n *\n * For example, if a service depends on `{ ctx: ApplicationContext }`, this function ensures\n * that the test value for `ctx` implements `Partial<ApplicationContext>`.\n * This can of course be disabled by casting the value explicitly.\n *\n * @param clazz a service class\n * @param options options passed to the service constructor\n * @returns a new instance of the given service class\n */\nexport function createService<References extends {}, Interface extends {}>(\n clazz: ServiceConstructor<References, Interface>,\n options?: CreateServiceOptions<References>\n): Service<Interface> {\n const references = options?.references ?? {};\n const referencesMeta = Object.fromEntries(\n Object.entries(references).map(([referenceName, reference]) => [\n referenceName,\n referenceMeta(referenceName, reference)\n ])\n );\n\n const intl = createIntl(options);\n return new clazz({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n references: references as any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n referencesMeta: referencesMeta as any,\n properties: options?.properties ?? {},\n intl\n });\n}\n\nfunction referenceMeta(referenceName: string, reference: unknown): ReferenceMeta | ReferenceMeta[] {\n if (Array.isArray(reference)) {\n return reference.map<ReferenceMeta>((_, index) => ({\n serviceId: `test-utils::${referenceName}-${index}`\n }));\n }\n return {\n serviceId: `test-utils::${referenceName}`\n };\n}\n"],"names":[],"mappings":";;AAwEO,SAAS,aAAA,CACZ,OACA,OAAA,EACkB;AAClB,EAAA,MAAM,UAAA,GAAa,OAAA,EAAS,UAAA,IAAc,EAAC;AAC3C,EAAA,MAAM,iBAAiB,MAAA,CAAO,WAAA;AAAA,IAC1B,MAAA,CAAO,QAAQ,UAAU,CAAA,CAAE,IAAI,CAAC,CAAC,aAAA,EAAe,SAAS,CAAA,KAAM;AAAA,MAC3D,aAAA;AAAA,MACA,aAAA,CAAc,eAAe,SAAS;AAAA,KACzC;AAAA,GACL;AAEA,EAAA,MAAM,IAAA,GAAO,WAAW,OAAO,CAAA;AAC/B,EAAA,OAAO,IAAI,KAAA,CAAM;AAAA;AAAA,IAEb,UAAA;AAAA;AAAA,IAEA,cAAA;AAAA,IACA,UAAA,EAAY,OAAA,EAAS,UAAA,IAAc,EAAC;AAAA,IACpC;AAAA,GACH,CAAA;AACL;AAEA,SAAS,aAAA,CAAc,eAAuB,SAAA,EAAqD;AAC/F,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,SAAS,CAAA,EAAG;AAC1B,IAAA,OAAO,SAAA,CAAU,GAAA,CAAmB,CAAC,CAAA,EAAG,KAAA,MAAW;AAAA,MAC/C,SAAA,EAAW,CAAA,YAAA,EAAe,aAAa,CAAA,CAAA,EAAI,KAAK,CAAA;AAAA,KACpD,CAAE,CAAA;AAAA,EACN;AACA,EAAA,OAAO;AAAA,IACH,SAAA,EAAW,eAAe,aAAa,CAAA;AAAA,GAC3C;AACJ;;;;"}
1
+ {"version":3,"file":"services.js","sources":["services.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { reactive } from \"@conterra/reactivity-core\";\nimport { ReferenceMeta, Service, ServiceConstructor } from \"@open-pioneer/runtime\";\nimport { createIntl } from \"./vanilla\";\n\n/**\n * Options for the {@link createService} function.\n */\nexport interface CreateServiceOptions<References> {\n /**\n * References provided to the service constructor.\n *\n * @default {}\n */\n references?: PartialServiceReferences<References>;\n\n /**\n * Properties provided to the service constructor.\n *\n * @default {}\n */\n properties?: Record<string, unknown>;\n\n /**\n * The locale for i18n messages and formatting.\n *\n * @default \"en\"\n */\n locale?: string;\n\n /**\n * The locale for embedded default messages.\n *\n * See also https://formatjs.io/docs/intl#message-descriptor\n *\n * @default \"en\"\n */\n defaultMessageLocale?: string;\n\n /**\n * I18n messages as (messageId, message) entries.\n *\n * @default {}\n */\n messages?: Record<string, string>;\n}\n\ntype PartialServiceReferences<References> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [referenceName in keyof References]?: References[referenceName] extends any[]\n ? Partial<References[referenceName][number]>[]\n : Partial<References[referenceName]>;\n};\n\n/**\n * Creates a new service instance of `clazz`.\n *\n * The options passed into the constructor of `clazz` are taking from the `options` parameter.\n *\n * This function allows the user to define mock- or test objects as service references.\n *\n * Most type-checking features are disabled for convenience, but by default this function's types\n * enforce that a value provided for a reference must match the partial interface of the actually required type.\n *\n * For example, if a service depends on `{ ctx: ApplicationContext }`, this function ensures\n * that the test value for `ctx` implements `Partial<ApplicationContext>`.\n * This can of course be disabled by casting the value explicitly.\n *\n * @param clazz a service class\n * @param options options passed to the service constructor\n * @returns a new instance of the given service class\n */\nexport function createService<References extends {}, Interface extends {}>(\n clazz: ServiceConstructor<References, Interface>,\n options?: CreateServiceOptions<References>\n): Service<Interface> {\n const references = options?.references ?? {};\n const referencesMeta = Object.fromEntries(\n Object.entries(references).map(([referenceName, reference]) => [\n referenceName,\n referenceMeta(referenceName, reference)\n ])\n );\n\n const intl = createIntl(options);\n return new clazz({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n references: references as any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n referencesMeta: referencesMeta as any,\n properties: options?.properties ?? {},\n intl,\n currentIntl: reactive(intl)\n });\n}\n\nfunction referenceMeta(referenceName: string, reference: unknown): ReferenceMeta | ReferenceMeta[] {\n if (Array.isArray(reference)) {\n return reference.map<ReferenceMeta>((_, index) => ({\n serviceId: `test-utils::${referenceName}-${index}`\n }));\n }\n return {\n serviceId: `test-utils::${referenceName}`\n };\n}\n"],"names":[],"mappings":";;;AAyEO,SAAS,aAAA,CACZ,OACA,OAAA,EACkB;AAClB,EAAA,MAAM,UAAA,GAAa,OAAA,EAAS,UAAA,IAAc,EAAC;AAC3C,EAAA,MAAM,iBAAiB,MAAA,CAAO,WAAA;AAAA,IAC1B,MAAA,CAAO,QAAQ,UAAU,CAAA,CAAE,IAAI,CAAC,CAAC,aAAA,EAAe,SAAS,CAAA,KAAM;AAAA,MAC3D,aAAA;AAAA,MACA,aAAA,CAAc,eAAe,SAAS;AAAA,KACzC;AAAA,GACL;AAEA,EAAA,MAAM,IAAA,GAAO,WAAW,OAAO,CAAA;AAC/B,EAAA,OAAO,IAAI,KAAA,CAAM;AAAA;AAAA,IAEb,UAAA;AAAA;AAAA,IAEA,cAAA;AAAA,IACA,UAAA,EAAY,OAAA,EAAS,UAAA,IAAc,EAAC;AAAA,IACpC,IAAA;AAAA,IACA,WAAA,EAAa,SAAS,IAAI;AAAA,GAC7B,CAAA;AACL;AAEA,SAAS,aAAA,CAAc,eAAuB,SAAA,EAAqD;AAC/F,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,SAAS,CAAA,EAAG;AAC1B,IAAA,OAAO,SAAA,CAAU,GAAA,CAAmB,CAAC,CAAA,EAAG,KAAA,MAAW;AAAA,MAC/C,SAAA,EAAW,CAAA,YAAA,EAAe,aAAa,CAAA,CAAA,EAAI,KAAK,CAAA;AAAA,KACpD,CAAE,CAAA;AAAA,EACN;AACA,EAAA,OAAO;AAAA,IACH,SAAA,EAAW,eAAe,aAAa,CAAA;AAAA,GAC3C;AACJ;;;;"}