Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correctly render array of custom elements in a slot #305

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add test
fago committed Jan 21, 2025

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit b2aa078e48c93e363575102d71f52f56ce11e28f
9 changes: 6 additions & 3 deletions test/unit/renderCustomElements.test.ts
Original file line number Diff line number Diff line change
@@ -3,24 +3,30 @@ import { describe, it, expect } from 'vitest'
import { mountSuspended } from '@nuxt/test-utils/runtime'
import { defineComponent } from 'vue'
import { useDrupalCe } from '../../src/runtime/composables/useDrupalCe'
import {useNuxtApp} from "#imports";

describe('renderCustomElements', () => {
const { renderCustomElements } = useDrupalCe()

// Define reusable test components
const TestComponent = defineComponent({
name: 'TestComponent',
props: {
foo: String
},
template: '<div>Test Component: {{ foo }}</div>'
})

const AnotherComponent = defineComponent({
name: 'AnotherComponent',
props: {
bar: String
},
template: '<div>Another Component: {{ bar }}</div>'
})
const app = useNuxtApp()
app.vueApp.component('TestComponent', TestComponent)
app.vueApp.component('AnotherComponent', AnotherComponent)

describe('basic input handling', () => {
it('should return null for empty inputs', () => {
@@ -67,7 +73,6 @@ describe('renderCustomElements', () => {
describe('custom element rendering', () => {
it('should render a single custom element', async () => {
const wrapper = await mountSuspended(defineComponent({
components: { TestComponent },
setup() {
return { component: renderCustomElements({
element: 'test-component',
@@ -96,7 +101,6 @@ describe('renderCustomElements', () => {

it('should render array of custom elements in a wrapper div', async () => {
const wrapper = await mountSuspended(defineComponent({
components: { TestComponent, AnotherComponent },
setup() {
return { component: renderCustomElements([
{ element: 'test-component', foo: 'one' },
@@ -114,7 +118,6 @@ describe('renderCustomElements', () => {
describe('edge cases', () => {
it('should handle malformed element objects', async () => {
const wrapper = await mountSuspended(defineComponent({
components: { TestComponent },
setup() {
return { component: renderCustomElements({ element: 'test-component' })}
},