Skip to content

Commit

Permalink
remove dynamic pkg.name in tests snapshots
Browse files Browse the repository at this point in the history
xeho91 committed Jul 21, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
xeho91 Mateusz Kadlubowski
1 parent fdebf5c commit b78d11d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/compiler/pre-transform/codemods/import-declaration.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pkg from '@storybook/addon-svelte-csf/package.json' with { type: 'json' };
import type { ImportDeclaration } from 'estree';
import { print } from 'svelte-ast-print';
import { describe, it } from 'vitest';
@@ -11,39 +10,39 @@ describe(transformImportDeclaration.name, () => {
it("removes legacy components and add 'defineMeta'", async ({ expect }) => {
const code = `
<script context="module" lang="ts">
import { Story, Template } from "${pkg.name}";
import { Story, Template } from "@storybook/addon-svelte-csf";
</script>
`;
const node = await parseAndExtractSvelteNode<ImportDeclaration>(code, 'ImportDeclaration');

expect(print(transformImportDeclaration({ node }))).toMatchInlineSnapshot(
`"import { defineMeta } from "${pkg.name}";"`
`"import { defineMeta } from "@storybook/addon-svelte-csf";"`
);
});

it("it doesn't remove existing 'defineMeta'", async ({ expect }) => {
const code = `
<script context="module" lang="ts">
import { Story, Template, defineMeta } from "${pkg.name}";
import { Story, Template, defineMeta } from "@storybook/addon-svelte-csf";
</script>
`;
const node = await parseAndExtractSvelteNode<ImportDeclaration>(code, 'ImportDeclaration');

expect(print(transformImportDeclaration({ node }))).toMatchInlineSnapshot(
`"import { defineMeta } from "${pkg.name}";"`
`"import { defineMeta } from "@storybook/addon-svelte-csf";"`
);
});

it("it doesn't remove existing 'setTemplate'", async ({ expect }) => {
const code = `
<script context="module" lang="ts">
import { defineMeta, setTemplate } from "${pkg.name}";
import { defineMeta, setTemplate } from "@storybook/addon-svelte-csf";
</script>
`;
const node = await parseAndExtractSvelteNode<ImportDeclaration>(code, 'ImportDeclaration');

expect(print(transformImportDeclaration({ node }))).toMatchInlineSnapshot(
`"import { defineMeta, setTemplate } from "${pkg.name}";"`
`"import { defineMeta, setTemplate } from "@storybook/addon-svelte-csf";"`
);
});
});

0 comments on commit b78d11d

Please sign in to comment.