-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/add option categories page 1732 (#328)
* feat: validate optionCategories in prefab components * feat: add option categories validation to wrapper options * test: add tests * feat: throw when option category member refers to non-existing option
- Loading branch information
NiekBetty
authored
Jul 28, 2022
1 parent
c80e48e
commit 0ee9ab4
Showing
7 changed files
with
220 additions
and
28 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,57 @@ | ||
import test, { ExecutionContext } from 'ava'; | ||
|
||
import { checkOptionCategoryReferences } from '../../src/utils/validation'; | ||
import type { Prefab } from '../../src/types'; | ||
|
||
type Context = ExecutionContext<unknown>; | ||
|
||
test('Throws when option category references do not match an option', (t: Context): void => { | ||
const prefabs = [ | ||
{ | ||
name: 'Component name', | ||
icon: 'TitleIcon', | ||
category: 'CONTENT', | ||
structure: [ | ||
{ | ||
type: 'WRAPPER', | ||
optionCategories: [{ label: 'Category 2', members: ['foo'] }], | ||
options: [ | ||
{ | ||
key: '0', | ||
type: 'LINKED_OPTION', | ||
value: { | ||
ref: { | ||
componentId: '#textComponent', | ||
optionId: '#textOption', | ||
}, | ||
}, | ||
}, | ||
], | ||
descendants: [ | ||
{ | ||
ref: { | ||
id: '#textComponent', | ||
}, | ||
name: 'Text', | ||
optionCategories: [{ label: 'Category 1', members: ['foo'] }], | ||
options: [ | ||
{ | ||
ref: { | ||
id: '#textOption', | ||
}, | ||
value: '', | ||
label: 'something', | ||
key: 'option1', | ||
type: 'TEXT', | ||
}, | ||
], | ||
descendants: [], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
] as unknown as Prefab[]; | ||
|
||
t.throws(() => checkOptionCategoryReferences(prefabs)); | ||
}); |
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
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
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
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
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
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