Merge pull request #2206 from payloadcms/fix/2189-empty-json

fix: allows empty objects to be retained in db
This commit is contained in:
James Mikrut
2023-02-28 10:45:46 -05:00
committed by GitHub
8 changed files with 47 additions and 4 deletions

View File

@@ -524,6 +524,19 @@ describe('Fields', () => {
},
})).rejects.toThrow('The following field is invalid: json');
});
it('should save empty json objects', async () => {
const createdJSON = await payload.create({
collection: 'json-fields',
data: {
json: {
state: {},
},
},
});
expect(createdJSON.json.state).toBeDefined();
});
});
describe('richText', () => {

View File

@@ -24,6 +24,10 @@ export default buildConfig({
slug,
access,
fields: [
{
name: 'json',
type: 'json',
},
{
name: 'title',
type: 'text',

View File

@@ -60,6 +60,19 @@ describe('globals', () => {
});
describe('local', () => {
it('should save empty json objects', async () => {
const createdJSON = await payload.updateGlobal({
slug,
data: {
json: {
state: {},
},
},
});
expect(createdJSON.json.state).toBeDefined();
});
it('should create', async () => {
const data = {
title: 'title',