@websolutespa/payload-plugin-bowl
Version:
Bowl PayloadCms plugin of the BOM Repository
46 lines (45 loc) • 1.72 kB
JavaScript
import { config, FieldCollection } from '@/test';
import { clearContext, endUsers, getContext, users } from '@websolutespa/test/payload';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
describe('withMedias 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((x)=>x.slug === FieldCollection.slug);
});
it('should have a field named "medias" of type "array"', ()=>{
field = collection.fields.find((field)=>field.type === 'array' && field.name === 'medias');
expect(field).toBeDefined();
});
describe('Subfields', ()=>{
describe('"media" subfield', ()=>{
let mediaField;
it('should have a subfield "media" (withMedia) of type "upload"', ()=>{
mediaField = field.fields.find((field)=>field.type === 'upload' && field.name === 'media');
expect(mediaField).toBeDefined();
});
});
});
});
/*
@todo: test document creation
describe('Document creation', () => {});
*/ });
//# sourceMappingURL=withMedias.test.js.map