@@ -179,10 +179,9 @@ describe('useSeoMetaTransform', () => {
179
179
])
180
180
expect(code).toBeDefined()
181
181
expect(code).toMatchInlineSnapshot(`
182
- "import { useSeoMeta as usm, useHead } from 'unhead'
183
- useHead({
184
- title: 'test',
185
- })
182
+ "import { useHead } from 'unhead'
183
+ import { useSeoMeta as usm, useHead } from 'unhead'
184
+ useHead({ title: 'test', })
186
185
useHead({
187
186
meta: [
188
187
{ name: 'description', content: 'World' },
@@ -233,7 +232,9 @@ describe('useSeoMetaTransform', () => {
233
232
])
234
233
expect(code).toBeDefined()
235
234
expect(code).toMatchInlineSnapshot(`
236
- "import { useServerSeoMeta, useServerHead, useHead, SomethingRandom } from 'unhead'
235
+ "import { useHead } from 'unhead'
236
+ import { useServerHead } from 'unhead'
237
+ import { useServerSeoMeta, useServerHead, useHead, SomethingRandom } from 'unhead'
237
238
useHead({
238
239
title: 'Hello',
239
240
});
@@ -522,4 +523,79 @@ export default /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render],
522
523
expect(code).match(/useServerHead/)
523
524
expect(code).match(/title:/)
524
525
})
526
+
527
+ it('#407', async () => {
528
+ const code = await transform(`
529
+ import { defineComponent as _defineComponent } from "vue";
530
+ import { useHead, useSeoMeta } from "@unhead/vue";
531
+
532
+ const _sfc_main = /* @__PURE__ */ _defineComponent({
533
+ __name: "app",
534
+ setup(__props, { expose }) {
535
+ expose();
536
+ useHead({ title: 'test' });
537
+ useSeoMeta({ description: 'foo' });
538
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
539
+ return __returned__;
540
+ }
541
+ });`, 'app.js')
542
+
543
+ expect(code).toBeDefined()
544
+ expect(code).toMatchInlineSnapshot(`
545
+ "import { useHead } from '@unhead/vue'
546
+
547
+ import { defineComponent as _defineComponent } from "vue";
548
+ import { useHead, useSeoMeta } from "@unhead/vue";
549
+
550
+ const _sfc_main = /* @__PURE__ */ _defineComponent({
551
+ __name: "app",
552
+ setup(__props, { expose }) {
553
+ expose();
554
+ useHead({ title: 'test' });
555
+ useHead({
556
+ meta: [
557
+ { name: 'description', content: 'foo' },
558
+ ]
559
+ });
560
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
561
+ return __returned__;
562
+ }
563
+ });"
564
+ `)
565
+ })
566
+
567
+ it('alt import as name', async () => {
568
+ const code = await transform(`
569
+ import { defineComponent as _defineComponent } from "vue";
570
+ import { useSeoMeta as SEOMETA } from "@unhead/vue";
571
+
572
+ const _sfc_main = /* @__PURE__ */ _defineComponent({
573
+ __name: "app",
574
+ setup(__props, { expose }) {
575
+ expose();
576
+ SEOMETA({});
577
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
578
+ return __returned__;
579
+ }
580
+ });`, 'app.js')
581
+
582
+ expect(code).toBeDefined()
583
+ expect(code).toMatchInlineSnapshot(`
584
+ "import { useHead } from '@unhead/vue'
585
+
586
+ import { defineComponent as _defineComponent } from "vue";
587
+ import { useSeoMeta as SEOMETA } from "@unhead/vue";
588
+
589
+ const _sfc_main = /* @__PURE__ */ _defineComponent({
590
+ __name: "app",
591
+ setup(__props, { expose }) {
592
+ expose();
593
+ useHead({
594
+ });
595
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
596
+ return __returned__;
597
+ }
598
+ });"
599
+ `)
600
+ })
525
601
})
0 commit comments