import assert from 'node:assert/strict' import { readFileSync } from 'node:fs' import test from 'node:test' import * as Vue from 'vue' import { renderToString } from 'vue/server-renderer' const source = readFileSync( new URL('../src/components/business/column-header-filter/index.vue', import.meta.url), 'utf8' ) const countTemplate = source.match(/]*class="value-count"[^>]*>[\s\S]*?<\/span>/)![0] const render = Vue.compile(countTemplate) for (const [count, visible] of [ [undefined, false], [0, true], [7, true] ] as const) { test(`count ${count} renders only when supplied, including zero`, async () => { const html = await renderToString( Vue.createSSRApp({ data: () => ({ opt: { count } }), render }) ) assert.equal(html.includes('class="value-count"'), visible) if (visible) assert.ok(html.includes(`>${count}`)) }) }