vona-module-test-vona 5.0.69 → 5.0.71
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/bean/aop.regExp.d.ts +6 -4
- package/dist/bean/aop.simple.d.ts +8 -4
- package/dist/bean/bean.testCtx.d.ts +1 -1
- package/dist/index.js +45 -43
- package/package.json +1 -1
- package/src/bean/aop.regExp.ts +10 -8
- package/src/bean/aop.simple.ts +22 -18
- package/src/bean/bean.testCtx.ts +1 -1
- package/src/controller/bean.ts +1 -1
- package/test/aopMethod.test.ts +1 -1
- package/test/authSimple.test.ts +1 -1
- package/test/broadcast.test.ts +1 -1
- package/test/cache/caching.test.ts +1 -1
- package/test/database/database.test.ts +6 -6
- package/test/database/dtoLazy.test.ts +1 -1
- package/test/database/modelAggregate.test.ts +1 -1
- package/test/database/modelCache.test.ts +1 -1
- package/test/database/modelGeneral.test.ts +1 -1
- package/test/database/modelGroup.test.ts +1 -1
- package/test/database/modelMagic.test.ts +1 -1
- package/test/database/modelRelations.test.ts +1 -1
- package/test/database/modelRelationsJoins.test.ts +1 -1
- package/test/database/modelRelationsMutate.test.ts +3 -3
- package/test/database/modelWhere.test.ts +1 -1
- package/test/database/orm.test.ts +1 -1
- package/test/database/transaction.test.ts +2 -2
- package/test/event.test.ts +1 -1
- package/test/instance.test.ts +2 -2
- package/test/locale.test.ts +2 -2
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { AopAction, AopActionGetter, AopActionSetter } from 'vona-module-a-aspect';
|
|
2
|
+
import type { BeanTestCtx } from './bean.testCtx.ts';
|
|
1
3
|
import { BeanAopBase } from 'vona';
|
|
2
4
|
export declare class AopRegExp extends BeanAopBase {
|
|
3
|
-
__get_name__
|
|
4
|
-
__set_name__
|
|
5
|
-
actionSync
|
|
6
|
-
actionAsync
|
|
5
|
+
protected __get_name__: AopActionGetter<BeanTestCtx, 'name'>;
|
|
6
|
+
protected __set_name__: AopActionSetter<BeanTestCtx, 'name'>;
|
|
7
|
+
actionSync: AopAction<BeanTestCtx, 'actionSync', string>;
|
|
8
|
+
actionAsync: AopAction<BeanTestCtx, 'actionAsync', string>;
|
|
7
9
|
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AopAction, AopActionDispose, AopActionGetter, AopActionInit, AopActionSetter } from 'vona-module-a-aspect';
|
|
1
|
+
import type { AopAction, AopActionDispose, AopActionGet, AopActionGetter, AopActionInit, AopActionSet, AopActionSetter } from 'vona-module-a-aspect';
|
|
3
2
|
import type { BeanTestCtx } from 'vona-module-test-vona';
|
|
4
3
|
import { BeanAopBase } from 'vona';
|
|
4
|
+
declare module 'vona-module-test-vona' {
|
|
5
|
+
interface BeanTestCtx {
|
|
6
|
+
magic: string;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
5
9
|
declare class AopSimpleBase extends BeanAopBase {
|
|
6
10
|
actionSync: AopAction<BeanTestCtx, 'actionSync', string>;
|
|
7
11
|
}
|
|
8
12
|
export declare class AopSimple extends AopSimpleBase {
|
|
9
|
-
protected __get__
|
|
10
|
-
protected __set__
|
|
13
|
+
protected __get__: AopActionGet<BeanTestCtx>;
|
|
14
|
+
protected __set__: AopActionSet<BeanTestCtx>;
|
|
11
15
|
protected __get_name__: AopActionGetter<BeanTestCtx, 'name'>;
|
|
12
16
|
protected __set_name__: AopActionSetter<BeanTestCtx, 'name'>;
|
|
13
17
|
protected __init__: AopActionInit<BeanTestCtx>;
|
package/dist/index.js
CHANGED
|
@@ -32,26 +32,29 @@ let AopRegExp = (_dec$1q = Aop({
|
|
|
32
32
|
}), _dec2$1q = BeanInfo({
|
|
33
33
|
module: "test-vona"
|
|
34
34
|
}), _dec$1q(_class$1q = _dec2$1q(_class$1q = class AopRegExp extends BeanAopBase {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
parts.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
35
|
+
constructor(...args) {
|
|
36
|
+
super(...args);
|
|
37
|
+
this.__get_name__ = function (next, _receiver) {
|
|
38
|
+
const value = next();
|
|
39
|
+
return `${value}:regexpaop`;
|
|
40
|
+
};
|
|
41
|
+
this.__set_name__ = function (value, next, _receiver) {
|
|
42
|
+
const parts = value.split(':');
|
|
43
|
+
const index = parts.indexOf('regexpaop');
|
|
44
|
+
if (index > -1) {
|
|
45
|
+
parts.splice(index, 1);
|
|
46
|
+
}
|
|
47
|
+
value = parts.join(':');
|
|
48
|
+
return next(value);
|
|
49
|
+
};
|
|
50
|
+
this.actionSync = (_args, next, _receiver) => {
|
|
51
|
+
const result = next();
|
|
52
|
+
return `${result}:regexpaop`;
|
|
53
|
+
};
|
|
54
|
+
this.actionAsync = async (_args, next, _receiver) => {
|
|
55
|
+
const result = await next();
|
|
56
|
+
return `${result}:regexpaop`;
|
|
57
|
+
};
|
|
55
58
|
}
|
|
56
59
|
}) || _class$1q) || _class$1q);
|
|
57
60
|
|
|
@@ -76,6 +79,27 @@ let AopSimple = (_dec$1p = Aop({
|
|
|
76
79
|
}), _dec$1p(_class$1p = _dec2$1p(_class$1p = class AopSimple extends AopSimpleBase {
|
|
77
80
|
constructor(...args) {
|
|
78
81
|
super(...args);
|
|
82
|
+
this.__get__ = (prop, next, _receiver) => {
|
|
83
|
+
const value = next();
|
|
84
|
+
if (prop === 'magic') {
|
|
85
|
+
return 'magic:simpleaop';
|
|
86
|
+
}
|
|
87
|
+
// if (prop === 'name') {
|
|
88
|
+
// return `${value}:simpleaop`;
|
|
89
|
+
// }
|
|
90
|
+
return value;
|
|
91
|
+
};
|
|
92
|
+
this.__set__ = (_prop, value, next, _receiver) => {
|
|
93
|
+
// if (prop === 'name') {
|
|
94
|
+
// const parts = value.split(':');
|
|
95
|
+
// const index = parts.indexOf('simpleaop');
|
|
96
|
+
// if (index > -1) {
|
|
97
|
+
// parts.splice(index, 1);
|
|
98
|
+
// }
|
|
99
|
+
// value = parts.join(':');
|
|
100
|
+
// }
|
|
101
|
+
return next(value);
|
|
102
|
+
};
|
|
79
103
|
this.__get_name__ = function (next, _receiver) {
|
|
80
104
|
const value = next();
|
|
81
105
|
return `${value}:simpleaop`;
|
|
@@ -100,28 +124,6 @@ let AopSimple = (_dec$1p = Aop({
|
|
|
100
124
|
return `${result}:simpleaop`;
|
|
101
125
|
};
|
|
102
126
|
}
|
|
103
|
-
// magic
|
|
104
|
-
__get__(prop, next) {
|
|
105
|
-
const value = next();
|
|
106
|
-
if (prop === 'magic') {
|
|
107
|
-
return 'magic:simpleaop';
|
|
108
|
-
}
|
|
109
|
-
if (prop === 'name') {
|
|
110
|
-
return `${value}:simpleaop`;
|
|
111
|
-
}
|
|
112
|
-
return value;
|
|
113
|
-
}
|
|
114
|
-
__set__(prop, value, next) {
|
|
115
|
-
if (prop === 'name') {
|
|
116
|
-
const parts = value.split(':');
|
|
117
|
-
const index = parts.indexOf('simpleaop');
|
|
118
|
-
if (index > -1) {
|
|
119
|
-
parts.splice(index, 1);
|
|
120
|
-
}
|
|
121
|
-
value = parts.join(':');
|
|
122
|
-
}
|
|
123
|
-
return next(value);
|
|
124
|
-
}
|
|
125
127
|
}) || _class$1p) || _class$1p);
|
|
126
128
|
|
|
127
129
|
var _dec$1o, _dec2$1o, _class$1o;
|
|
@@ -2327,7 +2329,7 @@ let ControllerBean = (_dec$h = Controller({
|
|
|
2327
2329
|
assert.equal(res, 'serviceTest');
|
|
2328
2330
|
|
|
2329
2331
|
// general scope
|
|
2330
|
-
res = this.
|
|
2332
|
+
res = this.app.scope(__ThisModule__).service.test.name;
|
|
2331
2333
|
assert.equal(res, 'serviceTest');
|
|
2332
2334
|
res = this.$scope.testVona.service.test.name;
|
|
2333
2335
|
assert.equal(res, 'serviceTest');
|
package/package.json
CHANGED
package/src/bean/aop.regExp.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
import type { AopAction, AopActionGetter, AopActionSetter } from 'vona-module-a-aspect';
|
|
2
|
+
import type { BeanTestCtx } from './bean.testCtx.ts';
|
|
1
3
|
import { BeanAopBase } from 'vona';
|
|
2
4
|
import { Aop } from 'vona-module-a-aspect';
|
|
3
5
|
|
|
4
6
|
@Aop({ match: [/^test-vona\.service\.test\w+$/, 'testCtx'], meta: { mode: 'test' } })
|
|
5
7
|
export class AopRegExp extends BeanAopBase {
|
|
6
|
-
__get_name__(next) {
|
|
8
|
+
protected __get_name__: AopActionGetter<BeanTestCtx, 'name'> = function (next, _receiver) {
|
|
7
9
|
const value = next();
|
|
8
10
|
return `${value}:regexpaop`;
|
|
9
|
-
}
|
|
11
|
+
};
|
|
10
12
|
|
|
11
|
-
__set_name__(value, next) {
|
|
13
|
+
protected __set_name__: AopActionSetter<BeanTestCtx, 'name'> = function (value, next, _receiver) {
|
|
12
14
|
const parts = value.split(':');
|
|
13
15
|
const index = parts.indexOf('regexpaop');
|
|
14
16
|
if (index > -1) {
|
|
@@ -16,15 +18,15 @@ export class AopRegExp extends BeanAopBase {
|
|
|
16
18
|
}
|
|
17
19
|
value = parts.join(':');
|
|
18
20
|
return next(value);
|
|
19
|
-
}
|
|
21
|
+
};
|
|
20
22
|
|
|
21
|
-
actionSync(_args, next) {
|
|
23
|
+
actionSync: AopAction<BeanTestCtx, 'actionSync', string> = (_args, next, _receiver) => {
|
|
22
24
|
const result = next();
|
|
23
25
|
return `${result}:regexpaop`;
|
|
24
|
-
}
|
|
26
|
+
};
|
|
25
27
|
|
|
26
|
-
async
|
|
28
|
+
actionAsync: AopAction<BeanTestCtx, 'actionAsync', string> = async (_args, next, _receiver) => {
|
|
27
29
|
const result = await next();
|
|
28
30
|
return `${result}:regexpaop`;
|
|
29
|
-
}
|
|
31
|
+
};
|
|
30
32
|
}
|
package/src/bean/aop.simple.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AopAction, AopActionDispose, AopActionGetter, AopActionInit, AopActionSetter } from 'vona-module-a-aspect';
|
|
1
|
+
import type { AopAction, AopActionDispose, AopActionGet, AopActionGetter, AopActionInit, AopActionSet, AopActionSetter } from 'vona-module-a-aspect';
|
|
3
2
|
import type { BeanTestCtx } from 'vona-module-test-vona';
|
|
4
3
|
import { BeanAopBase } from 'vona';
|
|
5
4
|
import { Aop } from 'vona-module-a-aspect';
|
|
6
5
|
|
|
6
|
+
declare module 'vona-module-test-vona' {
|
|
7
|
+
export interface BeanTestCtx {
|
|
8
|
+
magic: string;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
class AopSimpleBase extends BeanAopBase {
|
|
8
13
|
actionSync: AopAction<BeanTestCtx, 'actionSync', string> = (_args, next, _receiver) => {
|
|
9
14
|
const result = next();
|
|
@@ -13,29 +18,28 @@ class AopSimpleBase extends BeanAopBase {
|
|
|
13
18
|
|
|
14
19
|
@Aop({ match: 'testCtx', dependencies: 'test-vona:regExp', meta: { mode: 'test' } })
|
|
15
20
|
export class AopSimple extends AopSimpleBase {
|
|
16
|
-
|
|
17
|
-
protected __get__(prop: string, next: NextSync) {
|
|
21
|
+
protected __get__: AopActionGet<BeanTestCtx> = (prop, next, _receiver) => {
|
|
18
22
|
const value = next();
|
|
19
23
|
if (prop === 'magic') {
|
|
20
24
|
return 'magic:simpleaop';
|
|
21
25
|
}
|
|
22
|
-
if (prop === 'name') {
|
|
23
|
-
|
|
24
|
-
}
|
|
26
|
+
// if (prop === 'name') {
|
|
27
|
+
// return `${value}:simpleaop`;
|
|
28
|
+
// }
|
|
25
29
|
return value;
|
|
26
|
-
}
|
|
30
|
+
};
|
|
27
31
|
|
|
28
|
-
protected __set__
|
|
29
|
-
if (prop === 'name') {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
32
|
+
protected __set__: AopActionSet<BeanTestCtx> = (_prop, value, next, _receiver) => {
|
|
33
|
+
// if (prop === 'name') {
|
|
34
|
+
// const parts = value.split(':');
|
|
35
|
+
// const index = parts.indexOf('simpleaop');
|
|
36
|
+
// if (index > -1) {
|
|
37
|
+
// parts.splice(index, 1);
|
|
38
|
+
// }
|
|
39
|
+
// value = parts.join(':');
|
|
40
|
+
// }
|
|
37
41
|
return next(value);
|
|
38
|
-
}
|
|
42
|
+
};
|
|
39
43
|
|
|
40
44
|
protected __get_name__: AopActionGetter<BeanTestCtx, 'name'> = function (next, _receiver) {
|
|
41
45
|
const value = next();
|
package/src/bean/bean.testCtx.ts
CHANGED
package/src/controller/bean.ts
CHANGED
|
@@ -86,7 +86,7 @@ export class ControllerBean extends BeanBase {
|
|
|
86
86
|
assert.equal(res, 'serviceTest');
|
|
87
87
|
|
|
88
88
|
// general scope
|
|
89
|
-
res = this.
|
|
89
|
+
res = this.app.scope(__ThisModule__).service.test.name;
|
|
90
90
|
assert.equal(res, 'serviceTest');
|
|
91
91
|
|
|
92
92
|
res = this.$scope.testVona.service.test.name;
|
package/test/aopMethod.test.ts
CHANGED
|
@@ -6,7 +6,7 @@ describe('aopMethod.test.ts', () => {
|
|
|
6
6
|
it('action:aopMethod', async () => {
|
|
7
7
|
await app.bean.executor.mockCtx(async () => {
|
|
8
8
|
// scope
|
|
9
|
-
const scopeTest = app.
|
|
9
|
+
const scopeTest = app.scope('test-vona');
|
|
10
10
|
let result = scopeTest.service.aopMethod.testSyncBase();
|
|
11
11
|
assert.equal(result, '-+hello+-');
|
|
12
12
|
result = scopeTest.service.aopMethod.testSync();
|
package/test/authSimple.test.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { app } from 'vona-mock';
|
|
|
5
5
|
|
|
6
6
|
describe('authSimple.test.ts', () => {
|
|
7
7
|
it('action:passwordHash', async () => {
|
|
8
|
-
const scope = app.
|
|
8
|
+
const scope = app.scope('a-authsimple');
|
|
9
9
|
const password = '12344##1xxaasDFQ,.$';
|
|
10
10
|
const hash = await scope.service.authSimple.calcPasswordHash(password);
|
|
11
11
|
let verified = await scope.service.authSimple.verifyPasswordHash(password, hash);
|
package/test/broadcast.test.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { app } from 'vona-mock';
|
|
|
5
5
|
describe('broadcast.test.ts', () => {
|
|
6
6
|
it('action:broadcast', async () => {
|
|
7
7
|
await app.bean.executor.mockCtx(async () => {
|
|
8
|
-
app.
|
|
8
|
+
app.scope('test-vona').broadcast.test.emit(
|
|
9
9
|
{ message: 'hello' },
|
|
10
10
|
{
|
|
11
11
|
locale: 'zh-cn',
|
|
@@ -5,7 +5,7 @@ import { app } from 'vona-mock';
|
|
|
5
5
|
describe('caching.test.ts', () => {
|
|
6
6
|
it('action:caching', async () => {
|
|
7
7
|
await app.bean.executor.mockCtx(async () => {
|
|
8
|
-
const scopeTest = app.
|
|
8
|
+
const scopeTest = app.scope('test-vona');
|
|
9
9
|
// get: cacheKeyFn(string)
|
|
10
10
|
const res = await scopeTest.service.caching.get(2);
|
|
11
11
|
assert.equal(res.id, 2);
|
|
@@ -7,7 +7,7 @@ import { app } from 'vona-mock';
|
|
|
7
7
|
describe('database.test.ts', () => {
|
|
8
8
|
it('action:database:switchClient', async () => {
|
|
9
9
|
await app.bean.executor.mockCtx(async () => {
|
|
10
|
-
const scopeDatabase = app.
|
|
10
|
+
const scopeDatabase = app.scope('a-orm');
|
|
11
11
|
const defaultClientName = scopeDatabase.service.database.getDefaultClientName();
|
|
12
12
|
// current
|
|
13
13
|
assert.equal(app.ctx.db.clientName, defaultClientName);
|
|
@@ -24,7 +24,7 @@ describe('database.test.ts', () => {
|
|
|
24
24
|
it('action:model:clientName', async () => {
|
|
25
25
|
await app.bean.executor.mockCtx(async () => {
|
|
26
26
|
// scope
|
|
27
|
-
const scopeTest = app.
|
|
27
|
+
const scopeTest = app.scope('test-vona');
|
|
28
28
|
const modelTest = scopeTest.model.test;
|
|
29
29
|
assert.equal(modelTest.options.client, 'default');
|
|
30
30
|
const modelTest2 = scopeTest.model.test;
|
|
@@ -34,7 +34,7 @@ describe('database.test.ts', () => {
|
|
|
34
34
|
it('action:model:clientNameDynamic:transaction:fail', async () => {
|
|
35
35
|
await app.bean.executor.mockCtx(async () => {
|
|
36
36
|
// scope
|
|
37
|
-
const scopeTest = app.
|
|
37
|
+
const scopeTest = app.scope('test-vona');
|
|
38
38
|
const entityTest = await scopeTest.model.test.insert({ title: 'clientNameDynamic:fail' });
|
|
39
39
|
assert.equal(entityTest.title, 'clientNameDynamic:fail');
|
|
40
40
|
await catchError(async () => {
|
|
@@ -55,7 +55,7 @@ describe('database.test.ts', () => {
|
|
|
55
55
|
it('action:model:clientNameDynamic:transaction:success', async () => {
|
|
56
56
|
await app.bean.executor.mockCtx(async () => {
|
|
57
57
|
// scope
|
|
58
|
-
const scopeTest = app.
|
|
58
|
+
const scopeTest = app.scope('test-vona');
|
|
59
59
|
const entityTest = await scopeTest.model.test.insert({ title: 'clientNameDynamic:success' });
|
|
60
60
|
assert.equal(entityTest.title, 'clientNameDynamic:success');
|
|
61
61
|
const db = app.bean.database.getDb({ clientName: 'default' });
|
|
@@ -73,7 +73,7 @@ describe('database.test.ts', () => {
|
|
|
73
73
|
it('action:database:transaction:compensate', async () => {
|
|
74
74
|
await app.bean.executor.mockCtx(async () => {
|
|
75
75
|
// scope
|
|
76
|
-
const scopeTest = app.
|
|
76
|
+
const scopeTest = app.scope('test-vona');
|
|
77
77
|
const entityTest = await scopeTest.model.test.insert({ title: 'transaction:compensate:fail' });
|
|
78
78
|
assert.equal(entityTest.title, 'transaction:compensate:fail');
|
|
79
79
|
await catchError(async () => {
|
|
@@ -96,7 +96,7 @@ describe('database.test.ts', () => {
|
|
|
96
96
|
it('action:model:dynamicTableName', async () => {
|
|
97
97
|
await app.bean.executor.mockCtx(async () => {
|
|
98
98
|
// scope
|
|
99
|
-
const scopeTest = app.
|
|
99
|
+
const scopeTest = app.scope('test-vona');
|
|
100
100
|
const entityTest = scopeTest.entity.test;
|
|
101
101
|
const modelTest = scopeTest.model.testDynamicTable;
|
|
102
102
|
// tableName
|
|
@@ -37,7 +37,7 @@ describe('dtoLazy.test.ts', () => {
|
|
|
37
37
|
const schema = $schema(beanOptions.beanClass);
|
|
38
38
|
registry.register(beanOptions.beanFullName, schema);
|
|
39
39
|
const generator = new OpenApiGeneratorV31(registry.definitions);
|
|
40
|
-
const apiObj = generator.generateDocument(app.
|
|
40
|
+
const apiObj = generator.generateDocument(app.scope('a-openapi').config.generateDocument.V31);
|
|
41
41
|
assert.equal(cast(apiObj).components.schemas['test-vona.dto.userLazy'].properties.user.$ref, '#/components/schemas/test-vona.dto.userLazy');
|
|
42
42
|
assert.equal(cast(apiObj).components.schemas['test-vona.dto.roleLazy'].properties.users.items.$ref, '#/components/schemas/test-vona.dto.userLazy');
|
|
43
43
|
});
|
|
@@ -10,7 +10,7 @@ describe('modelAggregate.test.ts', () => {
|
|
|
10
10
|
await app.bean.executor.mockCtx(async () => {
|
|
11
11
|
const prefix = 'action:modelAggregate';
|
|
12
12
|
// scope
|
|
13
|
-
const scopeTest = app.
|
|
13
|
+
const scopeTest = app.scope('test-vona');
|
|
14
14
|
// insert: roles
|
|
15
15
|
const roles = await scopeTest.model.role.insertBulk([
|
|
16
16
|
{ name: `${prefix}:family` },
|
|
@@ -7,7 +7,7 @@ describe('modelCache.test.ts', () => {
|
|
|
7
7
|
await app.bean.executor.mockCtx(async () => {
|
|
8
8
|
const prefix = 'action:modelCache:cacheQuery';
|
|
9
9
|
// scope
|
|
10
|
-
const scopeTest = app.
|
|
10
|
+
const scopeTest = app.scope('test-vona');
|
|
11
11
|
// create
|
|
12
12
|
const user = await scopeTest.model.user.insert({ name: `${prefix}:1` });
|
|
13
13
|
// select
|
|
@@ -7,7 +7,7 @@ describe('model.test.ts', () => {
|
|
|
7
7
|
it('action:model:defaultValue', async () => {
|
|
8
8
|
await app.bean.executor.mockCtx(async () => {
|
|
9
9
|
// scope
|
|
10
|
-
const scopeTest = app.
|
|
10
|
+
const scopeTest = app.scope('test-vona');
|
|
11
11
|
// create
|
|
12
12
|
const item = await scopeTest.model.test.insert();
|
|
13
13
|
assert.equal(isNil(item.testDate), false);
|
|
@@ -10,7 +10,7 @@ describe('modelGroup.test.ts', () => {
|
|
|
10
10
|
await app.bean.executor.mockCtx(async () => {
|
|
11
11
|
const prefix = 'action:modelGroup';
|
|
12
12
|
// scope
|
|
13
|
-
const scopeTest = app.
|
|
13
|
+
const scopeTest = app.scope('test-vona');
|
|
14
14
|
// insert: roles
|
|
15
15
|
const roles = await scopeTest.model.role.insertBulk([
|
|
16
16
|
{ name: `${prefix}:family` },
|
|
@@ -7,7 +7,7 @@ describe('modelMagic.test.ts', () => {
|
|
|
7
7
|
await app.bean.executor.mockCtx(async () => {
|
|
8
8
|
const name = 'modelMagic:001';
|
|
9
9
|
// scope
|
|
10
|
-
const scopeTest = app.
|
|
10
|
+
const scopeTest = app.scope('test-vona');
|
|
11
11
|
// create
|
|
12
12
|
const item = await scopeTest.model.user.insert({ name });
|
|
13
13
|
assert.equal(item.name, name);
|
|
@@ -10,7 +10,7 @@ describe('modelRelations.test.ts', () => {
|
|
|
10
10
|
await app.bean.executor.mockCtx(async () => {
|
|
11
11
|
const prefix = 'action:modelRelations';
|
|
12
12
|
// scope
|
|
13
|
-
const scopeTest = app.
|
|
13
|
+
const scopeTest = app.scope('test-vona');
|
|
14
14
|
// test data: create
|
|
15
15
|
const testData = await scopeTest.service.testData.create(prefix);
|
|
16
16
|
const {
|
|
@@ -7,7 +7,7 @@ describe('modelRelationsJoins.test.ts', () => {
|
|
|
7
7
|
await app.bean.executor.mockCtx(async () => {
|
|
8
8
|
const prefix = 'action:modelRelationsJoins';
|
|
9
9
|
// scope
|
|
10
|
-
const scopeTest = app.
|
|
10
|
+
const scopeTest = app.scope('test-vona');
|
|
11
11
|
// test data: create
|
|
12
12
|
const testData = await scopeTest.service.testData.create(prefix);
|
|
13
13
|
const {
|
|
@@ -9,7 +9,7 @@ describe('modelRelationsMutate.test.ts', () => {
|
|
|
9
9
|
await app.bean.executor.mockCtx(async () => {
|
|
10
10
|
const prefix = 'action:modelRelationsMutate';
|
|
11
11
|
// scope
|
|
12
|
-
const scopeTest = app.
|
|
12
|
+
const scopeTest = app.scope('test-vona');
|
|
13
13
|
// insert: roles
|
|
14
14
|
const roles = await scopeTest.model.role.insertBulk([
|
|
15
15
|
{ name: `${prefix}:family` },
|
|
@@ -154,7 +154,7 @@ describe('modelRelationsMutate.test.ts', () => {
|
|
|
154
154
|
await app.bean.executor.mockCtx(async () => {
|
|
155
155
|
const prefix = 'action:modelRelationsMutateWith';
|
|
156
156
|
// scope
|
|
157
|
-
const scopeTest = app.
|
|
157
|
+
const scopeTest = app.scope('test-vona');
|
|
158
158
|
// insert: roles
|
|
159
159
|
const roles = await scopeTest.model.role.insertBulk([
|
|
160
160
|
{ name: `${prefix}:family` },
|
|
@@ -301,7 +301,7 @@ describe('modelRelationsMutate.test.ts', () => {
|
|
|
301
301
|
await app.bean.executor.mockCtx(async () => {
|
|
302
302
|
const prefix = 'action:modelRelationsMutateTree';
|
|
303
303
|
// scope
|
|
304
|
-
const scopeTest = app.
|
|
304
|
+
const scopeTest = app.scope('test-vona');
|
|
305
305
|
// create: categoryTree
|
|
306
306
|
const categoryTree = await scopeTest.model.category.insert({
|
|
307
307
|
name: `${prefix}:1`,
|
|
@@ -7,7 +7,7 @@ describe('modelWhere.test.ts', () => {
|
|
|
7
7
|
it('action:modelWhere', async () => {
|
|
8
8
|
await app.bean.executor.mockCtx(async () => {
|
|
9
9
|
if (app.bean.database.current.dialectName !== 'pg') return;
|
|
10
|
-
const scopeTest = app.
|
|
10
|
+
const scopeTest = app.scope('test-vona');
|
|
11
11
|
// ref
|
|
12
12
|
let builder = scopeTest.model.post.builder();
|
|
13
13
|
scopeTest.model.post.buildWhere(builder, { id: scopeTest.model.post.ref('id') as any });
|
|
@@ -5,7 +5,7 @@ describe('orm.test.ts', () => {
|
|
|
5
5
|
it('action:orm:hasOne', async () => {
|
|
6
6
|
await app.bean.executor.mockCtx(async () => {
|
|
7
7
|
// scope
|
|
8
|
-
const scopeTest = app.
|
|
8
|
+
const scopeTest = app.scope('test-vona');
|
|
9
9
|
// create: post/postContent
|
|
10
10
|
const post1 = await scopeTest.model.post.insert({
|
|
11
11
|
title: 'action:orm:hasOne:post1',
|
|
@@ -42,7 +42,7 @@ describe('transaction.test.ts', () => {
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
// aop method
|
|
45
|
-
const scopeTest = app.
|
|
45
|
+
const scopeTest = app.scope('test-vona');
|
|
46
46
|
await app.bean.executor.mockCtx(async () => {
|
|
47
47
|
// create table
|
|
48
48
|
await app.bean.model.createTable(tableNameFail, table => {
|
|
@@ -109,7 +109,7 @@ describe('transaction.test.ts', () => {
|
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
// aop method
|
|
112
|
-
const scopeTest = app.
|
|
112
|
+
const scopeTest = app.scope('test-vona');
|
|
113
113
|
await app.bean.executor.mockCtx(async () => {
|
|
114
114
|
// create table
|
|
115
115
|
await app.bean.model.createTable(tableNameSuccess, table => {
|
package/test/event.test.ts
CHANGED
|
@@ -6,7 +6,7 @@ describe('event.test.ts', () => {
|
|
|
6
6
|
it('action:event', async () => {
|
|
7
7
|
await app.bean.executor.mockCtx(async () => {
|
|
8
8
|
// scope
|
|
9
|
-
const scopeTest = app.
|
|
9
|
+
const scopeTest = app.scope('test-vona');
|
|
10
10
|
const result = await scopeTest.event.helloEcho.emit({ text: 'hello' }, 'world');
|
|
11
11
|
assert.equal(result, 'hello world');
|
|
12
12
|
});
|
package/test/instance.test.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { app } from 'vona-mock';
|
|
|
5
5
|
describe('instance.test.ts', () => {
|
|
6
6
|
it('action:instance:shareTest', async () => {
|
|
7
7
|
await app.bean.executor.mockCtx(async () => {
|
|
8
|
-
const scopeDatabase = app.
|
|
8
|
+
const scopeDatabase = app.scope('a-orm');
|
|
9
9
|
const defaultClientName = scopeDatabase.service.database.getDefaultClientName();
|
|
10
10
|
assert.equal(app.ctx.instanceName, 'shareTest');
|
|
11
11
|
assert.equal(app.ctx.instance.name, 'shareTest');
|
|
@@ -15,7 +15,7 @@ describe('instance.test.ts', () => {
|
|
|
15
15
|
});
|
|
16
16
|
it('action:instance:isolateTest', async () => {
|
|
17
17
|
await app.bean.executor.mockCtx(async () => {
|
|
18
|
-
const scopeDatabase = app.
|
|
18
|
+
const scopeDatabase = app.scope('a-orm');
|
|
19
19
|
const defaultClientName = scopeDatabase.service.database.getDefaultClientName();
|
|
20
20
|
assert.equal(app.ctx.instanceName, 'isolateTest');
|
|
21
21
|
assert.equal(app.ctx.instance.name, 'isolateTest');
|
package/test/locale.test.ts
CHANGED
|
@@ -19,7 +19,7 @@ describe('locale.test.ts', () => {
|
|
|
19
19
|
);
|
|
20
20
|
assert.equal(app.meta.locale.getText(false, undefined, ctx.locale, 'test-vona::TestHelloWorld'), '您好,世界');
|
|
21
21
|
// scope locale
|
|
22
|
-
const scopeTest = app.
|
|
22
|
+
const scopeTest = app.scope('test-vona');
|
|
23
23
|
assert.equal(scopeTest.locale.TestHelloWorld(), '您好,世界');
|
|
24
24
|
},
|
|
25
25
|
{ locale: 'zh-cn' },
|
|
@@ -29,7 +29,7 @@ describe('locale.test.ts', () => {
|
|
|
29
29
|
it('action:locale:plurals', async () => {
|
|
30
30
|
await app.bean.executor.mockCtx(async () => {
|
|
31
31
|
// scope
|
|
32
|
-
const scopeTest = app.
|
|
32
|
+
const scopeTest = app.scope('test-vona');
|
|
33
33
|
// english
|
|
34
34
|
assert.equal(scopeTest.locale.TestApples.locale('en-us', 0), 'no apples');
|
|
35
35
|
assert.equal(scopeTest.locale.TestApples.locale('en-us', 1), 'one apple');
|