- You deserve good things. With a whooping 10-15% interest rate per annum, grow your savings on your own terms with our completely automated process
-
- `
+ it('should should stack native html elements', () => {
+ const { asFragment } = renderComponent({
+ template: `
+
+ The future can be even brighter but a goal without a plan is just a wish
+
I am a happy paragraph element
+
I am a jolly heading element
+ You deserve good things. With a whooping 10-15% interest rate per annum, grow your savings on your own terms with our completely automated process
+
+ `
+ })
+
+ expect(asFragment()).toMatchSnapshot()
})
- expect(asFragment()).toMatchSnapshot()
-})
+ // Cannot use `it.each` because it cannot accept
+ // component as interpolated variable
+ it.each`
+ as
+ ${'section'}
+ ${'nav'}}
+ `(
+ 'should render CStack with element as $as',
+ ({ as }) => {
+ const inlineAttrs = `as="${as}"`
+ const { asFragment } = renderComponent({ inlineAttrs })
+ const stack = screen.getByTestId('stack')
+ expect(getTagName(stack)).toEqual(as)
+ expect(asFragment()).toMatchSnapshot()
+ }
+ )
-// Cannot use `it.each` because it cannot accept
-// component as interpolated variable
+ it('should preserve inherited event listeners', async () => {
+ const handleClick = jest.fn()
+ renderComponent({
+ inlineAttrs: '@click="handleClick"',
+ methods: {
+ handleClick
+ }
+ })
-it.each`
- as
- ${'section'}
- ${'nav'}}
-`(
- 'should render CStack with element as $as',
- ({ as }) => {
- const inlineAttrs = `as="${as}"`
- const { asFragment } = renderComponent({ inlineAttrs })
- const stack = screen.getByTestId('stack')
- expect(getTagName(stack)).toEqual(as)
- expect(asFragment()).toMatchSnapshot()
- }
-)
+ await userEvent.click(screen.getByTestId('stack'))
+ expect(handleClick).toHaveBeenCalledTimes(1)
+ })
+
+ it('should preserve inherited event listeners with custom `as` component', async () => {
+ const handleSubmit = jest.fn((event) => {
+ expect(event.target).toBe(screen.getByTestId('stack-as-form'))
+ })
+ renderComponent({
+ template: `
+
+
+
+
+ `,
+ methods: {
+ handleSubmit
+ }
+ })
+
+ await userEvent.click(screen.getByTestId('form-submit-btn'))
+ expect(handleSubmit).toHaveBeenCalledTimes(1)
+ })
+})
diff --git a/packages/chakra-ui-core/src/CStack/tests/__snapshots__/CStack.test.js.snap b/packages/chakra-ui-core/src/CStack/tests/__snapshots__/CStack.test.js.snap
index f0ccd760..97c679c3 100644
--- a/packages/chakra-ui-core/src/CStack/tests/__snapshots__/CStack.test.js.snap
+++ b/packages/chakra-ui-core/src/CStack/tests/__snapshots__/CStack.test.js.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`should render CStack with element as nav 1`] = `
+exports[`CStack should render CStack with element as nav 1`] = `