-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfcc70b
commit f4e6283
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |