@o3r/testing 14.4.0-prerelease.22 → 14.4.0-prerelease.23
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/package.json +25 -11
- package/transloco/index.d.ts +2 -0
- package/transloco/index.d.ts.map +1 -0
- package/transloco/index.js +5 -0
- package/transloco/index.js.map +1 -0
- package/transloco/transloco-mock.d.ts +40 -0
- package/transloco/transloco-mock.d.ts.map +1 -0
- package/transloco/transloco-mock.js +71 -0
- package/transloco/transloco-mock.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/testing",
|
|
3
|
-
"version": "14.4.0-prerelease.
|
|
3
|
+
"version": "14.4.0-prerelease.23",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -56,6 +56,10 @@
|
|
|
56
56
|
"types": "./localization/index.d.ts",
|
|
57
57
|
"default": "./localization/index.js"
|
|
58
58
|
},
|
|
59
|
+
"./transloco": {
|
|
60
|
+
"types": "./transloco/index.d.ts",
|
|
61
|
+
"default": "./transloco/index.js"
|
|
62
|
+
},
|
|
59
63
|
"./mocks": {
|
|
60
64
|
"types": "./mocks/index.d.ts",
|
|
61
65
|
"default": "./mocks/index.js"
|
|
@@ -96,13 +100,15 @@
|
|
|
96
100
|
"@angular/core": "^21.0.0",
|
|
97
101
|
"@angular/forms": "^21.0.0",
|
|
98
102
|
"@angular/platform-browser": "^21.0.0",
|
|
103
|
+
"@jsverse/transloco": "^8.0.0",
|
|
99
104
|
"@material/slider": "^14.0.0",
|
|
100
105
|
"@ngrx/store": "^21.0.0",
|
|
101
106
|
"@ngx-translate/core": "^15.0.0 || ~16.0.4",
|
|
102
|
-
"@o3r/core": "~14.4.0-prerelease.
|
|
103
|
-
"@o3r/eslint-config": "~14.4.0-prerelease.
|
|
104
|
-
"@o3r/localization": "~14.4.0-prerelease.
|
|
105
|
-
"@o3r/schematics": "~14.4.0-prerelease.
|
|
107
|
+
"@o3r/core": "~14.4.0-prerelease.23",
|
|
108
|
+
"@o3r/eslint-config": "~14.4.0-prerelease.23",
|
|
109
|
+
"@o3r/localization": "~14.4.0-prerelease.23",
|
|
110
|
+
"@o3r/schematics": "~14.4.0-prerelease.23",
|
|
111
|
+
"@o3r/transloco": "~14.4.0-prerelease.23",
|
|
106
112
|
"@playwright/test": "^1.49.0",
|
|
107
113
|
"@schematics/angular": "^21.0.0",
|
|
108
114
|
"eslint": "~9.39.0",
|
|
@@ -129,6 +135,9 @@
|
|
|
129
135
|
"@angular/forms": {
|
|
130
136
|
"optional": true
|
|
131
137
|
},
|
|
138
|
+
"@jsverse/transloco": {
|
|
139
|
+
"optional": true
|
|
140
|
+
},
|
|
132
141
|
"@material/slider": {
|
|
133
142
|
"optional": true
|
|
134
143
|
},
|
|
@@ -150,6 +159,9 @@
|
|
|
150
159
|
"@o3r/schematics": {
|
|
151
160
|
"optional": true
|
|
152
161
|
},
|
|
162
|
+
"@o3r/transloco": {
|
|
163
|
+
"optional": true
|
|
164
|
+
},
|
|
153
165
|
"@playwright/test": {
|
|
154
166
|
"optional": true
|
|
155
167
|
},
|
|
@@ -170,7 +182,7 @@
|
|
|
170
182
|
}
|
|
171
183
|
},
|
|
172
184
|
"dependencies": {
|
|
173
|
-
"@o3r/schematics": "~14.4.0-prerelease.
|
|
185
|
+
"@o3r/schematics": "~14.4.0-prerelease.23",
|
|
174
186
|
"esbuild": "~0.27.0",
|
|
175
187
|
"tslib": "^2.6.2"
|
|
176
188
|
},
|
|
@@ -191,16 +203,18 @@
|
|
|
191
203
|
"@babel/preset-typescript": "~7.29.0",
|
|
192
204
|
"@compodoc/compodoc": "^1.1.32",
|
|
193
205
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
|
|
206
|
+
"@jsverse/transloco": "~8.2.1",
|
|
194
207
|
"@material/slider": "^14.0.0",
|
|
195
208
|
"@ngrx/store": "~21.1.0",
|
|
196
209
|
"@ngx-translate/core": "~16.0.4",
|
|
197
210
|
"@nx/eslint-plugin": "~22.7.0",
|
|
198
211
|
"@nx/jest": "~22.7.0",
|
|
199
|
-
"@o3r/build-helpers": "~14.4.0-prerelease.
|
|
200
|
-
"@o3r/core": "~14.4.0-prerelease.
|
|
201
|
-
"@o3r/eslint-plugin": "~14.4.0-prerelease.
|
|
202
|
-
"@o3r/localization": "~14.4.0-prerelease.
|
|
203
|
-
"@o3r/test-helpers": "~14.4.0-prerelease.
|
|
212
|
+
"@o3r/build-helpers": "~14.4.0-prerelease.23",
|
|
213
|
+
"@o3r/core": "~14.4.0-prerelease.23",
|
|
214
|
+
"@o3r/eslint-plugin": "~14.4.0-prerelease.23",
|
|
215
|
+
"@o3r/localization": "~14.4.0-prerelease.23",
|
|
216
|
+
"@o3r/test-helpers": "~14.4.0-prerelease.23",
|
|
217
|
+
"@o3r/transloco": "~14.4.0-prerelease.23",
|
|
204
218
|
"@playwright/test": "~1.60.0",
|
|
205
219
|
"@schematics/angular": "~21.2.0",
|
|
206
220
|
"@standard-schema/spec": "~1.1.0",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transloco/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transloco/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC","sourcesContent":["export * from './transloco-mock';\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { EnvironmentProviders, PipeTransform, Provider } from '@angular/core';
|
|
2
|
+
import { LocalizationConfiguration } from '@o3r/transloco';
|
|
3
|
+
/**
|
|
4
|
+
* Mock translations interface to provide to the mock localization provider
|
|
5
|
+
*/
|
|
6
|
+
export interface MockTranslations {
|
|
7
|
+
/** Language code mapped to its translation key-value pairs */
|
|
8
|
+
[lang: string]: {
|
|
9
|
+
/** Translation key mapped to its translated value */
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Mock pipe for transloco (from \@jsverse/transloco)
|
|
15
|
+
*/
|
|
16
|
+
export declare class TranslocoPipeMock implements PipeTransform {
|
|
17
|
+
/**
|
|
18
|
+
* Transform method for the mock pipe
|
|
19
|
+
* @param args Arguments passed to the pipe
|
|
20
|
+
*/
|
|
21
|
+
transform(...args: any[]): string | undefined;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Mock pipe for o3rTranslate
|
|
25
|
+
*/
|
|
26
|
+
export declare class O3rTranslatePipeMock implements PipeTransform {
|
|
27
|
+
/**
|
|
28
|
+
* Transform method for the mock pipe
|
|
29
|
+
* @param args Arguments passed to the pipe
|
|
30
|
+
*/
|
|
31
|
+
transform(...args: any[]): string | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Provides mock localization configuration for testing
|
|
35
|
+
* @param localizationConfiguration Localization configuration
|
|
36
|
+
* @param translations Translations to use
|
|
37
|
+
* @returns List of providers for the TestBed
|
|
38
|
+
*/
|
|
39
|
+
export declare function provideLocalizationMock(localizationConfiguration?: Partial<LocalizationConfiguration>, translations?: MockTranslations): (Provider | EnvironmentProviders)[];
|
|
40
|
+
//# sourceMappingURL=transloco-mock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transloco-mock.d.ts","sourceRoot":"","sources":["../../src/transloco/transloco-mock.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAEpB,aAAa,EACb,QAAQ,EACT,MAAM,eAAe,CAAC;AAIvB,OAAO,EACL,yBAAyB,EAE1B,MAAM,gBAAgB,CAAC;AAcxB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,CAAC,IAAI,EAAE,MAAM,GAAG;QACd,qDAAqD;QACrD,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED;;GAEG;AACH,qBAIa,iBAAkB,YAAW,aAAa;IACrD;;;OAGG;IACI,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,GAAG,SAAS;CAGrD;AAED;;GAEG;AACH,qBAIa,oBAAqB,YAAW,aAAa;IACxD;;;OAGG;IACI,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,GAAG,SAAS;CAGrD;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,yBAAyB,GAAE,OAAO,CAAC,yBAAyB,CAAoC,EAChG,YAAY,GAAE,gBAAqB,GAClC,CAAC,QAAQ,GAAG,oBAAoB,CAAC,EAAE,CASrC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.O3rTranslatePipeMock = exports.TranslocoPipeMock = void 0;
|
|
4
|
+
exports.provideLocalizationMock = provideLocalizationMock;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const core_1 = require("@angular/core");
|
|
7
|
+
const transloco_1 = require("@jsverse/transloco");
|
|
8
|
+
const transloco_2 = require("@o3r/transloco");
|
|
9
|
+
const rxjs_1 = require("rxjs");
|
|
10
|
+
/**
|
|
11
|
+
* Default localization configuration for testing
|
|
12
|
+
*/
|
|
13
|
+
const defaultLocalizationConfiguration = {
|
|
14
|
+
supportedLocales: ['en'],
|
|
15
|
+
language: 'en',
|
|
16
|
+
fallbackLanguage: 'en'
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Mock pipe for transloco (from \@jsverse/transloco)
|
|
20
|
+
*/
|
|
21
|
+
let TranslocoPipeMock = class TranslocoPipeMock {
|
|
22
|
+
/**
|
|
23
|
+
* Transform method for the mock pipe
|
|
24
|
+
* @param args Arguments passed to the pipe
|
|
25
|
+
*/
|
|
26
|
+
transform(...args) {
|
|
27
|
+
return args && args.map((arg) => JSON.stringify(arg)).join(', ');
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.TranslocoPipeMock = TranslocoPipeMock;
|
|
31
|
+
exports.TranslocoPipeMock = TranslocoPipeMock = tslib_1.__decorate([
|
|
32
|
+
(0, core_1.Pipe)({
|
|
33
|
+
name: 'transloco',
|
|
34
|
+
standalone: true
|
|
35
|
+
})
|
|
36
|
+
], TranslocoPipeMock);
|
|
37
|
+
/**
|
|
38
|
+
* Mock pipe for o3rTranslate
|
|
39
|
+
*/
|
|
40
|
+
let O3rTranslatePipeMock = class O3rTranslatePipeMock {
|
|
41
|
+
/**
|
|
42
|
+
* Transform method for the mock pipe
|
|
43
|
+
* @param args Arguments passed to the pipe
|
|
44
|
+
*/
|
|
45
|
+
transform(...args) {
|
|
46
|
+
return args && args.map((arg) => JSON.stringify(arg)).join(', ');
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.O3rTranslatePipeMock = O3rTranslatePipeMock;
|
|
50
|
+
exports.O3rTranslatePipeMock = O3rTranslatePipeMock = tslib_1.__decorate([
|
|
51
|
+
(0, core_1.Pipe)({
|
|
52
|
+
name: 'o3rTranslate',
|
|
53
|
+
standalone: true
|
|
54
|
+
})
|
|
55
|
+
], O3rTranslatePipeMock);
|
|
56
|
+
/**
|
|
57
|
+
* Provides mock localization configuration for testing
|
|
58
|
+
* @param localizationConfiguration Localization configuration
|
|
59
|
+
* @param translations Translations to use
|
|
60
|
+
* @returns List of providers for the TestBed
|
|
61
|
+
*/
|
|
62
|
+
function provideLocalizationMock(localizationConfiguration = defaultLocalizationConfiguration, translations = {}) {
|
|
63
|
+
const providers = [
|
|
64
|
+
{ provide: transloco_1.TRANSLOCO_LOADER, useValue: { getTranslation: (lang) => (0, rxjs_1.of)(translations[lang]) } }
|
|
65
|
+
];
|
|
66
|
+
return [
|
|
67
|
+
(0, transloco_2.provideLocalization)(localizationConfiguration),
|
|
68
|
+
...providers
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=transloco-mock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transloco-mock.js","sourceRoot":"","sources":["../../src/transloco/transloco-mock.ts"],"names":[],"mappings":";;;AA6EA,0DAYC;;AAzFD,wCAKuB;AACvB,kDAE4B;AAC5B,8CAGwB;AACxB,+BAEc;AAEd;;GAEG;AACH,MAAM,gCAAgC,GAAG;IACvC,gBAAgB,EAAE,CAAC,IAAI,CAAC;IACxB,QAAQ,EAAE,IAAI;IACd,gBAAgB,EAAE,IAAI;CAC+B,CAAC;AAaxD;;GAEG;AAKI,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B;;;OAGG;IACI,SAAS,CAAC,GAAG,IAAW;QAC7B,OAAO,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnE,CAAC;CACF,CAAA;AARY,8CAAiB;4BAAjB,iBAAiB;IAJ7B,IAAA,WAAI,EAAC;QACJ,IAAI,EAAE,WAAW;QACjB,UAAU,EAAE,IAAI;KACjB,CAAC;GACW,iBAAiB,CAQ7B;AAED;;GAEG;AAKI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B;;;OAGG;IACI,SAAS,CAAC,GAAG,IAAW;QAC7B,OAAO,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnE,CAAC;CACF,CAAA;AARY,oDAAoB;+BAApB,oBAAoB;IAJhC,IAAA,WAAI,EAAC;QACJ,IAAI,EAAE,cAAc;QACpB,UAAU,EAAE,IAAI;KACjB,CAAC;GACW,oBAAoB,CAQhC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CACrC,4BAAgE,gCAAgC,EAChG,eAAiC,EAAE;IAEnC,MAAM,SAAS,GAAe;QAC5B,EAAE,OAAO,EAAE,4BAAgB,EAAE,QAAQ,EAAE,EAAE,cAAc,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,SAAE,EAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE;KACtG,CAAC;IAEF,OAAO;QACL,IAAA,+BAAmB,EAAC,yBAAyB,CAAC;QAC9C,GAAG,SAAS;KACb,CAAC;AACJ,CAAC","sourcesContent":["import {\n EnvironmentProviders,\n Pipe,\n PipeTransform,\n Provider,\n} from '@angular/core';\nimport {\n TRANSLOCO_LOADER,\n} from '@jsverse/transloco';\nimport {\n LocalizationConfiguration,\n provideLocalization,\n} from '@o3r/transloco';\nimport {\n of,\n} from 'rxjs';\n\n/**\n * Default localization configuration for testing\n */\nconst defaultLocalizationConfiguration = {\n supportedLocales: ['en'],\n language: 'en',\n fallbackLanguage: 'en'\n} as const satisfies Partial<LocalizationConfiguration>;\n\n/**\n * Mock translations interface to provide to the mock localization provider\n */\nexport interface MockTranslations {\n /** Language code mapped to its translation key-value pairs */\n [lang: string]: {\n /** Translation key mapped to its translated value */\n [key: string]: any;\n };\n}\n\n/**\n * Mock pipe for transloco (from \\@jsverse/transloco)\n */\n@Pipe({\n name: 'transloco',\n standalone: true\n})\nexport class TranslocoPipeMock implements PipeTransform {\n /**\n * Transform method for the mock pipe\n * @param args Arguments passed to the pipe\n */\n public transform(...args: any[]): string | undefined {\n return args && args.map((arg) => JSON.stringify(arg)).join(', ');\n }\n}\n\n/**\n * Mock pipe for o3rTranslate\n */\n@Pipe({\n name: 'o3rTranslate',\n standalone: true\n})\nexport class O3rTranslatePipeMock implements PipeTransform {\n /**\n * Transform method for the mock pipe\n * @param args Arguments passed to the pipe\n */\n public transform(...args: any[]): string | undefined {\n return args && args.map((arg) => JSON.stringify(arg)).join(', ');\n }\n}\n\n/**\n * Provides mock localization configuration for testing\n * @param localizationConfiguration Localization configuration\n * @param translations Translations to use\n * @returns List of providers for the TestBed\n */\nexport function provideLocalizationMock(\n localizationConfiguration: Partial<LocalizationConfiguration> = defaultLocalizationConfiguration,\n translations: MockTranslations = {}\n): (Provider | EnvironmentProviders)[] {\n const providers: Provider[] = [\n { provide: TRANSLOCO_LOADER, useValue: { getTranslation: (lang: string) => of(translations[lang]) } }\n ];\n\n return [\n provideLocalization(localizationConfiguration),\n ...providers\n ];\n}\n"]}
|