WIP pass the failed tests.

This commit is contained in:
Ahmed Bouhuolia
2020-05-17 07:08:12 +02:00
parent 00de156c9f
commit 10f636d2bc
77 changed files with 2164 additions and 1403 deletions

View File

@@ -1,15 +1,23 @@
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 create('item_category');
await create('item', { category_id: category.id });
await create('item', { category_id: category.id });
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.where('id', category.id).fetch();
const categoryItems = await categoryModel.items().fetch();
const categoryModel = await ItemCategory.tenant().query()
.where('id', category.id).first();
const categoryItems = await categoryModel.$relatedQuery('items');
expect(categoryItems.length).equals(2);
});