mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
WIP pass the failed tests.
This commit is contained in:
@@ -1,13 +1,20 @@
|
||||
import { create, expect } from '~/testInit';
|
||||
import {
|
||||
expect,
|
||||
} from '~/testInit';
|
||||
import Account from '@/models/Account';
|
||||
import AccountType from '@/models/AccountType';
|
||||
import {
|
||||
tenantFactory,
|
||||
tenantWebsite
|
||||
} from '~/dbInit';
|
||||
|
||||
|
||||
describe('Model: Account', () => {
|
||||
it('Should account model belongs to the associated account type model.', async () => {
|
||||
const accountType = await create('account_type');
|
||||
const account = await create('account', { account_type_id: accountType.id });
|
||||
const accountType = await tenantFactory.create('account_type');
|
||||
const account = await tenantFactory.create('account', { account_type_id: accountType.id });
|
||||
|
||||
const accountModel = await Account.query()
|
||||
const accountModel = await Account.tenant().query()
|
||||
.where('id', account.id)
|
||||
.withGraphFetched('type')
|
||||
.first();
|
||||
@@ -16,9 +23,9 @@ describe('Model: Account', () => {
|
||||
});
|
||||
|
||||
it('Should account model has one balance model that associated to the account model.', async () => {
|
||||
const accountBalance = await create('account_balance');
|
||||
const accountBalance = await tenantFactory.create('account_balance');
|
||||
|
||||
const accountModel = await Account.query()
|
||||
const accountModel = await Account.tenant().query()
|
||||
.where('id', accountBalance.accountId)
|
||||
.withGraphFetched('balance')
|
||||
.first();
|
||||
@@ -27,10 +34,10 @@ describe('Model: Account', () => {
|
||||
});
|
||||
|
||||
it('Should account model has many transactions models that associated to the account model.', async () => {
|
||||
const account = await create('account');
|
||||
const accountTransaction = await create('account_transaction', { account_id: account.id });
|
||||
const account = await tenantFactory.create('account');
|
||||
const accountTransaction = await tenantFactory.create('account_transaction', { account_id: account.id });
|
||||
|
||||
const accountModel = await Account.query().where('id', account.id).first();
|
||||
const accountModel = await Account.tenant().query().where('id', account.id).first();
|
||||
const transactionsModels = await accountModel.$relatedQuery('transactions');
|
||||
|
||||
expect(transactionsModels.length).equals(1);
|
||||
|
||||
Reference in New Issue
Block a user