Skip to content

Commit

Permalink
test: change to inline snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
wattanx committed Apr 30, 2024
1 parent 172a0a3 commit fccccb6
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions packages/vue-script-setup-converter/src/lib/convertSrc.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect, describe, it } from "vitest";
import { convertSrc } from "./convertSrc";
import { expect, describe, it } from 'vitest';
import { convertSrc } from './convertSrc';

describe("snapshot", () => {
it("lang=js", () => {
describe('snapshot', () => {
it('lang=js', () => {
const output = convertSrc(`<script>
import { defineComponent, toRefs, computed, ref } from 'vue';
Expand Down Expand Up @@ -37,7 +37,7 @@ export default defineComponent({
expect(output).toMatchSnapshot();
});

it("lang=ts", () => {
it('lang=ts', () => {
const output = convertSrc(`<script lang="ts">
import { defineComponent, toRefs, computed, ref } from 'vue';
Expand Down Expand Up @@ -73,7 +73,7 @@ export default defineComponent({
expect(output).toMatchSnapshot();
});

it("defineNuxtComponent", () => {
it('defineNuxtComponent', () => {
const output = convertSrc(`<script lang="ts">
import { defineNuxtComponent, useNuxtApp } from '#imports';
Expand All @@ -96,7 +96,7 @@ export default defineNuxtComponent({
expect(output).toMatchSnapshot();
});

it("empty setup context", () => {
it('empty setup context', () => {
const output = convertSrc(`<script lang="ts">
import { defineComponent, toRefs, computed } from 'vue';
Expand All @@ -118,14 +118,16 @@ export default defineComponent({
}
})
</script>`);
expect(output).toBe(
expect(output).toMatchInlineSnapshot(
`
import { defineComponent, toRefs, computed } from 'vue';
type Props = { msg?: string; }; const props = withDefaults(defineProps<Props>(), { msg: 'HelloWorld' });
const { msg } = toRefs(props);
const newMsg = computed(() => msg.value + '- HelloWorld');
`
"
import { defineComponent, toRefs, computed } from 'vue';
type Props = { msg?: string; }; const props = withDefaults(defineProps<Props>(), { msg: 'HelloWorld' });
const { msg } = toRefs(props);
const newMsg = computed(() => msg.value + '- HelloWorld');
"
`
);
});

Expand All @@ -150,13 +152,15 @@ export default defineComponent({
}
})
</script>`);
expect(output).toBe(
expect(output).toMatchInlineSnapshot(
`
import { defineComponent, computed } from 'vue';
type Props = { msg?: string; }; const props = withDefaults(defineProps<Props>(), { msg: 'HelloWorld' });
"
import { defineComponent, computed } from 'vue';
type Props = { msg?: string; }; const props = withDefaults(defineProps<Props>(), { msg: 'HelloWorld' });
const newMsg = computed(() => props.msg + '- HelloWorld');
`
const newMsg = computed(() => props.msg + '- HelloWorld');
"
`
);
})
});
});

0 comments on commit fccccb6

Please sign in to comment.