-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(editor): Render checkboxes in markdown (#9549)
- Loading branch information
1 parent
a221215
commit 47d7741
Showing
3 changed files
with
74 additions
and
1 deletion.
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
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
45 changes: 45 additions & 0 deletions
45
packages/design-system/src/components/N8nMarkdown/__tests__/Markdown.spec.ts
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,45 @@ | ||
import { render } from '@testing-library/vue'; | ||
import N8nMarkdown from '../Markdown.vue'; | ||
|
||
describe('components', () => { | ||
describe('N8nMarkdown', () => { | ||
it('should render unchecked checkboxes', () => { | ||
const wrapper = render(N8nMarkdown, { | ||
props: { | ||
content: '__TODO__\n- [ ] Buy milk\n- [ ] Buy socks\n', | ||
}, | ||
}); | ||
const checkboxes = wrapper.getAllByRole('checkbox'); | ||
expect(checkboxes).toHaveLength(2); | ||
checkboxes.forEach((checkbox) => { | ||
expect(checkbox).not.toBeChecked(); | ||
}); | ||
}); | ||
it('should render checked checkboxes', () => { | ||
const wrapper = render(N8nMarkdown, { | ||
props: { | ||
content: '__TODO__\n- [X] Buy milk\n- [X] Buy socks\n', | ||
}, | ||
}); | ||
const checkboxes = wrapper.getAllByRole('checkbox'); | ||
expect(checkboxes).toHaveLength(2); | ||
checkboxes.forEach((checkbox) => { | ||
expect(checkbox).toBeChecked(); | ||
}); | ||
}); | ||
it('should render inputs as plain text', () => { | ||
const wrapper = render(N8nMarkdown, { | ||
props: { | ||
content: | ||
'__TODO__\n- [X] Buy milk\n- <input type="text" data-testid="text-input" value="Something"/>\n', | ||
}, | ||
}); | ||
const checkboxes = wrapper.getAllByRole('checkbox'); | ||
expect(checkboxes).toHaveLength(1); | ||
expect(wrapper.queryByTestId('text-input')).toBeNull(); | ||
expect(wrapper.html()).toContain( | ||
'<input type=“text” data-testid=“text-input” value=“Something”/>', | ||
); | ||
}); | ||
}); | ||
}); |