Skip to content

Commit

Permalink
👌 #19 - PR feecback.
Browse files Browse the repository at this point in the history
- Move fixture to story.
- Remove selector option in test.
  • Loading branch information
Sven van de Scheur committed May 11, 2023
1 parent c78f36a commit f6b4280
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 88 deletions.
83 changes: 0 additions & 83 deletions src/fixtures/formio/formio-conditional.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/fixtures/formio/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './formio-columns';
export * from './formio-conditional';
export * from './formio-example';
export * from './formio-length';
export * from './formio-pattern';
Expand Down
88 changes: 84 additions & 4 deletions src/lib/renderer/renderer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,89 @@ renderFormWithConditionalLogic.args = {
configuration: DEFAULT_RENDER_CONFIGURATION,
form: {
display: 'form',
components: FORMIO_CONDITIONAL,
components: [
// Reference field.
{
id: 'favoriteAnimal',
type: 'textfield',
label: 'Favorite animal',
key: 'favoriteAnimal',
},

// Case: hide unless "cat"
{
conditional: {
eq: 'cat',
show: true,
when: 'favoriteAnimal',
},
id: 'motivationCat',
hidden: true,
type: 'textfield',
key: 'motivation',
label: 'Motivation',
placeholder: 'I like cats because...',
description: 'Please motivate why "cat" is your favorite animal...',
},

// Case hide unless "dog"
{
conditional: {
eq: 'dog',
show: true,
when: 'favoriteAnimal',
},
id: 'motivationDog',
hidden: true,
type: 'textfield',
key: 'motivation',
label: 'Motivation',
placeholder: 'I like dogs because...',
description: 'Please motivate why "dog" is your favorite animal...',
},

// Case hide unless "" (empty string)
{
conditional: {
eq: '',
show: true,
when: 'favoriteAnimal',
},
id: 'content1',
hidden: true,
type: 'content',
key: 'content',
html: 'Please enter you favorite animal.',
},

// Case show unless "cat"
{
conditional: {
eq: 'cat',
show: false,
when: 'favoriteAnimal',
},
id: 'content2',
hidden: false,
type: 'content',
key: 'content',
html: 'Have you tried "cat"?',
},

// Case show unless "dog"
{
conditional: {
eq: 'dog',
show: false,
when: 'favoriteAnimal',
},
id: 'content3',
hidden: false,
type: 'content',
key: 'content',
html: 'Have you tried "dog"?',
},
],
},
initialValues: {
favoriteAnimal: '',
Expand All @@ -177,9 +259,7 @@ renderFormWithConditionalLogic.args = {
};
renderFormWithConditionalLogic.play = async ({canvasElement}) => {
const canvas = within(canvasElement);
const input = canvas.getByLabelText('Favorite animal', {
selector: 'input',
});
const input = canvas.getByLabelText('Favorite animal');
expect(
await canvas.queryByText('Please motivate why "cat" is your favorite animal...')
).toBeNull();
Expand Down

0 comments on commit f6b4280

Please sign in to comment.