UNPKG

@websolutespa/payload-plugin-bowl

Version:

Bowl PayloadCms plugin of the BOM Repository

57 lines (56 loc) 2.02 kB
import { config, GlobalCollection } from '@/test'; import { clearContext, endUsers, getContext, users } from '@websolutespa/test/payload'; import { v4 as uuid } from 'uuid'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; describe('withGlobal global', ()=>{ 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('Global config', ()=>{ let withGlobalConfig; beforeAll(async ()=>{ withGlobalConfig = payload.config.globals.find((global)=>global.slug === GlobalCollection.slug); }); describe('translation', ()=>{ it('should have a label property', ()=>{ expect(withGlobalConfig).toHaveProperty('label'); }); it('fields should have a label property', ()=>{ const [field] = withGlobalConfig.fields; expect(field).toHaveProperty('label'); }); }); }); describe('Global update', ()=>{ let doc; let postData; it('should update the global', async ()=>{ postData = { customField: uuid() }; ({ result: doc } = await client.post(`/globals/${GlobalCollection.slug}`, postData, { headers: { Authorization: `JWT ${userToken}` } })); expect(doc).toBeDefined(); }); it('global should have a valid custom field', async ()=>{ expect(doc.customField).toEqual(postData.customField); }); }); }); //# sourceMappingURL=withGlobal.test.js.map