mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
add server to monorepo.
This commit is contained in:
23
packages/server/tests/models/User.test.js
Normal file
23
packages/server/tests/models/User.test.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import { create, expect } from '~/testInit';
|
||||
import User from 'models/TenantUser';
|
||||
import 'models/Role';
|
||||
import {
|
||||
tenantWebsite,
|
||||
tenantFactory,
|
||||
loginRes
|
||||
} from '~/dbInit';
|
||||
|
||||
|
||||
describe('Model: User', () => {
|
||||
describe('relations', () => {
|
||||
it('User model may has many associated roles.', async () => {
|
||||
const userHasRole = await tenantFactory.create('user_has_role');
|
||||
await tenantFactory.create('user_has_role', { user_id: userHasRole.user_id });
|
||||
|
||||
const userModel = await User.tenant().query().where('id', userHasRole.userId).first();
|
||||
const userRoles = await userModel.$relatedQuery('roles');
|
||||
|
||||
expect(userRoles).to.have.lengthOf(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user