chore: adds version count tests

This commit is contained in:
James
2023-01-16 21:05:40 -05:00
parent 8cfa550954
commit dff840c49b

View File

@@ -256,6 +256,61 @@ describe('Versions', () => {
expect(draftPost.title.es).toBe(spanishTitle);
});
});
describe('Draft Count', () => {
it('creates proper number of drafts', async () => {
const originalDraft = await payload.create({
collection: 'draft-posts',
draft: true,
data: {
title: 'A',
description: 'A',
_status: 'draft',
},
});
await payload.update({
collection: 'draft-posts',
id: originalDraft.id,
draft: true,
data: {
title: 'B',
description: 'B',
_status: 'draft',
},
});
await payload.update({
collection: 'draft-posts',
id: originalDraft.id,
draft: true,
data: {
title: 'C',
description: 'C',
_status: 'draft',
},
});
const mostRecentDraft = await payload.findByID({
collection: 'draft-posts',
id: originalDraft.id,
draft: true,
});
expect(mostRecentDraft.title).toStrictEqual('C');
const versions = await payload.findVersions({
collection: 'draft-posts',
where: {
parent: {
equals: originalDraft.id,
},
},
});
expect(versions.docs).toHaveLength(3);
});
});
});
describe('Querying', () => {