@event-driven-io/emmett-expressjs 0.43.0-beta.11 → 0.43.0-beta.13

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/dist/index.d.cts CHANGED
@@ -118,7 +118,6 @@ declare const ApiSpecification: {
118
118
 
119
119
  type E2EResponseAssert = (response: Response$1) => boolean | void;
120
120
  type ApiE2ESpecificationAssert = [E2EResponseAssert];
121
- declare function apiE2ESpecificationFor(getApplication: () => Application): ApiE2ESpecification;
122
121
  declare function apiE2ESpecificationFor<Store extends EventStore = InMemoryEventStore>(options: {
123
122
  getEventStore?: () => Store;
124
123
  getApplication: (eventStore: Store) => Application;
package/dist/index.d.ts CHANGED
@@ -118,7 +118,6 @@ declare const ApiSpecification: {
118
118
 
119
119
  type E2EResponseAssert = (response: Response$1) => boolean | void;
120
120
  type ApiE2ESpecificationAssert = [E2EResponseAssert];
121
- declare function apiE2ESpecificationFor(getApplication: () => Application): ApiE2ESpecification;
122
121
  declare function apiE2ESpecificationFor<Store extends EventStore = InMemoryEventStore>(options: {
123
122
  getEventStore?: () => Store;
124
123
  getApplication: (eventStore: Store) => Application;
package/dist/index.js CHANGED
@@ -1088,12 +1088,14 @@ import supertest from "supertest";
1088
1088
  import assert from "assert";
1089
1089
  function apiE2ESpecificationFor(optionsOrGetApplication, getApplication2) {
1090
1090
  const resolveApplication = () => {
1091
- if (typeof optionsOrGetApplication === "function") {
1092
- if (getApplication2) {
1093
- const eventStore2 = optionsOrGetApplication();
1094
- return getApplication2(eventStore2);
1095
- }
1096
- return optionsOrGetApplication();
1091
+ if (typeof optionsOrGetApplication === "function" && getApplication2) {
1092
+ const eventStore2 = optionsOrGetApplication();
1093
+ return getApplication2(eventStore2);
1094
+ }
1095
+ if (typeof optionsOrGetApplication !== "object") {
1096
+ throw new EmmettError(
1097
+ "Invalid arguments provided to apiE2ESpecificationFor. Expected either an options object or a getEventStore function and getApplication function."
1098
+ );
1097
1099
  }
1098
1100
  const eventStore = optionsOrGetApplication.getEventStore?.() ?? getInMemoryEventStore();
1099
1101
  return optionsOrGetApplication.getApplication(eventStore);