mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
25 lines
747 B
JavaScript
25 lines
747 B
JavaScript
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 tenantFactory.create('item_category');
|
|
await tenantFactory.create('item', { category_id: category.id });
|
|
await tenantFactory.create('item', { category_id: category.id });
|
|
|
|
const categoryModel = await ItemCategory.tenant().query()
|
|
.where('id', category.id).first();
|
|
|
|
const categoryItems = await categoryModel.$relatedQuery('items');
|
|
|
|
expect(categoryItems.length).equals(2);
|
|
});
|
|
});
|