mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 04:10:32 +00:00
16 lines
509 B
JavaScript
16 lines
509 B
JavaScript
import { create, expect } from '~/testInit';
|
|
import User from '@/models/User';
|
|
import '@/models/Role';
|
|
|
|
describe('Model: User', () => {
|
|
it('User model may has many associated roles.', async () => {
|
|
const userHasRole = await create('user_has_role');
|
|
await create('user_has_role', { user_id: userHasRole.user_id });
|
|
|
|
const userModel = await User.where('id', userHasRole.user_id).fetch();
|
|
const userRoles = await userModel.roles().fetch();
|
|
|
|
expect(userRoles).to.have.lengthOf(2);
|
|
});
|
|
});
|