Merge remote-tracking branch 'origin' into feat/1695-nullable-localized-array-and-blocks

This commit is contained in:
Jarrod Flesch
2023-01-09 16:19:11 -05:00
250 changed files with 7253 additions and 5608 deletions

View File

@@ -15,12 +15,10 @@ import { defaultNumber, numberDoc } from './collections/Number';
let client;
describe('Fields', () => {
beforeAll(async (done) => {
beforeAll(async () => {
const { serverURL } = await initPayloadTest({ __dirname, init: { local: false } });
client = new RESTClient(config, { serverURL, defaultSlug: 'point-fields' });
await client.login();
done();
});
describe('text', () => {
@@ -505,6 +503,29 @@ describe('Fields', () => {
});
});
describe('json', () => {
it('should save json data', async () => {
const json = { foo: 'bar' };
const doc = await payload.create({
collection: 'json-fields',
data: {
json,
},
});
expect(doc.json).toStrictEqual({ foo: 'bar' });
});
it('should validate json', async () => {
await expect(async () => payload.create({
collection: 'json-fields',
data: {
json: '{ bad input: true }',
},
})).rejects.toThrow('The following field is invalid: json');
});
});
describe('richText', () => {
it('should allow querying on rich text content', async () => {
const emptyRichTextQuery = await payload.find({