@websolutespa/payload-plugin-bowl
Version:
Bowl PayloadCms plugin of the BOM Repository
46 lines (45 loc) • 1.72 kB
JavaScript
import { config } 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';
import { options } from '../../options';
describe('locale.service', ()=>{
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('Payload config', ()=>{
it('should have a endpoint with "/locale" path and method "get', ()=>{
expect(payload.config.endpoints.find((endpoint)=>endpoint.path === '/locale' && endpoint.method === 'get')).toBeDefined();
});
});
describe('/locale get', ()=>{
let result;
beforeAll(async ()=>{
result = await client.get(`/locale?t=${uuid()}`, {
headers: {
Authorization: `users API-Key ${users.api.apiKey}`
}
});
});
it('should return one locale "document" for each locale', async ()=>{
options.locales.forEach((locale)=>{
const code = typeof locale === 'string' ? locale : locale.code;
expect(result.docs.find((locDoc)=>locDoc.id === code)).toBeDefined();
});
});
});
});
//# sourceMappingURL=locale.service.test.js.map