mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 04:10:32 +00:00
feat: remove Webpack and depend on nodemon. feat: refactoring expenses. feat: optimize system users with caching. feat: architecture tenant optimize.
25 lines
743 B
JavaScript
25 lines
743 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);
|
|
});
|
|
});
|