Files
bigcapital/server/tests/models/User.test.js
Ahmed Bouhuolia a22c8395f3 feat: remove path alias.
feat: remove Webpack and depend on nodemon.
feat: refactoring expenses.
feat: optimize system users with caching.
feat: architecture tenant optimize.
2020-09-15 00:51:39 +02:00

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);
});
});
});