Merge pull request #2206 from payloadcms/fix/2189-empty-json
fix: allows empty objects to be retained in db
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
@@ -24,6 +24,10 @@ export default buildConfig({
|
||||
slug,
|
||||
access,
|
||||
fields: [
|
||||
{
|
||||
name: 'json',
|
||||
type: 'json',
|
||||
},
|
||||
{
|
||||
name: 'title',
|
||||
type: 'text',
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user