@hodfords/nestjs-grpc-helper 11.4.0-rc.14 → 11.4.0-rc.15
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/helpers/mock.helper.js
CHANGED
|
@@ -6,16 +6,23 @@ const property_helper_1 = require("./property.helper");
|
|
|
6
6
|
const class_transformer_1 = require("class-transformer");
|
|
7
7
|
const faker_1 = require("@faker-js/faker");
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
|
+
function resolveType(type) {
|
|
10
|
+
if (typeof type === 'function' && type.name === 'type') {
|
|
11
|
+
return type();
|
|
12
|
+
}
|
|
13
|
+
return type;
|
|
14
|
+
}
|
|
9
15
|
function getData(option) {
|
|
10
16
|
const { mock } = option;
|
|
11
17
|
if (mock.sample) {
|
|
12
18
|
return mock.sample;
|
|
13
19
|
}
|
|
14
20
|
if (mock.nestedMaxSize) {
|
|
21
|
+
const resolvedType = resolveType(option.type);
|
|
15
22
|
if (option.isArray) {
|
|
16
|
-
return new Array(mock.nestedMaxSize).fill(0).map(() => sample(
|
|
23
|
+
return new Array(mock.nestedMaxSize).fill(0).map(() => sample(resolvedType));
|
|
17
24
|
}
|
|
18
|
-
return sample(
|
|
25
|
+
return sample(resolvedType);
|
|
19
26
|
}
|
|
20
27
|
if (mock.method && mock.method.startsWith('faker.')) {
|
|
21
28
|
const method = (0, lodash_1.get)({ faker: faker_1.faker }, mock.method);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.helper.js","sourceRoot":"","sources":["../../../lib/helpers/mock.helper.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"mock.helper.js","sourceRoot":"","sources":["../../../lib/helpers/mock.helper.ts"],"names":[],"mappings":";;AAiCA,oCAIC;AAED,wBAWC;AAlDD,uDAAyD;AACzD,yDAAoD;AACpD,2CAAwC;AACxC,mCAA6B;AAI7B,SAAS,WAAW,CAAC,IAAS;IAC1B,IAAI,OAAO,IAAI,K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