eventmodeler 0.3.8 → 0.3.10
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.
|
@@ -261,6 +261,11 @@ function formatScenarioThen(model, then) {
|
|
|
261
261
|
},
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
|
+
if (then.type === 'noCommand') {
|
|
265
|
+
return {
|
|
266
|
+
type: 'noCommand',
|
|
267
|
+
};
|
|
268
|
+
}
|
|
264
269
|
if (then.type === 'readModelAssertion' && then.readModelAssertion) {
|
|
265
270
|
const rm = model.readModels.get(then.readModelAssertion.readModelStickyId);
|
|
266
271
|
return {
|
|
@@ -330,6 +330,18 @@ function formatSliceXml(model, slice) {
|
|
|
330
330
|
: ` <command type="${escapeXml(name)}"/>\n`;
|
|
331
331
|
xml += ' </when>\n';
|
|
332
332
|
}
|
|
333
|
+
else if (scenario.whenEvents && scenario.whenEvents.length > 0) {
|
|
334
|
+
xml += ' <when>\n';
|
|
335
|
+
for (const whenEvent of scenario.whenEvents) {
|
|
336
|
+
const evt = model.events.get(whenEvent.eventStickyId);
|
|
337
|
+
const name = evt?.name ?? 'UnknownEvent';
|
|
338
|
+
const values = formatFieldValues(whenEvent.fieldValues);
|
|
339
|
+
xml += values
|
|
340
|
+
? ` <event type="${escapeXml(name)}">${escapeXmlText(values)}</event>\n`
|
|
341
|
+
: ` <event type="${escapeXml(name)}"/>\n`;
|
|
342
|
+
}
|
|
343
|
+
xml += ' </when>\n';
|
|
344
|
+
}
|
|
333
345
|
xml += ' <then>\n';
|
|
334
346
|
if (scenario.then.type === 'error') {
|
|
335
347
|
xml += ` <error`;
|
|
@@ -347,6 +359,17 @@ function formatSliceXml(model, slice) {
|
|
|
347
359
|
: ` <event type="${escapeXml(name)}"/>\n`;
|
|
348
360
|
}
|
|
349
361
|
}
|
|
362
|
+
else if (scenario.then.type === 'command' && scenario.then.expectedCommand) {
|
|
363
|
+
const cmd = model.commands.get(scenario.then.expectedCommand.commandStickyId);
|
|
364
|
+
const name = cmd?.name ?? 'UnknownCommand';
|
|
365
|
+
const values = formatFieldValues(scenario.then.expectedCommand.fieldValues);
|
|
366
|
+
xml += values
|
|
367
|
+
? ` <command type="${escapeXml(name)}">${escapeXmlText(values)}</command>\n`
|
|
368
|
+
: ` <command type="${escapeXml(name)}"/>\n`;
|
|
369
|
+
}
|
|
370
|
+
else if (scenario.then.type === 'noCommand') {
|
|
371
|
+
xml += ' <no-command/>\n';
|
|
372
|
+
}
|
|
350
373
|
else if (scenario.then.type === 'readModelAssertion' && scenario.then.readModelAssertion) {
|
|
351
374
|
const assertion = scenario.then.readModelAssertion;
|
|
352
375
|
const rm = model.readModels.get(assertion.readModelStickyId);
|
|
@@ -571,6 +594,17 @@ function formatSliceJson(model, slice) {
|
|
|
571
594
|
...(scenario.whenCommand.fieldValues && Object.keys(scenario.whenCommand.fieldValues).length > 0 ? { fieldValues: scenario.whenCommand.fieldValues } : {})
|
|
572
595
|
};
|
|
573
596
|
}
|
|
597
|
+
else if (scenario.whenEvents && scenario.whenEvents.length > 0) {
|
|
598
|
+
scenarioObj.when = {
|
|
599
|
+
events: scenario.whenEvents.map(whenEvent => {
|
|
600
|
+
const evt = model.events.get(whenEvent.eventStickyId);
|
|
601
|
+
return {
|
|
602
|
+
eventType: evt?.name ?? 'UnknownEvent',
|
|
603
|
+
...(whenEvent.fieldValues && Object.keys(whenEvent.fieldValues).length > 0 ? { fieldValues: whenEvent.fieldValues } : {})
|
|
604
|
+
};
|
|
605
|
+
})
|
|
606
|
+
};
|
|
607
|
+
}
|
|
574
608
|
if (scenario.then.type === 'error') {
|
|
575
609
|
scenarioObj.then = {
|
|
576
610
|
type: 'error',
|
|
@@ -590,6 +624,19 @@ function formatSliceJson(model, slice) {
|
|
|
590
624
|
})
|
|
591
625
|
};
|
|
592
626
|
}
|
|
627
|
+
else if (scenario.then.type === 'command' && scenario.then.expectedCommand) {
|
|
628
|
+
const cmd = model.commands.get(scenario.then.expectedCommand.commandStickyId);
|
|
629
|
+
scenarioObj.then = {
|
|
630
|
+
type: 'command',
|
|
631
|
+
commandType: cmd?.name ?? 'UnknownCommand',
|
|
632
|
+
...(scenario.then.expectedCommand.fieldValues && Object.keys(scenario.then.expectedCommand.fieldValues).length > 0 ? { fieldValues: scenario.then.expectedCommand.fieldValues } : {})
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
else if (scenario.then.type === 'noCommand') {
|
|
636
|
+
scenarioObj.then = {
|
|
637
|
+
type: 'noCommand'
|
|
638
|
+
};
|
|
639
|
+
}
|
|
593
640
|
else if (scenario.then.type === 'readModelAssertion' && scenario.then.readModelAssertion) {
|
|
594
641
|
const assertion = scenario.then.readModelAssertion;
|
|
595
642
|
const rm = model.readModels.get(assertion.readModelStickyId);
|
package/dist/types.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export interface ReadModelAssertion {
|
|
|
22
22
|
givenEvents: EventReference[];
|
|
23
23
|
expectedFieldValues: Record<string, unknown>;
|
|
24
24
|
}
|
|
25
|
-
export type ScenarioThenType = 'error' | 'events' | 'readModelAssertion' | 'command';
|
|
25
|
+
export type ScenarioThenType = 'error' | 'events' | 'readModelAssertion' | 'command' | 'noCommand';
|
|
26
26
|
export interface ScenarioThen {
|
|
27
27
|
type: ScenarioThenType;
|
|
28
28
|
errorMessage?: string;
|