Skip to content

Commit

Permalink
test: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
chenos committed Apr 20, 2024
1 parent 8f82954 commit 65b1e7c
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ describe('nocobase-admin-menu', () => {
});

test('migration', async () => {
await app.db.getRepository('collections').create({
values: {
autoGenId: true,
sortable: true,
name: 'bar',
template: 'general',
view: false,
},
context: {},
});
await app.db.getRepository('collections').create({
values: {
autoGenId: true,
Expand All @@ -37,7 +47,7 @@ describe('nocobase-admin-menu', () => {
{
type: 'sort',
name: 'sort3',
interface: 'sort3',
interface: 'sort',
uiSchema: {
type: 'number',
title: 'Sort 3',
Expand All @@ -46,10 +56,18 @@ describe('nocobase-admin-menu', () => {
'x-validator': 'integer',
},
},
{
type: 'hasMany',
name: 'bar',
target: 'bar',
foreignKey: 'fooId',
sortable: true,
},
],
},
context: {},
});

const migration = new Migration({
db: app.db,
// @ts-ignore
Expand Down Expand Up @@ -79,6 +97,15 @@ describe('nocobase-admin-menu', () => {
name: 'sort3',
},
});
expect(sort3.interface).toBe('sort');
expect(sort3.get('uiSchema.title')).toBe('Sort 3');
const sort4 = await app.db.getRepository('fields').findOne({
filter: {
collectionName: 'bar',
name: 'fooIdSort',
},
});
expect(sort4.interface).toBe('sort');
expect(sort4.get('uiSchema.title')).toBe('fooIdSort');
});
});

0 comments on commit 65b1e7c

Please sign in to comment.