chore: test (#2677)

This commit is contained in:
ChengLei Shao 2023-09-19 18:43:04 +08:00 committed by GitHub
parent fc609bafb9
commit 91095d8fe0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,39 @@ describe('belongs to many field', () => {
await db.close();
});
it('should define belongs to many relation through exists pivot collection', async () => {
const PostTag = db.collection({
name: 'postsTags',
fields: [
{
type: 'bigInt',
name: 'id',
primaryKey: true,
},
],
});
expect(PostTag.model.rawAttributes['id']).toBeDefined();
const Tag = db.collection({
name: 'tags',
fields: [
{ type: 'string', name: 'name' },
{ type: 'belongsToMany', name: 'posts', through: 'postsTags' },
],
});
const Post = db.collection({
name: 'posts',
fields: [
{ type: 'string', name: 'name' },
{ type: 'belongsToMany', name: 'tags', through: 'postsTags' },
],
});
expect(PostTag.model.rawAttributes['id']).toBeDefined();
});
test('association undefined', async () => {
const Post = db.collection({
name: 'posts',