definition-generator-framework 1.13.1 → 2.0.0-rc1
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.mts +204 -0
- package/dist/index.d.ts +204 -17
- package/dist/index.js +43 -50
- package/dist/index.mjs +43 -0
- package/package.json +28 -14
- package/dist/_mocks/mocks.d.ts +0 -7
- package/dist/_mocks/mocks.js +0 -44
- package/dist/decorators/definition-component.d.ts +0 -18
- package/dist/decorators/definition-component.js +0 -52
- package/dist/decorators/definition-generator.d.ts +0 -11
- package/dist/decorators/definition-generator.js +0 -30
- package/dist/framework/context.d.ts +0 -24
- package/dist/framework/context.js +0 -64
- package/dist/framework/definition-component.d.ts +0 -20
- package/dist/framework/definition-component.js +0 -29
- package/dist/framework/definition-generator.d.ts +0 -11
- package/dist/framework/definition-generator.js +0 -22
- package/dist/framework/definition-store.d.ts +0 -25
- package/dist/framework/definition-store.js +0 -121
- package/dist/framework/file-content-generator/file-content-generator.d.ts +0 -19
- package/dist/framework/file-content-generator/file-content-generator.js +0 -117
- package/dist/framework/file-content-generator/file-content-generator.test.d.ts +0 -24
- package/dist/framework/file-content-generator/file-content-generator.test.js +0 -161
- package/dist/framework/file-generators/index-file-generator.d.ts +0 -13
- package/dist/framework/file-generators/index-file-generator.js +0 -139
- package/dist/framework/file-generators/types-file-generator.d.ts +0 -6
- package/dist/framework/file-generators/types-file-generator.js +0 -35
- package/dist/framework/framework.d.ts +0 -28
- package/dist/framework/framework.data.d.ts +0 -6
- package/dist/framework/framework.data.js +0 -17
- package/dist/framework/framework.js +0 -51
- package/dist/framework/framework.model.d.ts +0 -32
- package/dist/framework/framework.model.js +0 -3
- package/dist/framework/index-file-generator/index-file-generator.d.ts +0 -10
- package/dist/framework/index-file-generator/index-file-generator.js +0 -118
- package/dist/framework/interfaces.d.ts +0 -46
- package/dist/framework/interfaces.js +0 -3
- package/dist/framework/kernel.d.ts +0 -12
- package/dist/framework/kernel.js +0 -308
- package/dist/helpers/common-functions/common-functions.d.ts +0 -10
- package/dist/helpers/common-functions/common-functions.js +0 -29
- package/dist/helpers/common-functions/common-functions.spec.d.ts +0 -1
- package/dist/helpers/common-functions/common-functions.spec.js +0 -50
- package/dist/helpers/common-functions/common-functions.test.d.ts +0 -1
- package/dist/helpers/common-functions/common-functions.test.js +0 -51
- package/dist/helpers/duplicate-helper/duplicate-helper.d.ts +0 -11
- package/dist/helpers/duplicate-helper/duplicate-helper.js +0 -40
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.d.ts +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +0 -54
- package/dist/helpers/duplicate-helper/duplicate-helper.test.d.ts +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.test.js +0 -55
- package/dist/helpers/output-helper/output-helper.d.ts +0 -30
- package/dist/helpers/output-helper/output-helper.js +0 -143
- package/dist/helpers/output-helper/output-helper.spec.d.ts +0 -24
- package/dist/helpers/output-helper/output-helper.spec.js +0 -261
- package/dist/helpers/output-helper/output-helper.test.d.ts +0 -24
- package/dist/helpers/output-helper/output-helper.test.js +0 -262
- package/dist/helpers/raw-definition-helper/raw-definition.helper.d.ts +0 -7
- package/dist/helpers/raw-definition-helper/raw-definition.helper.js +0 -66
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.d.ts +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +0 -143
- package/dist/helpers/raw-definition-helper/raw-definition.helper.test.d.ts +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.test.js +0 -136
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.d.ts +0 -16
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.js +0 -48
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +0 -191
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.d.ts +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.js +0 -213
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.d.ts +0 -13
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.js +0 -53
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.d.ts +0 -1
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.js +0 -96
- package/dist/helpers/validator/custom-validators/image.custom-validator.d.ts +0 -14
- package/dist/helpers/validator/custom-validators/image.custom-validator.js +0 -44
- package/dist/helpers/validator/custom-validators/path.custom-validator.d.ts +0 -9
- package/dist/helpers/validator/custom-validators/path.custom-validator.js +0 -30
- package/dist/helpers/validator/custom-validators/position-on-sprite.d.ts +0 -14
- package/dist/helpers/validator/custom-validators/position-on-sprite.js +0 -44
- package/dist/helpers/validator/custom-validators/reference.custom-validator.d.ts +0 -22
- package/dist/helpers/validator/custom-validators/reference.custom-validator.js +0 -123
- package/dist/helpers/validator/custom-validators/sprite.custom-validator.d.ts +0 -14
- package/dist/helpers/validator/custom-validators/sprite.custom-validator.js +0 -43
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.d.ts +0 -9
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js +0 -33
- package/dist/helpers/validator/custom-validators/unique.custom-validator.d.ts +0 -8
- package/dist/helpers/validator/custom-validators/unique.custom-validator.js +0 -20
- package/dist/helpers/validator/joi-custom-validators.d.ts +0 -33
- package/dist/helpers/validator/joi-custom-validators.js +0 -54
- package/dist/helpers/validator/joi-custom-validators.spec.d.ts +0 -1
- package/dist/helpers/validator/joi-custom-validators.spec.js +0 -304
- package/dist/helpers/validator/validator.d.ts +0 -21
- package/dist/helpers/validator/validator.js +0 -74
- package/dist/helpers/validator/validator.spec.d.ts +0 -1
- package/dist/helpers/validator/validator.spec.js +0 -332
- package/dist/helpers/validator/validator.test.d.ts +0 -1
- package/dist/helpers/validator/validator.test.js +0 -329
- package/dist/pipeline/1-select-definitions-helper.d.ts +0 -20
- package/dist/pipeline/1-select-definitions-helper.js +0 -76
- package/dist/pipeline/1-select-definitions.helper.d.ts +0 -20
- package/dist/pipeline/1-select-definitions.helper.js +0 -80
- package/dist/pipeline/1-select-definitions.helper.test.d.ts +0 -1
- package/dist/pipeline/1-select-definitions.helper.test.js +0 -141
- package/dist/pipeline/1-select-definitions.spec.d.ts +0 -1
- package/dist/pipeline/1-select-definitions.spec.js +0 -140
- package/dist/pipeline/2-structure-parser.helper.d.ts +0 -11
- package/dist/pipeline/2-structure-parser.helper.js +0 -70
- package/dist/pipeline/2-structure-parser.helper.spec.d.ts +0 -1
- package/dist/pipeline/2-structure-parser.helper.spec.js +0 -280
- package/dist/pipeline/2-structure-parser.helper.test.d.ts +0 -1
- package/dist/pipeline/2-structure-parser.helper.test.js +0 -281
- package/dist/pipeline/3-config.d.ts +0 -9
- package/dist/pipeline/3-config.js +0 -36
- package/dist/pipeline/_mocks/index.d.ts +0 -13
- package/dist/pipeline/_mocks/index.js +0 -52
- package/dist/pipeline/parsers/array-parser.d.ts +0 -4
- package/dist/pipeline/parsers/array-parser.js +0 -69
- package/dist/pipeline/parsers/array-parser.spec.d.ts +0 -1
- package/dist/pipeline/parsers/array-parser.spec.js +0 -128
- package/dist/pipeline/parsers/array-parser.test.d.ts +0 -1
- package/dist/pipeline/parsers/array-parser.test.js +0 -126
- package/dist/pipeline/parsers/object-parser.d.ts +0 -4
- package/dist/pipeline/parsers/object-parser.js +0 -135
- package/dist/pipeline/parsers/object-parser.spec.d.ts +0 -1
- package/dist/pipeline/parsers/object-parser.spec.js +0 -179
- package/dist/pipeline/parsers/object-parser.test.d.ts +0 -1
- package/dist/pipeline/parsers/object-parser.test.js +0 -186
- package/dist/pipeline/parsers/primitive-parser.d.ts +0 -7
- package/dist/pipeline/parsers/primitive-parser.js +0 -111
- package/dist/pipeline/parsers/primitive-parser.spec.d.ts +0 -1
- package/dist/pipeline/parsers/primitive-parser.spec.js +0 -79
- package/dist/pipeline/parsers/primitive-parser.test.d.ts +0 -1
- package/dist/pipeline/parsers/primitive-parser.test.js +0 -85
- package/dist/pipeline/raw-data-parser.d.ts +0 -5
- package/dist/pipeline/raw-data-parser.js +0 -25
- package/dist/pre-made-components/_validators/shape-validators.d.ts +0 -7
- package/dist/pre-made-components/_validators/shape-validators.js +0 -37
- package/dist/pre-made-components/_validators/sprite-validators.d.ts +0 -7
- package/dist/pre-made-components/_validators/sprite-validators.js +0 -43
- package/dist/pre-made-components/assets/1-sprite.d.ts +0 -15
- package/dist/pre-made-components/assets/1-sprite.js +0 -74
- package/dist/pre-made-components/assets/2-sprite-group.d.ts +0 -11
- package/dist/pre-made-components/assets/2-sprite-group.js +0 -41
- package/dist/pre-made-components/assets/3-font.d.ts +0 -17
- package/dist/pre-made-components/assets/3-font.js +0 -71
- package/dist/pre-made-components/events/1-event.d.ts +0 -6
- package/dist/pre-made-components/events/1-event.js +0 -206
- package/dist/pre-made-components/events/1-script.d.ts +0 -8
- package/dist/pre-made-components/events/1-script.js +0 -102
- package/dist/pre-made-components/events/2-event-test.d.ts +0 -18
- package/dist/pre-made-components/events/2-event-test.js +0 -172
- package/dist/pre-made-components/events/2-script-test.d.ts +0 -7
- package/dist/pre-made-components/events/2-script-test.js +0 -102
- package/dist/pre-made-components/events/3-event.d.ts +0 -7
- package/dist/pre-made-components/events/3-event.js +0 -100
- package/dist/pre-made-components/events/4-event-test.d.ts +0 -7
- package/dist/pre-made-components/events/4-event-test.js +0 -89
- package/dist/pre-made-components/events/event-setup.d.ts +0 -13
- package/dist/pre-made-components/events/event-setup.js +0 -20
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.d.ts +0 -3
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.js +0 -24
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.d.ts +0 -1
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.js +0 -39
- package/dist/pre-made-components/events/helpers/script-testing.helper.d.ts +0 -33
- package/dist/pre-made-components/events/helpers/script-testing.helper.js +0 -79
- package/dist/pre-made-components/events/script-setup.d.ts +0 -8
- package/dist/pre-made-components/events/script-setup.js +0 -16
- package/dist/pre-made-components/events/scripting-setup.d.ts +0 -33
- package/dist/pre-made-components/events/scripting-setup.js +0 -97
- package/dist/pre-made-components/events/validators.d.ts +0 -6
- package/dist/pre-made-components/events/validators.js +0 -96
- package/dist/setup.d.ts +0 -1
- package/dist/setup.js +0 -10
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __decorate =
|
|
3
|
-
(this && this.__decorate) ||
|
|
4
|
-
function (decorators, target, key, desc) {
|
|
5
|
-
var c = arguments.length,
|
|
6
|
-
r = c < 3 ? target : desc === null ? (desc = Object.getOwnPropertyDescriptor(target, key)) : desc,
|
|
7
|
-
d;
|
|
8
|
-
if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function')
|
|
9
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
10
|
-
else
|
|
11
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
12
|
-
if ((d = decorators[i])) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
|
-
};
|
|
15
|
-
var __importDefault =
|
|
16
|
-
(this && this.__importDefault) ||
|
|
17
|
-
function (mod) {
|
|
18
|
-
return mod && mod.__esModule ? mod : { default: mod };
|
|
19
|
-
};
|
|
20
|
-
var EventTestComponent_1;
|
|
21
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
22
|
-
exports.EventTestComponent = void 0;
|
|
23
|
-
const helpers_lib_1 = require('helpers-lib');
|
|
24
|
-
const joi_1 = __importDefault(require('joi'));
|
|
25
|
-
const script_engine_lib_1 = require('script-engine-lib');
|
|
26
|
-
const definition_component_1 = require('../../decorators/definition-component');
|
|
27
|
-
const definition_store_1 = require('../../framework/definition-store');
|
|
28
|
-
const _1_event_1 = require('./1-event');
|
|
29
|
-
const event_setup_1 = require('./event-setup');
|
|
30
|
-
const CommandEventSchema = joi_1.default.string().custom(value => ({
|
|
31
|
-
type: 'command',
|
|
32
|
-
value: value
|
|
33
|
-
}));
|
|
34
|
-
const RunEventSchema = joi_1.default
|
|
35
|
-
.object()
|
|
36
|
-
.keys({
|
|
37
|
-
runEvent: joi_1.default.string().reference(_1_event_1.EventComponent).required()
|
|
38
|
-
})
|
|
39
|
-
.custom(value => ({
|
|
40
|
-
type: 'runEvent',
|
|
41
|
-
value: value.runEvent
|
|
42
|
-
}));
|
|
43
|
-
const EventTestActionSchema = () =>
|
|
44
|
-
joi_1.default
|
|
45
|
-
.array()
|
|
46
|
-
.items(
|
|
47
|
-
joi_1.default
|
|
48
|
-
.alternatives()
|
|
49
|
-
.conditional(joi_1.default.string(), {
|
|
50
|
-
then: CommandEventSchema
|
|
51
|
-
})
|
|
52
|
-
.conditional(joi_1.default.object({ runEvent: joi_1.default.exist() }).unknown(), {
|
|
53
|
-
then: RunEventSchema
|
|
54
|
-
})
|
|
55
|
-
)
|
|
56
|
-
.min(1);
|
|
57
|
-
let EventTestComponent = (EventTestComponent_1 = class EventTestComponent extends definition_component_1.DefinitionComponent {
|
|
58
|
-
async process(definitions, output) {
|
|
59
|
-
let eventTestSimulator = this.createEventTestSimulator();
|
|
60
|
-
let runtimeErrors = this.runTests(definitions, eventTestSimulator, output);
|
|
61
|
-
this.printErrors(runtimeErrors, eventTestSimulator, output);
|
|
62
|
-
}
|
|
63
|
-
createEventTestSimulator() {
|
|
64
|
-
let allScripts = definition_store_1.DefinitionStore.getDefinitions(_1_event_1.EventComponent);
|
|
65
|
-
return new script_engine_lib_1.ScriptTestSimulator(allScripts);
|
|
66
|
-
}
|
|
67
|
-
runTests(testDefinitions, eventTestSimulator, output) {
|
|
68
|
-
let errorLogs = [];
|
|
69
|
-
testDefinitions.forEach(testDefinition => {
|
|
70
|
-
let event = definition_store_1.DefinitionStore.getDefinitionOrFail(_1_event_1.EventComponent, testDefinition.event);
|
|
71
|
-
let errorEncountered = false;
|
|
72
|
-
testDefinition.cases.forEach((testCase, testCaseIndex) => {
|
|
73
|
-
if (!errorEncountered) {
|
|
74
|
-
let jsEngine = new helpers_lib_1.JSEngine(new event_setup_1.EventSetup.EventSimulatorFunctionsConstructor(), {});
|
|
75
|
-
try {
|
|
76
|
-
eventTestSimulator.simulateScript(event, jsEngine, testCase.actionsBeforeTesting);
|
|
77
|
-
} catch (e) {
|
|
78
|
-
let errorLog = this.prepareErrorLog(e, testDefinition, testCaseIndex, output);
|
|
79
|
-
errorLogs.push(errorLog);
|
|
80
|
-
errorEncountered = true;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
return errorLogs;
|
|
86
|
-
}
|
|
87
|
-
prepareErrorLog(e, testDefinition, testCaseIndex, output) {
|
|
88
|
-
if (e instanceof script_engine_lib_1.SimulationError) {
|
|
89
|
-
return {
|
|
90
|
-
description: e.message,
|
|
91
|
-
location: definition_store_1.DefinitionStore.getLocationInFileById(
|
|
92
|
-
_1_event_1.EventComponent,
|
|
93
|
-
e.location.scriptId,
|
|
94
|
-
e.location.path
|
|
95
|
-
)
|
|
96
|
-
};
|
|
97
|
-
} else if (e instanceof script_engine_lib_1.ActionsBeforeTestingError) {
|
|
98
|
-
let executedActionLocation = definition_store_1.DefinitionStore.getLocationInFile(EventTestComponent_1, testDefinition, [
|
|
99
|
-
'cases',
|
|
100
|
-
`${testCaseIndex}`,
|
|
101
|
-
'actionsBeforeTesting',
|
|
102
|
-
`${e.actionIndex}`
|
|
103
|
-
]);
|
|
104
|
-
return {
|
|
105
|
-
description: e.message,
|
|
106
|
-
location: executedActionLocation
|
|
107
|
-
};
|
|
108
|
-
} else if (e instanceof script_engine_lib_1.BranchingBeforeTestingError) {
|
|
109
|
-
let testLocation = definition_store_1.DefinitionStore.getLocationInFile(EventTestComponent_1, testDefinition, []);
|
|
110
|
-
let executionHistoryAddition = `Running the test: ${output.convertLocationInFileToLink(testLocation)}\n\n`;
|
|
111
|
-
let executionHistoryStart = e.message.indexOf('\n', e.message.indexOf('Execution history')) + 1;
|
|
112
|
-
let fullMessage =
|
|
113
|
-
e.message.slice(0, executionHistoryStart) + executionHistoryAddition + e.message.slice(executionHistoryStart);
|
|
114
|
-
return {
|
|
115
|
-
description: fullMessage,
|
|
116
|
-
location: definition_store_1.DefinitionStore.getLocationInFileById(
|
|
117
|
-
_1_event_1.EventComponent,
|
|
118
|
-
e.location.scriptId,
|
|
119
|
-
e.location.path
|
|
120
|
-
)
|
|
121
|
-
};
|
|
122
|
-
} else {
|
|
123
|
-
throw e;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
printErrors(runtimeErrors, scriptTestSimulator, output) {
|
|
127
|
-
if (runtimeErrors.length === 0) {
|
|
128
|
-
scriptTestSimulator.getUnvisitedBranchLocations().forEach(location =>
|
|
129
|
-
output.addError({
|
|
130
|
-
description: `Event branch is not reaced by any of the combinations during the tests.`,
|
|
131
|
-
location: definition_store_1.DefinitionStore.getLocationInFileById(
|
|
132
|
-
_1_event_1.EventComponent,
|
|
133
|
-
location.scriptId,
|
|
134
|
-
location.path
|
|
135
|
-
)
|
|
136
|
-
})
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
runtimeErrors.forEach(error => output.addError(error));
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
exports.EventTestComponent = EventTestComponent;
|
|
143
|
-
exports.EventTestComponent =
|
|
144
|
-
EventTestComponent =
|
|
145
|
-
EventTestComponent_1 =
|
|
146
|
-
__decorate(
|
|
147
|
-
[
|
|
148
|
-
(0, definition_component_1.DefinitionComponentDecorator)({
|
|
149
|
-
componentName: 'EVENT-TEST',
|
|
150
|
-
keyName: 'id',
|
|
151
|
-
validationSchema: joi_1.default
|
|
152
|
-
.object()
|
|
153
|
-
.keys({
|
|
154
|
-
event: joi_1.default.string().reference(_1_event_1.EventComponent).required(),
|
|
155
|
-
cases: joi_1.default
|
|
156
|
-
.array()
|
|
157
|
-
.items(
|
|
158
|
-
joi_1.default
|
|
159
|
-
.object()
|
|
160
|
-
.keys({
|
|
161
|
-
actionsBeforeTesting: EventTestActionSchema().default([]).optional()
|
|
162
|
-
})
|
|
163
|
-
.required()
|
|
164
|
-
)
|
|
165
|
-
.required()
|
|
166
|
-
})
|
|
167
|
-
.required()
|
|
168
|
-
})
|
|
169
|
-
],
|
|
170
|
-
EventTestComponent
|
|
171
|
-
);
|
|
172
|
-
//# sourceMappingURL=2-event-test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { DefinitionComponent } from '../../decorators/definition-component';
|
|
2
|
-
import { Output } from '../../framework/interfaces';
|
|
3
|
-
import { ScriptTestDefinition } from './helpers/script-testing.helper';
|
|
4
|
-
export declare class ScriptTestComponent extends DefinitionComponent<ScriptTestDefinition> {
|
|
5
|
-
process(definitions: ScriptTestDefinition[], output: Output): Promise<void>;
|
|
6
|
-
private getLocationFinder;
|
|
7
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
var ScriptTestComponent_1;
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.ScriptTestComponent = void 0;
|
|
14
|
-
const joi_1 = __importDefault(require("joi"));
|
|
15
|
-
const definition_component_1 = require("../../decorators/definition-component");
|
|
16
|
-
const definition_store_1 = require("../../framework/definition-store");
|
|
17
|
-
const _1_script_1 = require("./1-script");
|
|
18
|
-
const script_testing_helper_1 = require("./helpers/script-testing.helper");
|
|
19
|
-
const scripting_setup_1 = require("./scripting-setup");
|
|
20
|
-
const CommandEventSchema = joi_1.default.string().custom(value => ({
|
|
21
|
-
type: 'command',
|
|
22
|
-
value: value
|
|
23
|
-
}));
|
|
24
|
-
const RunScriptSchema = joi_1.default.object()
|
|
25
|
-
.keys({
|
|
26
|
-
runScript: joi_1.default.string().reference(_1_script_1.ScriptComponent).required()
|
|
27
|
-
})
|
|
28
|
-
.custom(value => ({
|
|
29
|
-
type: 'runScript',
|
|
30
|
-
value: value.runScript
|
|
31
|
-
}));
|
|
32
|
-
const EventTestActionSchema = () => joi_1.default.array()
|
|
33
|
-
.items(joi_1.default.alternatives()
|
|
34
|
-
.conditional(joi_1.default.string(), {
|
|
35
|
-
then: CommandEventSchema
|
|
36
|
-
})
|
|
37
|
-
.conditional(joi_1.default.object({ runScript: joi_1.default.exist() }).unknown(), {
|
|
38
|
-
then: RunScriptSchema
|
|
39
|
-
})
|
|
40
|
-
.error(errors => errors.map(error => {
|
|
41
|
-
if (error.code === 'alternatives.any') {
|
|
42
|
-
let allowedTypes = 'command, runScript';
|
|
43
|
-
error.message = `${error.local.label} does not match any of the allowed types: ${allowedTypes}`;
|
|
44
|
-
}
|
|
45
|
-
return error;
|
|
46
|
-
})))
|
|
47
|
-
.min(1);
|
|
48
|
-
let ScriptTestComponent = ScriptTestComponent_1 = class ScriptTestComponent extends definition_component_1.DefinitionComponent {
|
|
49
|
-
async process(definitions, output) {
|
|
50
|
-
let allScripts = definition_store_1.DefinitionStore.getDefinitions(_1_script_1.ScriptComponent);
|
|
51
|
-
let scriptTestingHelper = new script_testing_helper_1.ScriptTestingHelper(allScripts, scripting_setup_1.ScriptTestingInternal.scriptSimulatorFunctionsConstructor, this.getLocationFinder());
|
|
52
|
-
let testCasesFullDefinitions = definitions.map(definition => ({
|
|
53
|
-
cases: definition.cases,
|
|
54
|
-
script: definition_store_1.DefinitionStore.getDefinitionOrFail(_1_script_1.ScriptComponent, definition.script),
|
|
55
|
-
scriptInput: scripting_setup_1.ScriptTestingInternal.getScriptInput(definition.script),
|
|
56
|
-
testDefinitionRef: definition
|
|
57
|
-
}));
|
|
58
|
-
let customTestCasesFullDefinitions = scripting_setup_1.ScriptTestingInternal.getCustomScriptTestCases().map(definition => ({
|
|
59
|
-
cases: definition.testDefinition.cases,
|
|
60
|
-
script: definition_store_1.DefinitionStore.getDefinitionOrFail(_1_script_1.ScriptComponent, definition.testDefinition.script),
|
|
61
|
-
scriptInput: scripting_setup_1.ScriptTestingInternal.getScriptInput(definition.testDefinition.script),
|
|
62
|
-
testDefinitionRef: definition.testDefinition,
|
|
63
|
-
customMessage: definition.customMessage
|
|
64
|
-
}));
|
|
65
|
-
let allTestDefinitions = testCasesFullDefinitions.concat(customTestCasesFullDefinitions);
|
|
66
|
-
let runtimeErrors = scriptTestingHelper.runTests(allTestDefinitions, output);
|
|
67
|
-
scriptTestingHelper.printErrors(runtimeErrors, output);
|
|
68
|
-
}
|
|
69
|
-
getLocationFinder() {
|
|
70
|
-
return {
|
|
71
|
-
getLocationOfDefinition: (key, path) => definition_store_1.DefinitionStore.getLocationInFileById(_1_script_1.ScriptComponent, key, path),
|
|
72
|
-
getLocationOfTestDefinition: (definition, path) => {
|
|
73
|
-
if (scripting_setup_1.ScriptTestingInternal.isCustomScriptTestCase(definition)) {
|
|
74
|
-
let errorMessage = `Internal error: custom script test case is failing. Definition: ${JSON.stringify(definition)}, Path: ${JSON.stringify(path)}`;
|
|
75
|
-
throw new Error(errorMessage);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
return definition_store_1.DefinitionStore.getLocationInFile(ScriptTestComponent_1, definition, path);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
exports.ScriptTestComponent = ScriptTestComponent;
|
|
85
|
-
exports.ScriptTestComponent = ScriptTestComponent = ScriptTestComponent_1 = __decorate([
|
|
86
|
-
(0, definition_component_1.DefinitionComponentDecorator)({
|
|
87
|
-
componentName: 'SCRIPT-TEST',
|
|
88
|
-
validationSchema: joi_1.default.object()
|
|
89
|
-
.keys({
|
|
90
|
-
script: joi_1.default.string().reference(_1_script_1.ScriptComponent).required(),
|
|
91
|
-
cases: joi_1.default.array()
|
|
92
|
-
.items(joi_1.default.object()
|
|
93
|
-
.keys({
|
|
94
|
-
actionsBeforeTesting: EventTestActionSchema().default([]).optional()
|
|
95
|
-
})
|
|
96
|
-
.required())
|
|
97
|
-
.required()
|
|
98
|
-
})
|
|
99
|
-
.required()
|
|
100
|
-
})
|
|
101
|
-
], ScriptTestComponent);
|
|
102
|
-
//# sourceMappingURL=2-script-test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ScriptDefinition } from 'script-engine-lib';
|
|
2
|
-
import { DefinitionComponent } from '../../decorators/definition-component';
|
|
3
|
-
import { Output } from '../../framework/interfaces';
|
|
4
|
-
export type EventID = string;
|
|
5
|
-
export declare class EventComponent extends DefinitionComponent<ScriptDefinition> {
|
|
6
|
-
process(definitions: ScriptDefinition[], output: Output): Promise<void>;
|
|
7
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.EventComponent = void 0;
|
|
13
|
-
const helpers_lib_1 = require("helpers-lib");
|
|
14
|
-
const joi_1 = __importDefault(require("joi"));
|
|
15
|
-
const definition_component_1 = require("../../decorators/definition-component");
|
|
16
|
-
const _1_script_1 = require("./1-script");
|
|
17
|
-
const validators_1 = require("./validators");
|
|
18
|
-
const JumpToEventSchema = joi_1.default.object()
|
|
19
|
-
.keys({
|
|
20
|
-
jumpTo: joi_1.default.string().lazyReference('EVENT').required()
|
|
21
|
-
})
|
|
22
|
-
.custom(value => ({
|
|
23
|
-
type: 'jumpTo',
|
|
24
|
-
value: value.jumpTo
|
|
25
|
-
}));
|
|
26
|
-
// ---- Main Schema ----
|
|
27
|
-
const EventActionId = 'EventActionsSchema';
|
|
28
|
-
const ActionsSchema = () => joi_1.default.array()
|
|
29
|
-
.items(joi_1.default.alternatives()
|
|
30
|
-
.conditional(joi_1.default.string(), {
|
|
31
|
-
then: (0, validators_1.ActionCommandSchema)()
|
|
32
|
-
})
|
|
33
|
-
.conditional(joi_1.default.object({ jumpTo: joi_1.default.exist() }).unknown(), {
|
|
34
|
-
then: JumpToEventSchema
|
|
35
|
-
})
|
|
36
|
-
.conditional(joi_1.default.object({ branchByChance: joi_1.default.exist() }).unknown(), {
|
|
37
|
-
then: (0, validators_1.BranchByChanceSchema)(EventActionId)
|
|
38
|
-
})
|
|
39
|
-
.conditional(joi_1.default.object({ branchByCondition: joi_1.default.exist() }).unknown(), {
|
|
40
|
-
then: (0, validators_1.BranchByConditionSchema)(EventActionId)
|
|
41
|
-
})
|
|
42
|
-
.conditional(joi_1.default.object({ branchByPlayerChoice: joi_1.default.exist() }).unknown(), {
|
|
43
|
-
then: (0, validators_1.BranchByPlayerChoiceSchema)(EventActionId)
|
|
44
|
-
})
|
|
45
|
-
.conditional(joi_1.default.object().min(1).max(1).unknown(), {
|
|
46
|
-
then: (0, validators_1.DialogSchema)()
|
|
47
|
-
})
|
|
48
|
-
.error(errors => errors.map(error => {
|
|
49
|
-
if (error.code === 'alternatives.any') {
|
|
50
|
-
let allowedTypes = 'command, jumpTo, branchByCondition, branchByPlayerChoice, branchByChance';
|
|
51
|
-
error.message = `${error.local.label} does not match any of the allowed types: ${allowedTypes}`;
|
|
52
|
-
}
|
|
53
|
-
return error;
|
|
54
|
-
})))
|
|
55
|
-
.custom((array) => {
|
|
56
|
-
let commandFoundAfterBranching = false;
|
|
57
|
-
let emptyStackRequiresBranchingFound = false;
|
|
58
|
-
array.forEach(action => {
|
|
59
|
-
if (emptyStackRequiresBranchingFound) {
|
|
60
|
-
commandFoundAfterBranching = true;
|
|
61
|
-
}
|
|
62
|
-
else if (action.type === 'branchByCondition' ||
|
|
63
|
-
action.type === 'branchByPlayerChoice' ||
|
|
64
|
-
action.type === 'branchByChance') {
|
|
65
|
-
emptyStackRequiresBranchingFound = true;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
if (commandFoundAfterBranching) {
|
|
69
|
-
throw new Error('There should not be any command after branching.');
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
return array;
|
|
73
|
-
}
|
|
74
|
-
})
|
|
75
|
-
.id(EventActionId);
|
|
76
|
-
let EventComponent = class EventComponent extends definition_component_1.DefinitionComponent {
|
|
77
|
-
async process(definitions, output) {
|
|
78
|
-
await output.addFile({
|
|
79
|
-
path: '/_premade/script-engine-definitions/events.ts',
|
|
80
|
-
preText: `import { ScriptDefinition } from "script-engine-lib";`,
|
|
81
|
-
variableName: 'EventDefinitions',
|
|
82
|
-
variableType: 'Readonly<Record<string, ScriptDefinition>>',
|
|
83
|
-
variable: helpers_lib_1.JsonHelper.arrayToObject(definitions, 'id')
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
exports.EventComponent = EventComponent;
|
|
88
|
-
exports.EventComponent = EventComponent = __decorate([
|
|
89
|
-
(0, definition_component_1.DefinitionComponentDecorator)({
|
|
90
|
-
componentName: 'EVENT',
|
|
91
|
-
keyName: 'id',
|
|
92
|
-
validationSchema: joi_1.default.object()
|
|
93
|
-
.keys({
|
|
94
|
-
id: joi_1.default.string().unique(_1_script_1.ScriptNames).required(),
|
|
95
|
-
actions: ActionsSchema().min(1).required()
|
|
96
|
-
})
|
|
97
|
-
.required()
|
|
98
|
-
})
|
|
99
|
-
], EventComponent);
|
|
100
|
-
//# sourceMappingURL=3-event.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { DefinitionComponent } from '../../decorators/definition-component';
|
|
2
|
-
import { Output } from '../../framework/interfaces';
|
|
3
|
-
import { ScriptTestDefinition } from './helpers/script-testing.helper';
|
|
4
|
-
export declare class EventTestComponent extends DefinitionComponent<ScriptTestDefinition> {
|
|
5
|
-
process(definitions: ScriptTestDefinition[], output: Output): Promise<void>;
|
|
6
|
-
private getLocationFinder;
|
|
7
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
var EventTestComponent_1;
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.EventTestComponent = void 0;
|
|
14
|
-
const joi_1 = __importDefault(require("joi"));
|
|
15
|
-
const definition_component_1 = require("../../decorators/definition-component");
|
|
16
|
-
const definition_store_1 = require("../../framework/definition-store");
|
|
17
|
-
const _3_event_1 = require("./3-event");
|
|
18
|
-
const script_testing_helper_1 = require("./helpers/script-testing.helper");
|
|
19
|
-
const scripting_setup_1 = require("./scripting-setup");
|
|
20
|
-
const CommandEventSchema = joi_1.default.string().custom(value => ({
|
|
21
|
-
type: 'command',
|
|
22
|
-
value: value
|
|
23
|
-
}));
|
|
24
|
-
const RunEventSchema = joi_1.default.object()
|
|
25
|
-
.keys({
|
|
26
|
-
runEvent: joi_1.default.string().reference(_3_event_1.EventComponent).required()
|
|
27
|
-
})
|
|
28
|
-
.custom(value => ({
|
|
29
|
-
type: 'runScript',
|
|
30
|
-
value: value.runEvent
|
|
31
|
-
}));
|
|
32
|
-
const EventTestActionSchema = () => joi_1.default.array()
|
|
33
|
-
.items(joi_1.default.alternatives()
|
|
34
|
-
.conditional(joi_1.default.string(), {
|
|
35
|
-
then: CommandEventSchema
|
|
36
|
-
})
|
|
37
|
-
.conditional(joi_1.default.object({ runEvent: joi_1.default.exist() }).unknown(), {
|
|
38
|
-
then: RunEventSchema
|
|
39
|
-
})
|
|
40
|
-
.error(errors => errors.map(error => {
|
|
41
|
-
if (error.code === 'alternatives.any') {
|
|
42
|
-
let allowedTypes = 'command, runEvent';
|
|
43
|
-
error.message = `${error.local.label} does not match any of the allowed types: ${allowedTypes}`;
|
|
44
|
-
}
|
|
45
|
-
return error;
|
|
46
|
-
})))
|
|
47
|
-
.min(1);
|
|
48
|
-
let EventTestComponent = EventTestComponent_1 = class EventTestComponent extends definition_component_1.DefinitionComponent {
|
|
49
|
-
async process(definitions, output) {
|
|
50
|
-
let allScripts = definition_store_1.DefinitionStore.getDefinitions(_3_event_1.EventComponent);
|
|
51
|
-
let scriptTestingHelper = new script_testing_helper_1.ScriptTestingHelper(allScripts, scripting_setup_1.ScriptTestingInternal.eventSimulatorFunctionsConstructor, this.getLocationFinder());
|
|
52
|
-
let runtimeErrors = scriptTestingHelper.runTests(definitions.map(definition => ({
|
|
53
|
-
cases: definition.cases,
|
|
54
|
-
script: definition_store_1.DefinitionStore.getDefinitionOrFail(_3_event_1.EventComponent, definition.script),
|
|
55
|
-
scriptInput: scripting_setup_1.ScriptTestingInternal.getEventInput(definition.script),
|
|
56
|
-
testDefinitionRef: definition
|
|
57
|
-
})), output);
|
|
58
|
-
scriptTestingHelper.printErrors(runtimeErrors, output);
|
|
59
|
-
}
|
|
60
|
-
getLocationFinder() {
|
|
61
|
-
return {
|
|
62
|
-
getLocationOfDefinition: (key, path) => definition_store_1.DefinitionStore.getLocationInFileById(_3_event_1.EventComponent, key, path),
|
|
63
|
-
getLocationOfTestDefinition: (definition, path) => definition_store_1.DefinitionStore.getLocationInFile(EventTestComponent_1, definition, path)
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
exports.EventTestComponent = EventTestComponent;
|
|
68
|
-
exports.EventTestComponent = EventTestComponent = EventTestComponent_1 = __decorate([
|
|
69
|
-
(0, definition_component_1.DefinitionComponentDecorator)({
|
|
70
|
-
componentName: 'EVENT-TEST',
|
|
71
|
-
validationSchema: joi_1.default.object()
|
|
72
|
-
.keys({
|
|
73
|
-
event: joi_1.default.string().reference(_3_event_1.EventComponent).required(),
|
|
74
|
-
cases: joi_1.default.array()
|
|
75
|
-
.items(joi_1.default.object()
|
|
76
|
-
.keys({
|
|
77
|
-
actionsBeforeTesting: EventTestActionSchema().default([]).optional()
|
|
78
|
-
})
|
|
79
|
-
.required())
|
|
80
|
-
.required()
|
|
81
|
-
})
|
|
82
|
-
.required()
|
|
83
|
-
.custom(value => ({
|
|
84
|
-
script: value.event,
|
|
85
|
-
cases: value.cases
|
|
86
|
-
}))
|
|
87
|
-
})
|
|
88
|
-
], EventTestComponent);
|
|
89
|
-
//# sourceMappingURL=4-event-test.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ScriptEngineSimulatorFunctions } from 'script-engine-lib';
|
|
2
|
-
export declare class EventSetup {
|
|
3
|
-
private static _eventSimulatorFunctionsConstructor;
|
|
4
|
-
private static _richTextTags;
|
|
5
|
-
static get EventSimulatorFunctionsConstructor(): new (
|
|
6
|
-
...args: any[]
|
|
7
|
-
) => ScriptEngineSimulatorFunctions;
|
|
8
|
-
static get RichTextTags(): Set<string> | undefined;
|
|
9
|
-
static set(
|
|
10
|
-
eventSimulatorFunctionsConstructor: new (...args: any[]) => ScriptEngineSimulatorFunctions,
|
|
11
|
-
richTextTags: Set<string> | undefined
|
|
12
|
-
): void;
|
|
13
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
exports.EventSetup = void 0;
|
|
4
|
-
class EventSetup {
|
|
5
|
-
static get EventSimulatorFunctionsConstructor() {
|
|
6
|
-
if (!this._eventSimulatorFunctionsConstructor) {
|
|
7
|
-
throw new Error('EventSimulatorFunctionsConstructor is not set');
|
|
8
|
-
}
|
|
9
|
-
return this._eventSimulatorFunctionsConstructor;
|
|
10
|
-
}
|
|
11
|
-
static get RichTextTags() {
|
|
12
|
-
return this._richTextTags;
|
|
13
|
-
}
|
|
14
|
-
static set(eventSimulatorFunctionsConstructor, richTextTags) {
|
|
15
|
-
this._eventSimulatorFunctionsConstructor = eventSimulatorFunctionsConstructor;
|
|
16
|
-
this._richTextTags = richTextTags;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.EventSetup = EventSetup;
|
|
20
|
-
//# sourceMappingURL=event-setup.js.map
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QuotesToTagsHelper = void 0;
|
|
4
|
-
const script_engine_lib_1 = require("script-engine-lib");
|
|
5
|
-
const scripting_setup_1 = require("../scripting-setup");
|
|
6
|
-
class QuotesToTagsHelper {
|
|
7
|
-
static convert(text) {
|
|
8
|
-
let isInsideQuote = false;
|
|
9
|
-
let quoteIndex = text.indexOf('"');
|
|
10
|
-
while (quoteIndex >= 0) {
|
|
11
|
-
let tag = isInsideQuote ? '"</b>' : '<b>"';
|
|
12
|
-
text = text.substring(0, quoteIndex) + tag + text.substring(quoteIndex + 1);
|
|
13
|
-
isInsideQuote = !isInsideQuote;
|
|
14
|
-
quoteIndex = text.indexOf('"', quoteIndex + tag.length);
|
|
15
|
-
}
|
|
16
|
-
if (isInsideQuote) {
|
|
17
|
-
throw new Error('Quote is not closed.');
|
|
18
|
-
}
|
|
19
|
-
script_engine_lib_1.RichTextValidator.validate(text, scripting_setup_1.ScriptTestingInternal.richTextTags);
|
|
20
|
-
return text;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.QuotesToTagsHelper = QuotesToTagsHelper;
|
|
24
|
-
//# sourceMappingURL=quotes-to-tags.helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const vitest_1 = require("vitest");
|
|
4
|
-
const quotes_to_tags_helper_1 = require("./quotes-to-tags.helper");
|
|
5
|
-
(0, vitest_1.describe)('QuotesToTagsHelper', () => {
|
|
6
|
-
(0, vitest_1.test)('plane text', () => {
|
|
7
|
-
let text = '0123';
|
|
8
|
-
let result = quotes_to_tags_helper_1.QuotesToTagsHelper.convert(text);
|
|
9
|
-
(0, vitest_1.expect)(result).toBe('0123');
|
|
10
|
-
});
|
|
11
|
-
(0, vitest_1.test)('quote in text', () => {
|
|
12
|
-
let text = `"0123"0123`;
|
|
13
|
-
let result = quotes_to_tags_helper_1.QuotesToTagsHelper.convert(text);
|
|
14
|
-
(0, vitest_1.expect)(result).toBe('<b>"0123"</b>0123');
|
|
15
|
-
});
|
|
16
|
-
(0, vitest_1.test)('multiple quotes in text', () => {
|
|
17
|
-
let text = `"0123"0123"0123"0123`;
|
|
18
|
-
let result = quotes_to_tags_helper_1.QuotesToTagsHelper.convert(text);
|
|
19
|
-
(0, vitest_1.expect)(result).toBe('<b>"0123"</b>0123<b>"0123"</b>0123');
|
|
20
|
-
});
|
|
21
|
-
(0, vitest_1.test)('unclosed single quote', () => {
|
|
22
|
-
let text = `"0123`;
|
|
23
|
-
(0, vitest_1.expect)(() => quotes_to_tags_helper_1.QuotesToTagsHelper.convert(text)).toThrow('Quote is not closed.');
|
|
24
|
-
});
|
|
25
|
-
(0, vitest_1.test)('unclosed multiple quotes', () => {
|
|
26
|
-
let text = `"0123"0123"0123`;
|
|
27
|
-
(0, vitest_1.expect)(() => quotes_to_tags_helper_1.QuotesToTagsHelper.convert(text)).toThrow('Quote is not closed.');
|
|
28
|
-
});
|
|
29
|
-
(0, vitest_1.test)('use together with other tags', () => {
|
|
30
|
-
let text = `"0123"<r>0123</r>`;
|
|
31
|
-
let result = quotes_to_tags_helper_1.QuotesToTagsHelper.convert(text);
|
|
32
|
-
(0, vitest_1.expect)(result).toBe('<b>"0123"</b><r>0123</r>');
|
|
33
|
-
});
|
|
34
|
-
(0, vitest_1.test)('conflict with other tags', () => {
|
|
35
|
-
let text = `"0123<r>01"23</r>`;
|
|
36
|
-
(0, vitest_1.expect)(() => quotes_to_tags_helper_1.QuotesToTagsHelper.convert(text)).toThrow(`Mismatched tags: expected closing tag for 'r', but found 'b' at position`);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
//# sourceMappingURL=quotes-to-tags.helper.test.js.map
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ScriptDefinition, ScriptEngineSimulatorFunctions, ScriptTestActionDefinition } from 'script-engine-lib';
|
|
2
|
-
import { ErrorLog, LocationInFile, Output } from '../../../framework/interfaces';
|
|
3
|
-
export interface ScriptTestCasesDefinition {
|
|
4
|
-
readonly actionsBeforeTesting: readonly ScriptTestActionDefinition[];
|
|
5
|
-
}
|
|
6
|
-
export interface ScriptTestDefinition {
|
|
7
|
-
readonly script: string;
|
|
8
|
-
readonly cases: readonly ScriptTestCasesDefinition[];
|
|
9
|
-
}
|
|
10
|
-
export interface CustomScriptTestDefinition {
|
|
11
|
-
readonly testDefinition: ScriptTestDefinition;
|
|
12
|
-
readonly customMessage: string;
|
|
13
|
-
}
|
|
14
|
-
export interface ScriptTestFullDefinition<T> {
|
|
15
|
-
readonly script: ScriptDefinition;
|
|
16
|
-
readonly testDefinitionRef: T;
|
|
17
|
-
readonly scriptInput: any;
|
|
18
|
-
readonly customMessage?: string;
|
|
19
|
-
readonly cases: readonly ScriptTestCasesDefinition[];
|
|
20
|
-
}
|
|
21
|
-
export interface ScriptTestingLocationFinder<T> {
|
|
22
|
-
getLocationOfDefinition(key: string, path: readonly string[]): LocationInFile;
|
|
23
|
-
getLocationOfTestDefinition(definition: T, path: readonly string[]): LocationInFile;
|
|
24
|
-
}
|
|
25
|
-
export declare class ScriptTestingHelper<T> {
|
|
26
|
-
private functionsConstructor;
|
|
27
|
-
private locationFinder;
|
|
28
|
-
private scriptTestSimulator;
|
|
29
|
-
constructor(allScripts: ScriptDefinition[], functionsConstructor: new (input: any) => ScriptEngineSimulatorFunctions, locationFinder: ScriptTestingLocationFinder<T>);
|
|
30
|
-
runTests(testDefinitions: ScriptTestFullDefinition<T>[], output: Output): ErrorLog[];
|
|
31
|
-
printErrors(runtimeErrors: ErrorLog[], output: Output): void;
|
|
32
|
-
private prepareErrorLog;
|
|
33
|
-
}
|