vona-module-test-vona 5.0.70 → 5.0.72

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/index.js CHANGED
@@ -2329,7 +2329,7 @@ let ControllerBean = (_dec$h = Controller({
2329
2329
  assert.equal(res, 'serviceTest');
2330
2330
 
2331
2331
  // general scope
2332
- res = this.bean.scope(__ThisModule__).service.test.name;
2332
+ res = this.app.scope(__ThisModule__).service.test.name;
2333
2333
  assert.equal(res, 'serviceTest');
2334
2334
  res = this.$scope.testVona.service.test.name;
2335
2335
  assert.equal(res, 'serviceTest');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-test-vona",
3
3
  "type": "module",
4
- "version": "5.0.70",
4
+ "version": "5.0.72",
5
5
  "title": "test-vona",
6
6
  "vonaModule": {
7
7
  "fileVersion": 1,
@@ -86,7 +86,7 @@ export class ControllerBean extends BeanBase {
86
86
  assert.equal(res, 'serviceTest');
87
87
 
88
88
  // general scope
89
- res = this.bean.scope(__ThisModule__).service.test.name;
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;
@@ -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.bean.scope('test-vona');
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();
@@ -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.bean.scope('a-authsimple');
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);
@@ -16,10 +16,11 @@ describe('authSimple.test.ts', () => {
16
16
 
17
17
  it('action:authSimple', async () => {
18
18
  await app.bean.executor.mockCtx(async () => {
19
+ const password = app.scope('home-user').config.passwordDefault.admin;
19
20
  // login
20
21
  const jwt = await app.bean.auth.authenticate('a-authsimple:simple', {
21
22
  clientName: 'default',
22
- clientOptions: { username: 'admin', password: '123456' },
23
+ clientOptions: { username: 'admin', password },
23
24
  });
24
25
  assert.equal(!!jwt?.accessToken, true);
25
26
  // isAuthenticated: isolate
@@ -36,7 +37,7 @@ describe('authSimple.test.ts', () => {
36
37
  assert.equal(isAuthenticated, true);
37
38
  // login again
38
39
  const jwt2 = await app.bean.authSimple.authenticate(
39
- { username: 'admin', password: '123456' },
40
+ { username: 'admin', password },
40
41
  'login',
41
42
  'default',
42
43
  );
@@ -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.bean.scope('test-vona').broadcast.test.emit(
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.bean.scope('test-vona');
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.bean.scope('a-orm');
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.bean.scope('test-vona');
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.bean.scope('test-vona');
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.bean.scope('test-vona');
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.bean.scope('test-vona');
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.bean.scope('test-vona');
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.bean.scope('a-openapi').config.generateDocument.V31);
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.bean.scope('test-vona');
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.bean.scope('test-vona');
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.bean.scope('test-vona');
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.bean.scope('test-vona');
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.bean.scope('test-vona');
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.bean.scope('test-vona');
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.bean.scope('test-vona');
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.bean.scope('test-vona');
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.bean.scope('test-vona');
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.bean.scope('test-vona');
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.bean.scope('test-vona');
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.bean.scope('test-vona');
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.bean.scope('test-vona');
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.bean.scope('test-vona');
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 => {
@@ -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.bean.scope('test-vona');
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
  });
@@ -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.bean.scope('a-orm');
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.bean.scope('a-orm');
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');
@@ -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.bean.scope('test-vona');
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.bean.scope('test-vona');
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');