mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
WIP pass the failed tests.
This commit is contained in:
@@ -1,15 +1,23 @@
|
||||
import { create, expect } from '~/testInit';
|
||||
import '@/models/Item';
|
||||
import ItemCategory from '@/models/ItemCategory';
|
||||
import {
|
||||
tenantWebsite,
|
||||
tenantFactory,
|
||||
loginRes
|
||||
} from '~/dbInit';
|
||||
|
||||
|
||||
describe('Model: ItemCategories', () => {
|
||||
it('Shoud item category model has many associated items.', async () => {
|
||||
const category = await create('item_category');
|
||||
await create('item', { category_id: category.id });
|
||||
await create('item', { category_id: category.id });
|
||||
const category = await tenantFactory.create('item_category');
|
||||
await tenantFactory.create('item', { category_id: category.id });
|
||||
await tenantFactory.create('item', { category_id: category.id });
|
||||
|
||||
const categoryModel = await ItemCategory.where('id', category.id).fetch();
|
||||
const categoryItems = await categoryModel.items().fetch();
|
||||
const categoryModel = await ItemCategory.tenant().query()
|
||||
.where('id', category.id).first();
|
||||
|
||||
const categoryItems = await categoryModel.$relatedQuery('items');
|
||||
|
||||
expect(categoryItems.length).equals(2);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user