Files
bigcapital/packages/server/tests/models/Item.test.js
2023-02-03 11:57:50 +02:00

23 lines
725 B
JavaScript

import { create, expect } from '~/testInit';
import Item from 'models/Item';
// eslint-disable-next-line no-unused-vars
import itemCategory from 'models/ItemCategory';
import {
tenantWebsite,
tenantFactory,
loginRes
} from '~/dbInit';
describe('Model: Item', () => {
it('Should item model belongs to the associated category model.', async () => {
const category = await tenantFactory.create('item_category');
const item = await tenantFactory.create('item', { category_id: category.id });
const itemModel = await Item.tenant().query().where('id', item.id).first();
const itemCategoryModel = await itemModel.$relatedQuery('category');
expect(itemCategoryModel.id).equals(category.id);
});
});