@mirta/testing 0.4.4 → 0.4.6

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.
@@ -59,3 +59,39 @@ global.runRule = vi.fn();
59
59
  global.Notify = mock();
60
60
  // Мок сервиса оповещения.
61
61
  global.Alarms = mock();
62
+ // Реализация String.prototype.format для тестов
63
+ String.prototype.format = function (...args) {
64
+ let result = '';
65
+ let argIndex = 0;
66
+ const str = this;
67
+ // Шаг 1: парсим строку, заменяя {} и обрабатывая {{, }}
68
+ for (let i = 0; i < str.length; i++) {
69
+ if (str[i] === '{' && str[i + 1] === '{') {
70
+ result += '{';
71
+ i++;
72
+ continue;
73
+ }
74
+ if (str[i] === '}' && str[i + 1] === '}') {
75
+ result += '}';
76
+ i++;
77
+ continue;
78
+ }
79
+ if (str[i] === '{' && str[i + 1] === '}') {
80
+ result += argIndex < args.length ? String(args[argIndex++]) : '';
81
+ i++;
82
+ continue;
83
+ }
84
+ result += str[i];
85
+ }
86
+ // Шаг 2: добавляем лишние аргументы
87
+ if (argIndex < args.length) {
88
+ const rest = args.slice(argIndex).map(String).join(' ');
89
+ // Всегда добавляем пробел перед rest, даже если строка пустая
90
+ result += ' ' + rest;
91
+ }
92
+ return result;
93
+ };
94
+ String.prototype.xformat = function () {
95
+ throw new Error('string.xformat() is not allowed in tests. '
96
+ + 'Use string.format() or mock the result');
97
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mirta/testing",
3
3
  "description": "A unit-test runner equipped with built-in Wiren Board runtime emulation",
4
- "version": "0.4.4",
4
+ "version": "0.4.6",
5
5
  "license": "Unlicense",
6
6
  "keywords": [
7
7
  "mirta",
@@ -39,12 +39,12 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "vitest-mock-extended": "^3.1.0",
42
- "@mirta/env-loader": "0.4.4",
43
- "mirta": "0.4.4",
44
- "@mirta/workspace": "0.4.4"
42
+ "@mirta/env-loader": "0.4.6",
43
+ "mirta": "0.4.6",
44
+ "@mirta/workspace": "0.4.6"
45
45
  },
46
46
  "devDependencies": {
47
- "@mirta/rollup": "0.4.4"
47
+ "@mirta/rollup": "0.4.6"
48
48
  },
49
49
  "scripts": {
50
50
  "build:mono": "rollup -c"