UNPKG

@websolutespa/payload-plugin-bowl

Version:

Bowl PayloadCms plugin of the BOM Repository

42 lines (41 loc) 1.6 kB
import { config } from '@/test'; import { clearContext, endUsers, getContext, users } from '@websolutespa/test/payload'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; import { options } from '../../options'; describe('withTenants field', ()=>{ let payload; let client; let userToken; let endUserToken; let apiKey; beforeAll(async ()=>{ const context = await getContext(config); payload = context.payload; client = context.client; userToken = await client.getToken('users', users.admin); endUserToken = await client.getToken('end_users', endUsers.user); apiKey = users.api.apiKey; }); afterAll(async ()=>{ await clearContext(); }); describe('Field config', ()=>{ let collection; let field; beforeAll(async ()=>{ collection = payload.config.collections.find((collection)=>collection.slug === options.slug.users); }); it('Users collection should have a field named "tenants" of type "relationship"', ()=>{ field = collection.fields.find((field)=>field.type === 'relationship' && field.name === 'tenants'); expect(field).toBeDefined(); }); it('should allow multiple relations', ()=>{ expect(field.hasMany).toEqual(true); }); it('should be editable only by admins', ()=>{ expect(field.access.create.name).toEqual('isAdmin'); expect(field.access.update.name).toEqual('isAdmin'); }); }); }); //# sourceMappingURL=withTenants.test.js.map