mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
add server to monorepo.
This commit is contained in:
22
packages/server/tests/models/Item.test.js
Normal file
22
packages/server/tests/models/Item.test.js
Normal file
@@ -0,0 +1,22 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user