WIP pass the failed tests.

This commit is contained in:
Ahmed Bouhuolia
2020-05-17 07:08:12 +02:00
parent 00de156c9f
commit 10f636d2bc
77 changed files with 2164 additions and 1403 deletions

View File

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