Files
bigcapital/server/tests/models/ItemCategories.test.js
Ahmed Bouhuolia a22c8395f3 feat: remove path alias.
feat: remove Webpack and depend on nodemon.
feat: refactoring expenses.
feat: optimize system users with caching.
feat: architecture tenant optimize.
2020-09-15 00:51:39 +02:00

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