mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-13 19:30:30 +00:00
24 lines
688 B
JavaScript
24 lines
688 B
JavaScript
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);
|
|
});
|
|
});
|
|
});
|