import test from 'node:test' import assert from 'node:assert/strict' import fs from 'node:fs' import path from 'node:path' import vm from 'node:vm' import { fileURLToPath } from 'node:url' import Vue from 'vue' import { compileToFunctions } from 'vue-template-compiler' const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..') const componentPath = path.join(root, 'src/views/modules/activity/list.vue') const source = fs.readFileSync(componentPath, 'utf8') function operationButtons (row) { const operationSlot = source.match(/([\s\S]*?)<\/template>/)[1] const { render, staticRenderFns } = compileToFunctions(`
${operationSlot}
`) Vue.prototype.$hasPermission = () => true const vm = new Vue({ data: () => ({ scope: { row } }), methods: { handleEdit () {}, handleDetail () {}, handleInfo () {}, handleCode () {}, handleReviewCode () {}, handleUpDown () {}, handleCancel () {}, handleDelete () {} }, render, staticRenderFns }) const vnode = vm._render() return (vnode.children || []).map(child => child.children && child.children[0] && child.children[0].text).filter(Boolean) } function loadMethods () { const script = source.match(/