@coderzz/mocker-data-generator 3.0.5 → 3.0.7
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/CHANGELOG.md +43 -0
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/build/main/array-includes.d.ts +0 -0
- package/build/main/array-includes.js +45 -45
- package/build/main/index.d.ts +7 -7
- package/build/main/index.js +12 -12
- package/build/main/index.spec.d.ts +1 -1
- package/build/main/index.spec.js +16 -16
- package/build/main/lib/Generator.d.ts +61 -61
- package/build/main/lib/Generator.js +134 -134
- package/build/main/lib/Mocker.d.ts +22 -22
- package/build/main/lib/Mocker.js +76 -76
- package/build/main/lib/Schema.d.ts +9 -9
- package/build/main/lib/Schema.js +210 -210
- package/build/main/lib/types.d.ts +8 -8
- package/build/main/lib/types.js +2 -2
- package/build/main/lib/utils.d.ts +10 -10
- package/build/main/lib/utils.js +222 -222
- package/build/main/tests/Generator.db.spec.d.ts +1 -1
- package/build/main/tests/Generator.db.spec.js +33 -33
- package/build/main/tests/Generator.eval.spec.d.ts +1 -1
- package/build/main/tests/Generator.eval.spec.js +21 -21
- package/build/main/tests/Generator.function.spec.d.ts +1 -1
- package/build/main/tests/Generator.function.spec.js +48 -48
- package/build/main/tests/Generator.generator.spec.d.ts +1 -1
- package/build/main/tests/Generator.generator.spec.js +187 -187
- package/build/main/tests/Generator.hasMany.spec.d.ts +1 -1
- package/build/main/tests/Generator.hasMany.spec.js +115 -115
- package/build/main/tests/Generator.hasOne.spec.d.ts +1 -1
- package/build/main/tests/Generator.hasOne.spec.js +146 -146
- package/build/main/tests/Generator.incrementalId.spec.d.ts +1 -1
- package/build/main/tests/Generator.incrementalId.spec.js +26 -26
- package/build/main/tests/Generator.self.spec.d.ts +1 -1
- package/build/main/tests/Generator.self.spec.js +24 -24
- package/build/main/tests/Generator.static.spec.d.ts +1 -1
- package/build/main/tests/Generator.static.spec.js +15 -15
- package/build/main/tests/Generator.values.spec.d.ts +1 -1
- package/build/main/tests/Generator.values.spec.js +16 -16
- package/build/main/tests/Mocker.build.spec.d.ts +1 -1
- package/build/main/tests/Mocker.build.spec.js +196 -196
- package/build/main/tests/Mocker.reset.spec.d.ts +1 -1
- package/build/main/tests/Mocker.reset.spec.js +17 -17
- package/build/main/tests/Mocker.restart.spec.d.ts +1 -1
- package/build/main/tests/Mocker.restart.spec.js +24 -24
- package/build/main/tests/Mocker.schema.spec.d.ts +1 -1
- package/build/main/tests/Mocker.schema.spec.js +18 -18
- package/build/main/tests/Mocker.seed.spec.d.ts +1 -1
- package/build/main/tests/Mocker.seed.spec.js +42 -42
- package/build/main/tests/Schema.Array.spec.d.ts +1 -1
- package/build/main/tests/Schema.Array.spec.js +332 -332
- package/build/main/tests/Schema.BuildSingle.spec.d.ts +1 -1
- package/build/main/tests/Schema.BuildSingle.spec.js +13 -13
- package/build/main/tests/mocker.spec.d.ts +1 -1
- package/build/main/tests/mocker.spec.js +405 -405
- package/build/module/array-includes.js +45 -45
- package/build/module/index.js +7 -7
- package/build/module/lib/Generator.js +131 -131
- package/build/module/lib/Mocker.js +73 -73
- package/build/module/lib/Schema.js +207 -207
- package/build/module/lib/types.js +1 -1
- package/build/module/lib/utils.js +209 -209
- package/package.json +1 -1
@@ -1,115 +1,115 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
var tslib_1 = require("tslib");
|
4
|
-
var ava_1 = require("ava");
|
5
|
-
var __1 = require("..");
|
6
|
-
var gen = new __1.Generator();
|
7
|
-
(0, ava_1.default)('Should get many from the DB with max', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
8
|
-
var data, res;
|
9
|
-
return tslib_1.__generator(this, function (_a) {
|
10
|
-
data = Array.from(new Array(10)).map(function (el, i) { return ({ id: i }); });
|
11
|
-
gen.DB = { hello: data };
|
12
|
-
res = gen.hasMany({
|
13
|
-
hasMany: 'hello',
|
14
|
-
max: 2
|
15
|
-
});
|
16
|
-
res.forEach(function (r) { return t.true(data.indexOf(r) > -1); });
|
17
|
-
t.true(res.length <= 2);
|
18
|
-
t.true(res.length >= 1);
|
19
|
-
return [2 /*return*/];
|
20
|
-
});
|
21
|
-
}); });
|
22
|
-
(0, ava_1.default)('Should get many from the DB with min', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
23
|
-
var data, res;
|
24
|
-
return tslib_1.__generator(this, function (_a) {
|
25
|
-
data = Array.from(new Array(10)).map(function (el, i) { return ({ id: i }); });
|
26
|
-
gen.DB = { hello: data };
|
27
|
-
res = gen.hasMany({
|
28
|
-
hasMany: 'hello',
|
29
|
-
max: 10,
|
30
|
-
min: 4
|
31
|
-
});
|
32
|
-
res.forEach(function (r) { return t.true(data.indexOf(r) > -1); });
|
33
|
-
t.true(res.length <= 10);
|
34
|
-
t.true(res.length >= 4);
|
35
|
-
return [2 /*return*/];
|
36
|
-
});
|
37
|
-
}); });
|
38
|
-
(0, ava_1.default)('Should get many from the DB with min = 0', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
39
|
-
var data, res;
|
40
|
-
return tslib_1.__generator(this, function (_a) {
|
41
|
-
data = Array.from(new Array(10)).map(function (el, i) { return ({ id: i }); });
|
42
|
-
gen.DB = { hello: data };
|
43
|
-
res = gen.hasMany({
|
44
|
-
hasMany: 'hello',
|
45
|
-
max: 1,
|
46
|
-
min: 0
|
47
|
-
});
|
48
|
-
res.forEach(function (r) { return t.true(data.indexOf(r) > -1); });
|
49
|
-
t.true(res.length <= 1);
|
50
|
-
t.true(res.length >= 0);
|
51
|
-
return [2 /*return*/];
|
52
|
-
});
|
53
|
-
}); });
|
54
|
-
(0, ava_1.default)('Should get many from the DB with fixed amount', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
55
|
-
var data, res;
|
56
|
-
return tslib_1.__generator(this, function (_a) {
|
57
|
-
data = Array.from(new Array(10)).map(function (el, i) { return ({ id: i }); });
|
58
|
-
gen.DB = { hello: data };
|
59
|
-
res = gen.hasMany({
|
60
|
-
hasMany: 'hello',
|
61
|
-
amount: 5
|
62
|
-
});
|
63
|
-
res.forEach(function (r) { return t.true(data.indexOf(r) > -1); });
|
64
|
-
t.true(res.length === 5);
|
65
|
-
return [2 /*return*/];
|
66
|
-
});
|
67
|
-
}); });
|
68
|
-
(0, ava_1.default)('Should get many from the DB, and one field of each entity', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
69
|
-
var data, res;
|
70
|
-
return tslib_1.__generator(this, function (_a) {
|
71
|
-
data = Array.from(new Array(10)).map(function (el, i) { return ({ id: i }); });
|
72
|
-
gen.DB = { hello: data };
|
73
|
-
res = gen.hasMany({
|
74
|
-
hasMany: 'hello',
|
75
|
-
get: 'id',
|
76
|
-
amount: 1
|
77
|
-
});
|
78
|
-
t.true(typeof res[0] === 'number');
|
79
|
-
return [2 /*return*/];
|
80
|
-
});
|
81
|
-
}); });
|
82
|
-
(0, ava_1.default)('Should get many from the DB, unique', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
83
|
-
var data, res;
|
84
|
-
return tslib_1.__generator(this, function (_a) {
|
85
|
-
data = Array.from(new Array(2)).map(function (el, i) { return ({ id: i }); });
|
86
|
-
gen.DB = { hello: data };
|
87
|
-
res = gen.hasMany({
|
88
|
-
hasMany: 'hello',
|
89
|
-
get: 'id',
|
90
|
-
amount: 2,
|
91
|
-
unique: true
|
92
|
-
});
|
93
|
-
t.deepEqual(res, [0, 1]);
|
94
|
-
return [2 /*return*/];
|
95
|
-
});
|
96
|
-
}); });
|
97
|
-
(0, ava_1.default)('Should throw an error, not enough unique data', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
98
|
-
var data, res;
|
99
|
-
return tslib_1.__generator(this, function (_a) {
|
100
|
-
data = Array.from(new Array(2)).map(function (el, i) { return ({ id: i }); });
|
101
|
-
gen.DB = { hello: data };
|
102
|
-
try {
|
103
|
-
res = gen.hasMany({
|
104
|
-
hasMany: 'hello',
|
105
|
-
get: 'id',
|
106
|
-
amount: 3,
|
107
|
-
unique: true
|
108
|
-
});
|
109
|
-
}
|
110
|
-
catch (e) {
|
111
|
-
t.deepEqual(e, 'Can´t get unique data. Source "hello" has not enough data');
|
112
|
-
}
|
113
|
-
return [2 /*return*/];
|
114
|
-
});
|
115
|
-
}); });
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
var tslib_1 = require("tslib");
|
4
|
+
var ava_1 = require("ava");
|
5
|
+
var __1 = require("..");
|
6
|
+
var gen = new __1.Generator();
|
7
|
+
(0, ava_1.default)('Should get many from the DB with max', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
8
|
+
var data, res;
|
9
|
+
return tslib_1.__generator(this, function (_a) {
|
10
|
+
data = Array.from(new Array(10)).map(function (el, i) { return ({ id: i }); });
|
11
|
+
gen.DB = { hello: data };
|
12
|
+
res = gen.hasMany({
|
13
|
+
hasMany: 'hello',
|
14
|
+
max: 2
|
15
|
+
});
|
16
|
+
res.forEach(function (r) { return t.true(data.indexOf(r) > -1); });
|
17
|
+
t.true(res.length <= 2);
|
18
|
+
t.true(res.length >= 1);
|
19
|
+
return [2 /*return*/];
|
20
|
+
});
|
21
|
+
}); });
|
22
|
+
(0, ava_1.default)('Should get many from the DB with min', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
23
|
+
var data, res;
|
24
|
+
return tslib_1.__generator(this, function (_a) {
|
25
|
+
data = Array.from(new Array(10)).map(function (el, i) { return ({ id: i }); });
|
26
|
+
gen.DB = { hello: data };
|
27
|
+
res = gen.hasMany({
|
28
|
+
hasMany: 'hello',
|
29
|
+
max: 10,
|
30
|
+
min: 4
|
31
|
+
});
|
32
|
+
res.forEach(function (r) { return t.true(data.indexOf(r) > -1); });
|
33
|
+
t.true(res.length <= 10);
|
34
|
+
t.true(res.length >= 4);
|
35
|
+
return [2 /*return*/];
|
36
|
+
});
|
37
|
+
}); });
|
38
|
+
(0, ava_1.default)('Should get many from the DB with min = 0', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
39
|
+
var data, res;
|
40
|
+
return tslib_1.__generator(this, function (_a) {
|
41
|
+
data = Array.from(new Array(10)).map(function (el, i) { return ({ id: i }); });
|
42
|
+
gen.DB = { hello: data };
|
43
|
+
res = gen.hasMany({
|
44
|
+
hasMany: 'hello',
|
45
|
+
max: 1,
|
46
|
+
min: 0
|
47
|
+
});
|
48
|
+
res.forEach(function (r) { return t.true(data.indexOf(r) > -1); });
|
49
|
+
t.true(res.length <= 1);
|
50
|
+
t.true(res.length >= 0);
|
51
|
+
return [2 /*return*/];
|
52
|
+
});
|
53
|
+
}); });
|
54
|
+
(0, ava_1.default)('Should get many from the DB with fixed amount', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
55
|
+
var data, res;
|
56
|
+
return tslib_1.__generator(this, function (_a) {
|
57
|
+
data = Array.from(new Array(10)).map(function (el, i) { return ({ id: i }); });
|
58
|
+
gen.DB = { hello: data };
|
59
|
+
res = gen.hasMany({
|
60
|
+
hasMany: 'hello',
|
61
|
+
amount: 5
|
62
|
+
});
|
63
|
+
res.forEach(function (r) { return t.true(data.indexOf(r) > -1); });
|
64
|
+
t.true(res.length === 5);
|
65
|
+
return [2 /*return*/];
|
66
|
+
});
|
67
|
+
}); });
|
68
|
+
(0, ava_1.default)('Should get many from the DB, and one field of each entity', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
69
|
+
var data, res;
|
70
|
+
return tslib_1.__generator(this, function (_a) {
|
71
|
+
data = Array.from(new Array(10)).map(function (el, i) { return ({ id: i }); });
|
72
|
+
gen.DB = { hello: data };
|
73
|
+
res = gen.hasMany({
|
74
|
+
hasMany: 'hello',
|
75
|
+
get: 'id',
|
76
|
+
amount: 1
|
77
|
+
});
|
78
|
+
t.true(typeof res[0] === 'number');
|
79
|
+
return [2 /*return*/];
|
80
|
+
});
|
81
|
+
}); });
|
82
|
+
(0, ava_1.default)('Should get many from the DB, unique', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
83
|
+
var data, res;
|
84
|
+
return tslib_1.__generator(this, function (_a) {
|
85
|
+
data = Array.from(new Array(2)).map(function (el, i) { return ({ id: i }); });
|
86
|
+
gen.DB = { hello: data };
|
87
|
+
res = gen.hasMany({
|
88
|
+
hasMany: 'hello',
|
89
|
+
get: 'id',
|
90
|
+
amount: 2,
|
91
|
+
unique: true
|
92
|
+
});
|
93
|
+
t.deepEqual(res, [0, 1]);
|
94
|
+
return [2 /*return*/];
|
95
|
+
});
|
96
|
+
}); });
|
97
|
+
(0, ava_1.default)('Should throw an error, not enough unique data', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
98
|
+
var data, res;
|
99
|
+
return tslib_1.__generator(this, function (_a) {
|
100
|
+
data = Array.from(new Array(2)).map(function (el, i) { return ({ id: i }); });
|
101
|
+
gen.DB = { hello: data };
|
102
|
+
try {
|
103
|
+
res = gen.hasMany({
|
104
|
+
hasMany: 'hello',
|
105
|
+
get: 'id',
|
106
|
+
amount: 3,
|
107
|
+
unique: true
|
108
|
+
});
|
109
|
+
}
|
110
|
+
catch (e) {
|
111
|
+
t.deepEqual(e, 'Can´t get unique data. Source "hello" has not enough data');
|
112
|
+
}
|
113
|
+
return [2 /*return*/];
|
114
|
+
});
|
115
|
+
}); });
|
@@ -1 +1 @@
|
|
1
|
-
export {};
|
1
|
+
export {};
|
@@ -1,146 +1,146 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
var tslib_1 = require("tslib");
|
4
|
-
var ava_1 = require("ava");
|
5
|
-
var __1 = require("..");
|
6
|
-
var gen = new __1.Generator();
|
7
|
-
var set1 = [
|
8
|
-
{
|
9
|
-
id: 0
|
10
|
-
},
|
11
|
-
{
|
12
|
-
id: 1
|
13
|
-
},
|
14
|
-
{
|
15
|
-
id: 2
|
16
|
-
},
|
17
|
-
{
|
18
|
-
id: 3
|
19
|
-
},
|
20
|
-
{
|
21
|
-
id: 4
|
22
|
-
},
|
23
|
-
{
|
24
|
-
id: 5
|
25
|
-
},
|
26
|
-
{
|
27
|
-
id: 6
|
28
|
-
},
|
29
|
-
{
|
30
|
-
id: 7
|
31
|
-
},
|
32
|
-
{
|
33
|
-
id: 8
|
34
|
-
},
|
35
|
-
{
|
36
|
-
id: 9
|
37
|
-
}
|
38
|
-
];
|
39
|
-
var set2 = [
|
40
|
-
{
|
41
|
-
id: {
|
42
|
-
id: 0
|
43
|
-
}
|
44
|
-
},
|
45
|
-
{
|
46
|
-
id: {
|
47
|
-
id: 1
|
48
|
-
}
|
49
|
-
},
|
50
|
-
{
|
51
|
-
id: {
|
52
|
-
id: 2
|
53
|
-
}
|
54
|
-
},
|
55
|
-
{
|
56
|
-
id: {
|
57
|
-
id: 3
|
58
|
-
}
|
59
|
-
},
|
60
|
-
{
|
61
|
-
id: {
|
62
|
-
id: 4
|
63
|
-
}
|
64
|
-
},
|
65
|
-
{
|
66
|
-
id: {
|
67
|
-
id: 5
|
68
|
-
}
|
69
|
-
},
|
70
|
-
{
|
71
|
-
id: {
|
72
|
-
id: 6
|
73
|
-
}
|
74
|
-
},
|
75
|
-
{
|
76
|
-
id: {
|
77
|
-
id: 7
|
78
|
-
}
|
79
|
-
},
|
80
|
-
{
|
81
|
-
id: {
|
82
|
-
id: 8
|
83
|
-
}
|
84
|
-
},
|
85
|
-
{
|
86
|
-
id: {
|
87
|
-
id: 9
|
88
|
-
}
|
89
|
-
}
|
90
|
-
];
|
91
|
-
(0, ava_1.default)('Should get one of the DB', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
92
|
-
var res;
|
93
|
-
return tslib_1.__generator(this, function (_a) {
|
94
|
-
gen.DB = { hello: set1 };
|
95
|
-
res = gen.hasOne({ hasOne: 'hello' });
|
96
|
-
t.true(set1.indexOf(res) > -1);
|
97
|
-
return [2 /*return*/];
|
98
|
-
});
|
99
|
-
}); });
|
100
|
-
(0, ava_1.default)('Should get one of the DB, and one field of that entity (eval)', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
101
|
-
var res;
|
102
|
-
return tslib_1.__generator(this, function (_a) {
|
103
|
-
gen.DB = {
|
104
|
-
hello: set1
|
105
|
-
};
|
106
|
-
res = gen.hasOne({ hasOne: 'hello', get: 'id', eval: true });
|
107
|
-
t.true(res !== undefined);
|
108
|
-
t.true(res !== null);
|
109
|
-
t.true(res === 0 || (res && res <= 10));
|
110
|
-
t.true(res === 0 || (res && res >= 0));
|
111
|
-
return [2 /*return*/];
|
112
|
-
});
|
113
|
-
}); });
|
114
|
-
(0, ava_1.default)('Should get one of the DB, and one field of that entity (no-eval)', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
115
|
-
var res;
|
116
|
-
return tslib_1.__generator(this, function (_a) {
|
117
|
-
gen.DB = {
|
118
|
-
hello: set1
|
119
|
-
};
|
120
|
-
res = gen.hasOne({ hasOne: 'hello', get: 'id' });
|
121
|
-
t.true(res !== undefined);
|
122
|
-
t.true(res !== null);
|
123
|
-
t.true(res === 0 || (res && res <= 10));
|
124
|
-
t.true(res === 0 || (res && res >= 0));
|
125
|
-
return [2 /*return*/];
|
126
|
-
});
|
127
|
-
}); });
|
128
|
-
(0, ava_1.default)('Should get one of the DB, and one field of that entity, more deep', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
129
|
-
var res;
|
130
|
-
return tslib_1.__generator(this, function (_a) {
|
131
|
-
switch (_a.label) {
|
132
|
-
case 0:
|
133
|
-
gen.DB = {
|
134
|
-
hello: set2
|
135
|
-
};
|
136
|
-
return [4 /*yield*/, gen.hasOne({ hasOne: 'hello', get: 'id.id' })];
|
137
|
-
case 1:
|
138
|
-
res = _a.sent();
|
139
|
-
t.true(res !== undefined);
|
140
|
-
t.true(res !== null);
|
141
|
-
t.true(res === 0 || (res && res <= 10));
|
142
|
-
t.true(res === 0 || (res && res >= 0));
|
143
|
-
return [2 /*return*/];
|
144
|
-
}
|
145
|
-
});
|
146
|
-
}); });
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
var tslib_1 = require("tslib");
|
4
|
+
var ava_1 = require("ava");
|
5
|
+
var __1 = require("..");
|
6
|
+
var gen = new __1.Generator();
|
7
|
+
var set1 = [
|
8
|
+
{
|
9
|
+
id: 0
|
10
|
+
},
|
11
|
+
{
|
12
|
+
id: 1
|
13
|
+
},
|
14
|
+
{
|
15
|
+
id: 2
|
16
|
+
},
|
17
|
+
{
|
18
|
+
id: 3
|
19
|
+
},
|
20
|
+
{
|
21
|
+
id: 4
|
22
|
+
},
|
23
|
+
{
|
24
|
+
id: 5
|
25
|
+
},
|
26
|
+
{
|
27
|
+
id: 6
|
28
|
+
},
|
29
|
+
{
|
30
|
+
id: 7
|
31
|
+
},
|
32
|
+
{
|
33
|
+
id: 8
|
34
|
+
},
|
35
|
+
{
|
36
|
+
id: 9
|
37
|
+
}
|
38
|
+
];
|
39
|
+
var set2 = [
|
40
|
+
{
|
41
|
+
id: {
|
42
|
+
id: 0
|
43
|
+
}
|
44
|
+
},
|
45
|
+
{
|
46
|
+
id: {
|
47
|
+
id: 1
|
48
|
+
}
|
49
|
+
},
|
50
|
+
{
|
51
|
+
id: {
|
52
|
+
id: 2
|
53
|
+
}
|
54
|
+
},
|
55
|
+
{
|
56
|
+
id: {
|
57
|
+
id: 3
|
58
|
+
}
|
59
|
+
},
|
60
|
+
{
|
61
|
+
id: {
|
62
|
+
id: 4
|
63
|
+
}
|
64
|
+
},
|
65
|
+
{
|
66
|
+
id: {
|
67
|
+
id: 5
|
68
|
+
}
|
69
|
+
},
|
70
|
+
{
|
71
|
+
id: {
|
72
|
+
id: 6
|
73
|
+
}
|
74
|
+
},
|
75
|
+
{
|
76
|
+
id: {
|
77
|
+
id: 7
|
78
|
+
}
|
79
|
+
},
|
80
|
+
{
|
81
|
+
id: {
|
82
|
+
id: 8
|
83
|
+
}
|
84
|
+
},
|
85
|
+
{
|
86
|
+
id: {
|
87
|
+
id: 9
|
88
|
+
}
|
89
|
+
}
|
90
|
+
];
|
91
|
+
(0, ava_1.default)('Should get one of the DB', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
92
|
+
var res;
|
93
|
+
return tslib_1.__generator(this, function (_a) {
|
94
|
+
gen.DB = { hello: set1 };
|
95
|
+
res = gen.hasOne({ hasOne: 'hello' });
|
96
|
+
t.true(set1.indexOf(res) > -1);
|
97
|
+
return [2 /*return*/];
|
98
|
+
});
|
99
|
+
}); });
|
100
|
+
(0, ava_1.default)('Should get one of the DB, and one field of that entity (eval)', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
101
|
+
var res;
|
102
|
+
return tslib_1.__generator(this, function (_a) {
|
103
|
+
gen.DB = {
|
104
|
+
hello: set1
|
105
|
+
};
|
106
|
+
res = gen.hasOne({ hasOne: 'hello', get: 'id', eval: true });
|
107
|
+
t.true(res !== undefined);
|
108
|
+
t.true(res !== null);
|
109
|
+
t.true(res === 0 || (res && res <= 10));
|
110
|
+
t.true(res === 0 || (res && res >= 0));
|
111
|
+
return [2 /*return*/];
|
112
|
+
});
|
113
|
+
}); });
|
114
|
+
(0, ava_1.default)('Should get one of the DB, and one field of that entity (no-eval)', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
115
|
+
var res;
|
116
|
+
return tslib_1.__generator(this, function (_a) {
|
117
|
+
gen.DB = {
|
118
|
+
hello: set1
|
119
|
+
};
|
120
|
+
res = gen.hasOne({ hasOne: 'hello', get: 'id' });
|
121
|
+
t.true(res !== undefined);
|
122
|
+
t.true(res !== null);
|
123
|
+
t.true(res === 0 || (res && res <= 10));
|
124
|
+
t.true(res === 0 || (res && res >= 0));
|
125
|
+
return [2 /*return*/];
|
126
|
+
});
|
127
|
+
}); });
|
128
|
+
(0, ava_1.default)('Should get one of the DB, and one field of that entity, more deep', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
129
|
+
var res;
|
130
|
+
return tslib_1.__generator(this, function (_a) {
|
131
|
+
switch (_a.label) {
|
132
|
+
case 0:
|
133
|
+
gen.DB = {
|
134
|
+
hello: set2
|
135
|
+
};
|
136
|
+
return [4 /*yield*/, gen.hasOne({ hasOne: 'hello', get: 'id.id' })];
|
137
|
+
case 1:
|
138
|
+
res = _a.sent();
|
139
|
+
t.true(res !== undefined);
|
140
|
+
t.true(res !== null);
|
141
|
+
t.true(res === 0 || (res && res <= 10));
|
142
|
+
t.true(res === 0 || (res && res >= 0));
|
143
|
+
return [2 /*return*/];
|
144
|
+
}
|
145
|
+
});
|
146
|
+
}); });
|
@@ -1 +1 @@
|
|
1
|
-
export {};
|
1
|
+
export {};
|
@@ -1,26 +1,26 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
var tslib_1 = require("tslib");
|
4
|
-
var ava_1 = require("ava");
|
5
|
-
var __1 = require("..");
|
6
|
-
var gen = new __1.Generator();
|
7
|
-
gen.name = 'user';
|
8
|
-
gen.DB = { user: [{ id: 0 }, { id: 1 }, { id: 2 }] };
|
9
|
-
(0, ava_1.default)('Incremental Id true', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
10
|
-
var res;
|
11
|
-
return tslib_1.__generator(this, function (_a) {
|
12
|
-
res = gen.incrementalId({ incrementalId: true });
|
13
|
-
t.true(res === 3);
|
14
|
-
return [2 /*return*/];
|
15
|
-
});
|
16
|
-
}); });
|
17
|
-
(0, ava_1.default)('Incremental Id default value', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
18
|
-
var res;
|
19
|
-
return tslib_1.__generator(this, function (_a) {
|
20
|
-
res = gen.incrementalId({ incrementalId: '2' });
|
21
|
-
t.true(res === 5);
|
22
|
-
res = gen.incrementalId({ incrementalId: '9' });
|
23
|
-
t.true(res === 12);
|
24
|
-
return [2 /*return*/];
|
25
|
-
});
|
26
|
-
}); });
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
var tslib_1 = require("tslib");
|
4
|
+
var ava_1 = require("ava");
|
5
|
+
var __1 = require("..");
|
6
|
+
var gen = new __1.Generator();
|
7
|
+
gen.name = 'user';
|
8
|
+
gen.DB = { user: [{ id: 0 }, { id: 1 }, { id: 2 }] };
|
9
|
+
(0, ava_1.default)('Incremental Id true', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
10
|
+
var res;
|
11
|
+
return tslib_1.__generator(this, function (_a) {
|
12
|
+
res = gen.incrementalId({ incrementalId: true });
|
13
|
+
t.true(res === 3);
|
14
|
+
return [2 /*return*/];
|
15
|
+
});
|
16
|
+
}); });
|
17
|
+
(0, ava_1.default)('Incremental Id default value', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
18
|
+
var res;
|
19
|
+
return tslib_1.__generator(this, function (_a) {
|
20
|
+
res = gen.incrementalId({ incrementalId: '2' });
|
21
|
+
t.true(res === 5);
|
22
|
+
res = gen.incrementalId({ incrementalId: '9' });
|
23
|
+
t.true(res === 12);
|
24
|
+
return [2 /*return*/];
|
25
|
+
});
|
26
|
+
}); });
|
@@ -1 +1 @@
|
|
1
|
-
export {};
|
1
|
+
export {};
|
@@ -1,24 +1,24 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
var tslib_1 = require("tslib");
|
4
|
-
var ava_1 = require("ava");
|
5
|
-
var __1 = require("..");
|
6
|
-
var gen = new __1.Generator();
|
7
|
-
(0, ava_1.default)('Should have access to object', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
8
|
-
var res;
|
9
|
-
return tslib_1.__generator(this, function (_a) {
|
10
|
-
gen.object = { hello: 'world' };
|
11
|
-
res = gen.self({ self: 'hello' });
|
12
|
-
t.true(res === 'world');
|
13
|
-
return [2 /*return*/];
|
14
|
-
});
|
15
|
-
}); });
|
16
|
-
(0, ava_1.default)('[eval] Should have access to object', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
17
|
-
var res;
|
18
|
-
return tslib_1.__generator(this, function (_a) {
|
19
|
-
gen.object = { hello: 'world' };
|
20
|
-
res = gen.self({ self: 'hello', eval: true });
|
21
|
-
t.true(res === 'world');
|
22
|
-
return [2 /*return*/];
|
23
|
-
});
|
24
|
-
}); });
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
var tslib_1 = require("tslib");
|
4
|
+
var ava_1 = require("ava");
|
5
|
+
var __1 = require("..");
|
6
|
+
var gen = new __1.Generator();
|
7
|
+
(0, ava_1.default)('Should have access to object', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
8
|
+
var res;
|
9
|
+
return tslib_1.__generator(this, function (_a) {
|
10
|
+
gen.object = { hello: 'world' };
|
11
|
+
res = gen.self({ self: 'hello' });
|
12
|
+
t.true(res === 'world');
|
13
|
+
return [2 /*return*/];
|
14
|
+
});
|
15
|
+
}); });
|
16
|
+
(0, ava_1.default)('[eval] Should have access to object', function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
17
|
+
var res;
|
18
|
+
return tslib_1.__generator(this, function (_a) {
|
19
|
+
gen.object = { hello: 'world' };
|
20
|
+
res = gen.self({ self: 'hello', eval: true });
|
21
|
+
t.true(res === 'world');
|
22
|
+
return [2 /*return*/];
|
23
|
+
});
|
24
|
+
}); });
|
@@ -1 +1 @@
|
|
1
|
-
export {};
|
1
|
+
export {};
|