Skip to content

Commit

Permalink
Test schema_menu_item creation
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanoverna committed Jan 15, 2024
1 parent cfcc70b commit f4e6283
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions packages/cma-client-node/__tests__/schemaMenuItem.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { generateNewCmaClient } from '../../../jest-helpers/generateNewCmaClient';
import { generateId } from '../../cma-client/src';

describe('menu item', () => {
it.concurrent('create, find, list, update, destroy', async () => {
const client = await generateNewCmaClient();

const schemaMenuItem = await client.schemaMenuItems.create({
kind: 'item_type',
label: 'Editorial content',
position: 1,
});

expect(schemaMenuItem.label).toEqual('Editorial content');

const foundschemaMenuItems = await client.schemaMenuItems.find(
schemaMenuItem,
);
expect(foundschemaMenuItems.id).toEqual(schemaMenuItem.id);

const allSchemaMenuItems = await client.schemaMenuItems.list();
expect(allSchemaMenuItems).toHaveLength(1);

const updatedschemaMenuItems = await client.schemaMenuItems.update(
schemaMenuItem,
{
...schemaMenuItem,
label: 'Updated',
},
);
expect(updatedschemaMenuItems.label).toEqual('Updated');

await client.schemaMenuItems.destroy(schemaMenuItem);
expect(await client.schemaMenuItems.list()).toHaveLength(0);
});

it.concurrent('create with explicit ID', async () => {
const client = await generateNewCmaClient();

const newId = generateId();

const schemaMenuItem = await client.schemaMenuItems.create({
id: newId,
kind: 'item_type',
label: 'Editorial content',
position: 1,
});

expect(schemaMenuItem.id).toEqual(newId);
});
});

0 comments on commit f4e6283

Please sign in to comment.